Taylorovy polynomy zadané funkce: sin(x) 

> # initialize
restart;
with(plots);
f:=sin(x);
# nmax is the maximum approximation order (the order of the Taylor polynomial + 1)
nmax:=9;
setoptions(thickness=2);
 

 

 

[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fiel...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fiel...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fiel...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fiel...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fiel...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fiel...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fiel...
sin(x)
9 (1)
 

> # initialize the lists T and R
T:=[seq(0,i=1..nmax+1)];
R:=T;
# now calculate the Taylor polynomials
for n from 1 to nmax do
T[n]:=convert(taylor(f,x,n),polynom);
R[n]:=f-T[n];
end do;
n:='n';
 

                                       
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
0
sin(x)
x
`+`(sin(x), `-`(x))
x
`+`(sin(x), `-`(x))
`+`(x, `-`(`*`(`/`(1, 6), `*`(`^`(x, 3)))))
`+`(sin(x), `-`(x), `*`(`/`(1, 6), `*`(`^`(x, 3))))
`+`(x, `-`(`*`(`/`(1, 6), `*`(`^`(x, 3)))))
`+`(sin(x), `-`(x), `*`(`/`(1, 6), `*`(`^`(x, 3))))
`+`(x, `-`(`*`(`/`(1, 6), `*`(`^`(x, 3)))), `*`(`/`(1, 120), `*`(`^`(x, 5))))
`+`(sin(x), `-`(x), `*`(`/`(1, 6), `*`(`^`(x, 3))), `-`(`*`(`/`(1, 120), `*`(`^`(x, 5)))))
`+`(x, `-`(`*`(`/`(1, 6), `*`(`^`(x, 3)))), `*`(`/`(1, 120), `*`(`^`(x, 5))))
`+`(sin(x), `-`(x), `*`(`/`(1, 6), `*`(`^`(x, 3))), `-`(`*`(`/`(1, 120), `*`(`^`(x, 5)))))
`+`(x, `-`(`*`(`/`(1, 6), `*`(`^`(x, 3)))), `*`(`/`(1, 120), `*`(`^`(x, 5))), `-`(`*`(`/`(1, 5040), `*`(`^`(x, 7)))))
`+`(sin(x), `-`(x), `*`(`/`(1, 6), `*`(`^`(x, 3))), `-`(`*`(`/`(1, 120), `*`(`^`(x, 5)))), `*`(`/`(1, 5040), `*`(`^`(x, 7))))
`+`(x, `-`(`*`(`/`(1, 6), `*`(`^`(x, 3)))), `*`(`/`(1, 120), `*`(`^`(x, 5))), `-`(`*`(`/`(1, 5040), `*`(`^`(x, 7)))))
`+`(sin(x), `-`(x), `*`(`/`(1, 6), `*`(`^`(x, 3))), `-`(`*`(`/`(1, 120), `*`(`^`(x, 5)))), `*`(`/`(1, 5040), `*`(`^`(x, 7))))
n (2)
 

Graf funkce a jejího n-tého Taylorova polynomu 

> # n goes from 0 to nmax-1 to represent the order of the Taylor polynomial
plots[animate](plot,[[f,T[n+1]],x=-5..5,y=-10..10],n=[seq(i,i=0..nmax-1)]);
 

Plot_2d
 

Graf zbytku po n-tém Taylorově polynomu 

> animate(plot,[R[n+1],x=-5..5,y=-10..10],n=[seq(i,i=0..nmax-1)]);
 

Plot_2d
 

>