#pkg load symbolic; #1.a syms x; f=exp(x) t1=taylor(f,x,0,'order',1); t2=taylor(f,x,0,'order',2); t3=taylor(f,x,0,'order',3); t4=taylor(f,x,0,'order',4); t10 = taylor(f,x,0,'order',10); #ezplot(t1) hold on ezplot(t2) hold on ezplot(t3) hold on ezplot(t4) xlim([-3,3]) #1.b vpa(exp(1),7) vpa(subs(t10,x,1),7) #2.a syms x; f=sin(x) t3=taylor(f,x,0,'order',3); t5=taylor(f,x,0,'order',5); hold off ezplot(f) hold on ezplot(t3) hold on ezplot(t5) xlim([-pi,pi]) ylim([-2,2]) #2.b t10=taylor(f,x,0,'order',10); vpa(sin(pi/5),5) vpa(subs(t10,x,sym(pi)/5),5) vpa(sin(10*pi/3),5) vpa(subs(t10,x,10*sym(pi)/3),5) #it's not precise enought, increase n for Taylor series or move x0=0 to x0= 10pi/3 #3.a syms x; f=log(1+x); t2= taylor(f,x,0,'order',2); t5= taylor(f,x,0,'order',5); hold off ezplot(f) hold on ezplot(t2) hold on ezplot(t5) xlim([-0.9,1]) ylim([-1,1]) t= taylor(f,x,0,'order',10); vpa(log(2),5) vpa(subs(t,x,1),5) syms x; g=log(1-x); t2 = taylor(g,x,0,'order',10) t-t2 vpa(subs(t,x,sym(0.999,'f')) - subs(g,x,sym(0.999,'f')),5)