Series Solution Example
Some Polynomial Approximations
Truncated series solutions are graphed in red (Order 7) and then maroon (Order 10), blue (Order 12), green (Order 14), magenta (Order 24), brown (Order 36), orange (Order 60)
and black (Order 86).
> | ode:=diff(y(x),x,x)+x*diff(y(x),x)-2*y(x)=sin(x); |
> | Order:=7; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly:=convert(%,polynom); |
> | eval(poly,x=2.0); |
> | with(plots):SeriesSoln:=plot(poly,x=0..7,y=-60..60,color=red,thickness=2): |
> | display(SeriesSoln); |
> | Order:=10; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly1:=convert(%,polynom); |
> | eval(poly1,x=2.0); |
> | with(plots):SeriesSoln1:=plot(poly1,x=0..7,y=-60..20,color=maroon,thickness=2): |
> | display(SeriesSoln1); |
> | Order:=12; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly2:=convert(%,polynom); |
> | eval(poly2,x=2.0); |
> | SeriesSoln2:=plot(poly2,x=0..7,y=-60..60,color=blue,thickness=2): |
> | display(SeriesSoln1,SeriesSoln2); |
> | Order:=14; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly3:=convert(%,polynom); |
> | eval(poly3,x=2.0); |
> | SeriesSoln3:=plot(poly3,x=0..7,y=-60..60,color=green,thickness=2): |
> | display(SeriesSoln1,SeriesSoln2,SeriesSoln3); |
> | Order:=24; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly4:=convert(%,polynom); |
> | eval(poly4,x=2.0); |
> | SeriesSoln4:=plot(poly4,x=0..7,y=-60..60,color=magenta,thickness=2): |
> | display(SeriesSoln1,SeriesSoln2,SeriesSoln3,SeriesSoln4); |
> | Order:=36; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly5:=convert(%,polynom); |
> | eval(poly5,x=2.0); |
> | SeriesSoln5:=plot(poly5,x=0..7,y=-60..60,color=brown,thickness=2,numpoints=200): |
> | display(SeriesSoln1,SeriesSoln2,SeriesSoln3,SeriesSoln4,SeriesSoln5); |
> | Order:=60; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly6:=convert(%,polynom); |
> | eval(poly6,x=2.0); |
> | SeriesSoln6:=plot(poly6,x=0..7,y=-60..60,color=orange,thickness=2,numpoints=200): |
> | Order:=86; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly7:=convert(%,polynom); |
> | eval(poly7,x=2.0); |
> | SeriesSoln7:=plot(poly7,x=0..7,y=-60..60,color=black,thickness=2,numpoints=200): |
> | display(SeriesSoln,SeriesSoln1,SeriesSoln2,SeriesSoln3,SeriesSoln4,SeriesSoln5,SeriesSoln6,SeriesSoln7); |
> | display(SeriesSoln,SeriesSoln1,SeriesSoln2,SeriesSoln3,SeriesSoln4,SeriesSoln5,SeriesSoln6,SeriesSoln7); |
> |