MapleMaclaurinTangent.mws

Maclaurin and Taylor  Pollynomials

tan(x), esp(x), ln(x)

>    with(plots):

Warning, the name changecoords has been redefined

tan(x)

>    evalf(tan(0.2));

.2027100355

>    evalf(0.2+0.2^3/3);

.2026666667

>    evalf(tan(Pi/4));

1.

>    evalf(Pi/4+(Pi/4)^3/3);

.9468891879

>    Order:=10;

Order := 10

>    t:=taylor(tan(x),x=0);

t := series(1*x+1/3*x^3+2/15*x^5+17/315*x^7+62/2835*x^9+O(x^10),x,10)

Convert to a polynomial and then a function.

>    p:=convert(t,polynom);

p := x+1/3*x^3+2/15*x^5+17/315*x^7+62/2835*x^9

>    f:=p;

f := x+1/3*x^3+2/15*x^5+17/315*x^7+62/2835*x^9

>    eval(f,x=Pi/4);

1/4*Pi+1/192*Pi^3+1/7680*Pi^5+17/5160960*Pi^7+31/371589120*Pi^9

>    evalf(%);

.9991710669

Here I graph tan(x) and the third and ninth Maclaurin polynomials.

>    P3:=plot(x+x^3/3,x=-Pi/2..Pi/2,y=-10..10,thickness=3,color=blue,labels=[x,y]):

>    P9:=plot(f,x=-Pi/2..Pi/2,y=-10..10,thickness=3,color=green,labels=[x,y]):

>    TanGraph:=plot(tan(x),x=-Pi/2..Pi/2,y=-10..10,thickness=3,color=red,labels=[x,y]):

>    display(P3,P9,TanGraph);

[Maple Plot]

Construct and graph the tenth Maclaurin polynomial for exp(x).

>    Order:=11;

Order := 11

>    te10:=taylor(exp(x),x=0);

te10 := series(1+1*x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8+1/362880*x^9+1/3628800*x^10+O(x^11),x,11)

>    pe10:=convert(te10,polynom);

pe10 := 1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8+1/362880*x^9+1/3628800*x^10

>    pe10Graph:=plot(pe10,x=-10..10,y=-10..10000,thickness=3,color=blue,labels=[x,y]):

>    ExpGraph:=plot(exp(x),x=-10..10,y=-10..10000,thickness=3,color=red,labels=[x,y]):

>    display(pe10Graph,ExpGraph);

[Maple Plot]

Below we see exp(2) being approximated by 10th and 20th Maclaurin polynomials.

>    f:=pe10;

f := 1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8+1/362880*x^9+1/3628800*x^10

>    eval(f,x=2);

34913/4725

>    evalf(%);

7.388994709

>    evalf(exp(2));

7.389056099

>    Order:=21;

Order := 21

>    t20:=taylor(exp(x),x=0);

t20 := series(1+1*x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8+1/362880*x^9+1/3628800*x^10+1/39916800*x^11+1/479001600*x^12+1/6227020800*x^13+1/87178291200*x^14+1/1307674368000...
t20 := series(1+1*x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8+1/362880*x^9+1/3628800*x^10+1/39916800*x^11+1/479001600*x^12+1/6227020800*x^13+1/87178291200*x^14+1/1307674368000...

>    pe20:=convert(t20,polynom);

pe20 := 1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8+1/362880*x^9+1/3628800*x^10+1/39916800*x^11+1/479001600*x^12+1/6227020800*x^13+1/87178291200*x^14+1/1307674368000*x^15+1/...
pe20 := 1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8+1/362880*x^9+1/3628800*x^10+1/39916800*x^11+1/479001600*x^12+1/6227020800*x^13+1/87178291200*x^14+1/1307674368000*x^15+1/...

>    f:=pe20;

f := 1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8+1/362880*x^9+1/3628800*x^10+1/39916800*x^11+1/479001600*x^12+1/6227020800*x^13+1/87178291200*x^14+1/1307674368000*x^15+1/209...
f := 1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8+1/362880*x^9+1/3628800*x^10+1/39916800*x^11+1/479001600*x^12+1/6227020800*x^13+1/87178291200*x^14+1/1307674368000*x^15+1/209...

>    eval(f,x=2);

68576238333199/9280784638125

>    evalf(%);

7.389056099

>    evalf(exp(2));

7.389056099

Here I graph ln(x) and the 10th Taylor polynomial for ln(x) centered at 1 and approximate ln(1.2) using the 10th Taylor polynomial centered at 1.

>    Order:=11;

Order := 11

>    tln10:=taylor(ln(x),x=1);

tln10 := series(1*(x-1)-1/2*(x-1)^2+1/3*(x-1)^3-1/4*(x-1)^4+1/5*(x-1)^5-1/6*(x-1)^6+1/7*(x-1)^7-1/8*(x-1)^8+1/9*(x-1)^9-1/10*(x-1)^10+O((x-1)^11),x=-(-1),11)

>    pln10:=convert(tln10,polynom);

pln10 := x-1-1/2*(x-1)^2+1/3*(x-1)^3-1/4*(x-1)^4+1/5*(x-1)^5-1/6*(x-1)^6+1/7*(x-1)^7-1/8*(x-1)^8+1/9*(x-1)^9-1/10*(x-1)^10

>    lnGraph:=plot(ln(x),x=0..2,thickness=3,color=red,labels=[x,y]):

>    pln10Graph:=plot(pln10,x=0..2,thickness=3,color=blue,labels=[x,y]):

>    display(lnGraph,pln10Graph);

[Maple Plot]

>    fln10:=pln10;

fln10 := x-1-1/2*(x-1)^2+1/3*(x-1)^3-1/4*(x-1)^4+1/5*(x-1)^5-1/6*(x-1)^6+1/7*(x-1)^7-1/8*(x-1)^8+1/9*(x-1)^9-1/10*(x-1)^10

>    eval(fln10,x=1.2);

.1823215553

>    eval(ln(1.2));

.1823215568

>