Series Solution Example 12
Some Polynomial Approximations
Truncated series solutions are graphed in red (Order 9 and then Order 10), blue (Order 12), green (Order 14), magenta (Order 24), and black (Order 36).
> | ode:=diff(y(x),x,x)+x*y(x)=x*sin(x); |
> | Order:=9; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly:=convert(%,polynom); |
> | with(plots):SeriesSoln:=plot(poly,x=0..8,y=-40..40,color=red): |
> | display(SeriesSoln); |
> | Order:=10; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly1:=convert(%,polynom); |
> | with(plots):SeriesSoln1:=plot(poly1,x=0..5,y=-10..40,color=red): |
> | display(SeriesSoln1); |
> | Order:=12; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly2:=convert(%,polynom); |
> | SeriesSoln2:=plot(poly2,x=0..5,y=-10..40,color=blue): |
> | display(SeriesSoln1,SeriesSoln2); |
> | Order:=14; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly3:=convert(%,polynom); |
> | SeriesSoln3:=plot(poly3,x=0..5,y=-10..40,color=green): |
> | display(SeriesSoln1,SeriesSoln2,SeriesSoln3); |
> | Order:=24; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly4:=convert(%,polynom); |
> | SeriesSoln4:=plot(poly4,x=0..5,y=-10..40,color=magenta): |
> | display(SeriesSoln1,SeriesSoln2,SeriesSoln3,SeriesSoln4); |
> | Order:=36; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly5:=convert(%,polynom); |
> | SeriesSoln5:=plot(poly5,x=0..5,y=-10..40,color=black): |
> | display(SeriesSoln1,SeriesSoln2,SeriesSoln3,SeriesSoln4,SeriesSoln5); |
> |
> |