Taylor Polynomials

The standard Maple command taylor can be used to generate the first few terms of the Taylor's

or Maclaurin's series for a function. Three parameters are required. The first is an expression

for the value of the function, the second is x=0 for a Maclaurin's series or x=a if a Taylor's

series in powers of (x-a) is desired, and the third is the number of terms desired or one larger

than the highest power required (because the constant term is an extra term).

> taylor(sin(x),x=0,11);

series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^...

> taylor(sin(x),x=Pi/2,9);

series(1-1/2*(x-1/2*Pi)^2+1/24*(x-1/2*Pi)^4-1/720*(...

The last term is called a Big Oh term, and represents the fact that the tail end of the series is less than

some constant times the absolute value of the power inside the parentheses following the Big Oh

symbol. The output of the taylor command can be used to see as many terms of the Taylor's series as desired, but it is not useful for evaluation or graphing. The taylorfunction command in the wfucalc library may be used for evaluating and graphing Taylor polynomials of a function. For example the third, fifth, and seventh degree Taylor polynomials about x=0 for sin(x) can be defined as follows:

> with(wfucalc);

[eulerf, limitf, mygcd, nall, nallexp, nallquad, ne...
[eulerf, limitf, mygcd, nall, nallexp, nallquad, ne...
[eulerf, limitf, mygcd, nall, nallexp, nallquad, ne...

> p3:=taylorfunction(sin(x),x=0,4);

p3 := proc (x) options operator, arrow; x-1/6*x^3 e...

> p5:=taylorfunction(sin(x),x=0,6);

p5 := proc (x) options operator, arrow; x-1/6*x^3+1...

> p7:=taylorfunction(sin(x),x=0,8);

p7 := proc (x) options operator, arrow; x-1/6*x^3+1...

Now compare the approximations these polynomials (or partial sums) give to the actual value of sin(1).

Note that p3 gives only about 1 decimal accuracy, while p5 gives about 2 or 3 decimal accuracy, and p7 gives about 4 decimal accuracy.

> evalf([sin(1),p3(1),p5(1),p7(1)]);

[.8414709848, .8333333333, .8416666667, .8414682540...

Now let's compare the graphs of sin(x) with each of these Taylor polynomials.

> plot([sin(x),p3(x),p5(x),p7(x)],x=-4..4,y=-4..4,color=[red,green,blue, yellow]);

[Maple Plot]

Next, we look at the Taylor polynomials for sin(x) about x =Pi/2, and compare their graphs with the graph of sin(x) when x is near Pi/2.

> q2:=taylorfunction(sin(x),x=Pi/2,3);

q2 := proc (x) options operator, arrow; 1-1/2*(x-1/...

> q4:=taylorfunction(sin(x),x=Pi/2,5);

q4 := proc (x) options operator, arrow; 1-1/2*(x-1/...

> q6:=taylorfunction(sin(x),x=Pi/2,7);

q6 := proc (x) options operator, arrow; 1-1/2*(x-1/...

> plot([sin(x),q2(x),q4(x),q6(x)],x=-2..5,color=[red,green,blue,yellow]);

[Maple Plot]

>