Taylor series 2

2273 days ago by Marnix.VanDaele

Symbolische reeksontwikkingen (ontwikkelingen waarbij f(x) geen specifiek functievoorschrift heeft).

var ('h'); f=function('f'); 
       
taylor(f(x+h),h,0,2) 
       
1/2*h^2*diff(f(x), x, x) + h*diff(f(x), x) + f(x)
1/2*h^2*diff(f(x), x, x) + h*diff(f(x), x) + f(x)

Op weg naar een eerste-orde benadering van f'(x)

expr=f(x+h)-f(x); taylor(expr,h,0,2); 
       
1/2*h^2*diff(f(x), x, x) + h*diff(f(x), x)
1/2*h^2*diff(f(x), x, x) + h*diff(f(x), x)
approx1=(f(x+h)-f(x))/(h); fout_approx1=diff(f(x),x)-approx1; taylor(fout_approx1,h,0,2); 
       
-1/6*h^2*diff(f(x), x, x, x) - 1/2*h*diff(f(x), x, x)
-1/6*h^2*diff(f(x), x, x, x) - 1/2*h*diff(f(x), x, x)

Op weg naar een tweede-orde benadering van f'(x).

taylor(f(x-h),h,0,2) 
       
1/2*h^2*diff(f(x), x, x) - h*diff(f(x), x) + f(x)
1/2*h^2*diff(f(x), x, x) - h*diff(f(x), x) + f(x)
expr2=f(x+h)-f(x-h); taylor(expr2,h,0,2); 
       
2*h*diff(f(x), x)
2*h*diff(f(x), x)
approx2=(f(x+h)-f(x-h))/(2*h); fout_approx2=diff(f(x),x)-approx2; taylor(fout_approx2,h,0,2); 
       
-1/6*h^2*diff(f(x), x, x, x)
-1/6*h^2*diff(f(x), x, x, x)