MaplePowerSeriesGraphs.mws

Power Series Plots

Graphs Using Truncated Series Approximations

Here are some examples of graphs of functions defined by power series using finite series to approximate.

>    with(plots):

Warning, the name changecoords has been redefined

>    Sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30);

Sum((-1)^n*x^(2*n+1)/(2*n+1)!,n = 0 .. 30)

>    plot(sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3);

[Maple Plot]

>    Sum(((-1)^n)*(x^(2*n+1))/(2*n+2)!,n=0..30);

Sum((-1)^n*x^(2*n+1)/(2*n+2)!,n = 0 .. 30)

>    plot(sum(((-1)^n)*(x^(2*n+1))/(2*n+2)!,n=0..30),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3);

[Maple Plot]

>    Sum(((-1)^n)*(x^(2*n))/(2*n+1)!,n=0..30);

Sum((-1)^n*x^(2*n)/(2*n+1)!,n = 0 .. 30)

>    plot(sum(((-1)^n)*(x^(2*n))/(2*n+1)!,n=0..30),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3);

[Maple Plot]

Below I recreate the first example above and compare it to sin(x).  We cannot visually distinguish between them.

>    SineSeries:=plot(sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3):

>    SineGraph:=plot(sin(x),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3,color=blue):

>    display(SineSeries,SineGraph);

[Maple Plot]

It takes a much wider window to see any difference between the two graphs.

>    SineSeries2:=plot(sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30),x=-9*Pi..9*Pi,y=-2..2,thickness=3,numpoints=2500):

>    SineGraph2:=plot(sin(x),x=-9*Pi..9*Pi,y=-2..2,thickness=3,color=blue):

>    display(SineSeries2,SineGraph2);

[Maple Plot]

If we add more terms to the sine series we are again not able to visually distinguish between the two graphs over the interval pictured.

>    SineSeries3:=plot(sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..40),x=-9*Pi..9*Pi,y=-2..2,thickness=3,numpoints=2500):

>    SineGraph3:=plot(sin(x),x=-9*Pi..9*Pi,y=-2..2,thickness=3,color=blue):

>    display(SineSeries3,SineGraph3);

[Maple Plot]

This time I will give a function a name and compute some values.

>    Sine30:=sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30):

>    eval(Sine30,x=1);

427114022440271088273498897681626111408221875211526674151381353374166538712098749021/507580213877224798800856812176625227226004528988036003099405939480985600000000000000

>    evalf(%);

.8414709848

>    sin(1.0);

.8414709848

>    eval(Sine30,x=20);

1053638468019581040537165368426187959020109808620701922780/1154103788115264248519581115434960400366445649042443626739

>    evalf(%);

.9129494928

>    sin(20.0);

.9129452507

Here is another way we could give a name to our function defined by a series and use it.

>    Sine30b:=x->sum(((-1)^n)*(x^(2*n+1))/(2*n+1)!,n=0..30);

Sine30b := x -> sum((-1)^n*x^(2*n+1)/(2*n+1)!,n = 0 .. 30)

>    Sine30b(10.0);

-.5440211109

>    sin(10.0);

-.5440211109

>    plot(Sine30b(x),x=-2*Pi..2*Pi,y=-1.2..1.2,thickness=3);

[Maple Plot]

Here is another function defined by a power series again approximated using only the first 31 terms.

>    WhatIsIt:=x->sum(((-1)^n)*(n^2)*(x^n)/(2*n)!,n=0..30);

WhatIsIt := x -> sum((-1)^n*n^2*x^n/(2*n)!,n = 0 .. 30)

>    WhatIsIt(2.0);

-.4271998467

>    WhatIsIt2:=x->sum(((-1)^n)*(n^2)*(x^n)/(2*n)!,n=0..50);

WhatIsIt2 := x -> sum((-1)^n*n^2*x^n/(2*n)!,n = 0 .. 50)

>    WhatIsIt2(2.0);

-.4271998467

It looks like WhatIsIt is a pretty accurate approximation to the corresponding infinite series at x = 2.

>    (31^2)*(20.0^31)/(2*31)!;

.6557780551e-42

We can tell that WhatIsIt is an accurate representation of the corresponding infinite series over the interval [0,20] since the number above is so close to zero.  Thus we can graph WhatIsIt over the interval [0,20] and consider the graph an accurate representation of the function defined by the corresponging infinite series.

>    plot(WhatIsIt(x),x=0..20,y=-1..4,thickness=3);

[Maple Plot]

In the graphs below we might be less confident about the accuracy of WhatIsIt in approximating an infinite series over the portion of the interval where x is negative.  The graphs probably are accurate based on the computations below them but why might we be less confident?

>    plot(WhatIsIt(x),x=-10..10,y=-10..50,thickness=3);

[Maple Plot]

>    plot(WhatIsIt(x),x=-20..20,y=-10..300,thickness=3);

[Maple Plot]

>    WhatIsIt(-20.0);

267.8192640

>    WhatIsIt2(-20.0);

267.8192640

Here is an approximation to a function defined by a power series that has a finite interval of convergence.

>    FiniteInterval:=x->sum(((-1)^n)*((x/2)^n)/(2*n),n=1..30);

FiniteInterval := x -> sum(1/2*(-1)^n*(1/2*x)^n/n,n = 1 .. 30)

The corresponding infinite series would converge over the interval (-2,2].  The convergence would be very slow close to -2 and 2.

>    FiniteInterval2:=x->sum(((-1)^n)*((x/2)^n)/(2*n),n=1..50);

FiniteInterval2 := x -> sum(1/2*(-1)^n*(1/2*x)^n/n,n = 1 .. 50)

>    FiniteInterval(0.5);

-.1115717757

>    FiniteInterval2(0.5);

-.1115717757

>    FiniteInterval(1.0);

-.2027325540

>    FiniteInterval2(1.0);

-.2027325541

>    FiniteInterval(1.5);

-.2798066426

>    FiniteInterval2(1.5);

-.2798078916

>    FiniteInterval(1.9);

-.3322016424

>    FiniteInterval2(1.9);

-.3335436681

>    FiniteInterval(1.99);

-.3382895474

>    FiniteInterval2(1.99);

-.3414791213

>    FiniteInterval(-1.99);

1.925129829

>    FiniteInterval2(-1.99);

2.131867936

The accuracy in approximating the corresponding infinite series becomes more questionable close to the ends of the interval of convergence.  Why does it appear to be more inaccurate at the negative end?

>    FIplot:=plot(FiniteInterval(x),x=-2..2,y=-3..3,thickness=3):

>    FI2plot:=plot(FiniteInterval2(x),x=-2..2,y=-3..3,thickness=3,color=blue):

>    display(FIplot,FI2plot);

>   

[Maple Plot]

>    FIplotb:=plot(FiniteInterval(x),x=-3..3,y=-10..10,thickness=3,numpoints=2500):

>    FI2plotb:=plot(FiniteInterval2(x),x=-3..3,y=-10..10,thickness=3,color=blue,numpoints=2500):

>    display(FIplotb,FI2plotb);

[Maple Plot]

>    FIplotb:=plot(FiniteInterval(x),x=-3..3,y=-1000..1000,thickness=3,numpoints=2500):

>    FI2plotb:=plot(FiniteInterval2(x),x=-3..3,y=-1000..1000,thickness=3,color=blue,numpoints=2500):

>    display(FIplotb,FI2plotb);

[Maple Plot]

Since the corresponding infinite series diverges outside the interval (-2,2] the graphs of the finite series above are useless as approximations of the infinite series outside this interval.