以下动画演示了cosx的泰勒多项式逼近cosx的过程:
with(plots):f(x):=cos(x):
n:=39:xmax:=15:ymax:=4:
hanshu:=plot(f(x),x=-1..xmax):
for k from 1 to n do:
s[k]:=taylor(f(x),x=0,k):
taylor_duoxiangshi[k]:=convert(%,polynom):
duoxiangshi[k]:=plot(taylor_duoxiangshi[k],x=-1..xmax,color=blue):od:
duoxiangshi:=display(seq(duoxiangshi[k],k=1..n),insequence=true):
display(duoxiangshi,hanshu,scaling=constrained,thickness=3,view=[-1..xmax,-1..ymax]);
评论