# Tema 8
08-4  La fórmula de Taylor

Expressió del polinomi de Taylor d'una funció

kill(all)$

taylor(f(x), x, x0, 3);

taylor(f(x), x, 0, 3);

Exemple 8.4.1

kill(all)$

f1(x):=exp(x);
taylor(f1(x), x, 0, 1);         taylor(f1(x), x, 0, 2);
taylor(f1(x), x, 0, 3);         taylor(f1(x), x, 0, 4);

define ( T1(x) , taylor(f1(x), x, 0, 1) );                             
define ( T2(x) , taylor(f1(x), x, 0, 2) ); 
define ( T3(x) , taylor(f1(x), x, 0, 3) ); 
define ( T4(x) , taylor(f1(x), x, 0, 4) );

wxplot2d([f1(x),T1(x)], [x,-2,2], [ylabel, ""] , [legend, "f(x)" , "T1(x)"] , [style, [lines, 2]] ,
[gnuplot_preamble, "set grid"], [nticks, 300] )$

wxplot2d([f1(x),T2(x)], [x,-2,2], [ylabel, ""] , [legend, "f(x)" , "T2(x)"] , [style, [lines, 2]] ,
 [gnuplot_preamble, "set grid"], [nticks, 300] )$

wxplot2d([f1(x),T3(x)], [x,-2,2], [ylabel, ""] , [legend, "f(x)" , "T3(x)"] , [style, [lines, 2]] ,
[gnuplot_preamble, "set grid"], [nticks, 300] )$

wxplot2d([f1(x),T4(x)], [x,-2,2], [ylabel, ""] , [legend, "f(x)" , "T4(x)"] , [style, [lines, 2]] ,
[gnuplot_preamble, "set grid"], [nticks, 300] )$

wxplot2d([f1(x),T4(x)], [x,-0.2,0.2], [ylabel, ""] , [legend, "f(x)" , "T4(x)"] , [style, [lines, 2]] ,
[gnuplot_preamble, "set grid"], [nticks, 300] )$

Exemple 8.4.2

kill(all)$

f(x):=cos(x^2);        
define (T4(x) , taylor(f(x), x, 0, 4) );

wxplot2d([f(x),T4(x)], [x,-3,3], [y,-2, 2], [ylabel, ""] , [legend, "f(x)" , "T4(x)"] , [style, [lines, 2]] ,
[gnuplot_preamble, "set grid"], [nticks, 300] )$

define (T8(x) , taylor(f(x), x, 0, 8) );

wxplot2d([f(x),T8(x)], [x,-3,3], [y,-2,2], [ylabel, ""] , [legend, "f(x)" , "T8(x)"] , [style, [lines, 2]] ,
[gnuplot_preamble, "set size ratio 1; set grid"], [nticks, 300] )$

define (T16(x) , taylor(f(x), x, 0, 16) );

wxplot2d([f(x),T16(x)], [x,-3,3], [y,-2,2], [ylabel, ""] , [legend, "f(x)" , "T16(x)"] , [style, [lines, 2]] ,
[gnuplot_preamble, "set size ratio 1; set grid"], [nticks, 300] )$

Sèries de potències

kill(all)$

'exp(x)=powerseries(exp(x), x, 0);

'exp(x)=niceindices(powerseries(exp(x), x, 0));

'sin(x)=niceindices(powerseries(sin(x), x, 0));

'cos(x)=niceindices(powerseries(cos(x), x, 0));

'atan(x)=niceindices(powerseries(atan(x), x, 0));

f4(x):=1/(1+x);     'f4(x)=niceindices(powerseries(f4(x), x, 0));

'log(x+1)=niceindices(powerseries(log(x+1), x, 0));

'log(x)=niceindices(powerseries(log(x), x, 1));