diff --git a/source/calculus/exercises/outcomes/TI/TI3/generator.sage b/source/calculus/exercises/outcomes/TI/TI3/generator.sage index 0c92a0cd8..e2afa39d5 100644 --- a/source/calculus/exercises/outcomes/TI/TI3/generator.sage +++ b/source/calculus/exercises/outcomes/TI/TI3/generator.sage @@ -1,32 +1,50 @@ +#Functions to display powers of trig functions +def print_cosp(self,*args): return f"\\cos ^{{{args[1]}}}({latex(args[0])})" +def deriv_cosp(self,*args,**kwds): + if args[1]==1: + return -1*sinp(args[0],1)*args[0].derivative(args[kwds['diff_param']]) + else: + return args[1]*-1*cosp(args[0],args[1]-1)*sinp(args[0],1)*args[0].derivative(args[kwds['diff_param']]) + +cosp = function("cosp",nargs=2,print_latex_func=print_cosp,derivative_func=deriv_cosp) +def print_sinp(self,*args): return f"\\sin ^{{{args[1]}}}({latex(args[0])})" +def deriv_sinp(self,*args,**kwds): + if args[1]==1: + return cosp(args[0],1)*args[0].derivative(args[kwds['diff_param']]) + else: + return args[1]*sinp(args[0],args[1]-1)*cosp(args[0],1)*args[0].derivative(args[kwds['diff_param']]) + +sinp = function("sinp",nargs=2,print_latex_func=print_sinp, derivative_func=deriv_sinp) + class Generator(BaseGenerator): + def data(self): - # integral with odd power + # Task 1, integral with odd power x=var("x") - even=2*randint(1,6) - - odd=choice([5,7]) + n=randint(1,6) + m=randint(2,3) - z = var("z") - if odd==5: - hint = "hint_2" - else: - hint = "hint_3" + k=var('k') + z=var('z') + hint=f"(1-z)^{m}={latex(sum(binomial(m,k)*(-z)^k,k,0,m))}" - trigs=[sin, cos] - shuffle(trigs) - f=randint(1,5)*(trigs[0](x))^even*(trigs[1](x))^odd + trigs=[sinp, cosp] + shuffle(trigs) - F=f.integral(x) + a = randint(1,6) + f = a*trigs[0](x,2*n)*trigs[1](x,2*m+1) + F = sum(a*binomial(m,k)*(-1)^k*1/(2*n+2*k+1)*trigs[0](x,2*n+2*k+1)*trigs[0](x,1).derivative(x)/trigs[1](x,1),k,0,m) + - # integral with even powers + # Task 2, integral with even powers a = randrange(2,6) m = randrange(2,5) n = randrange(2,5) k = 2^randrange(2,5) - g = k*cos(a*x)^(2*m)*sin(a*x)^(2*n) + g = k*cosp(a*x,2*m)*sinp(a*x,2*n) also_g = k/2^(m+n)*(1+cos(2*a*x))^m*(1-cos(2*a*x))^n @@ -35,5 +53,5 @@ class Generator(BaseGenerator): "F": F, "g": g, "also_g": also_g, - hint: True, + "hint": hint, } diff --git a/source/calculus/exercises/outcomes/TI/TI3/template.xml b/source/calculus/exercises/outcomes/TI/TI3/template.xml index 0377ef9f6..6239538d2 100644 --- a/source/calculus/exercises/outcomes/TI/TI3/template.xml +++ b/source/calculus/exercises/outcomes/TI/TI3/template.xml @@ -3,14 +3,8 @@

-Use trigonometric identities and -{{#hint_2}} -(1-z)^2=1-2z+z^2 -{{/hint_2}} -{{#hint_3}} -(1-z)^3=1-3z+3z^2-z^3 -{{/hint_3}} -to explain and demonstrate how to find +Using trigonometric identities and the fact that {{hint}}, +explain and demonstrate how to find \displaystyle \int {{f}} dx.