A Nonlinear Second Order Equation
Non-Linear Model with a Series Solution
Truncated series solutions to the non-linear model are graphed in blue (SeriesSoln) and green. The analytical solution is graphed in red (AnalSoln).
The analytical solution satisfying y(0) = 0 and y'(0) = 1 is y = sin(x).
We can observe that the series solution is accurate close to 0 (where the series is centered) and as more terms are added to the series solution the interval over which it is accurate becomes larger.
> | ode:=diff(y(x),x,x)+2*x*diff(y(x),x)+sin(y(x))=-sin(x)+2*x*cos(x)+sin(sin(x)); |
> | Order:=12; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly:=convert(%,polynom); |
> | with(plots):AnalSoln:=plot(sin(x),x=0..2*Pi,color=red): |
Warning, the name changecoords has been redefined
> | SeriesSoln:=plot(poly,x=0..2*Pi,color=blue): |
> | display(SeriesSoln,AnalSoln); |
> | Order:=16; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly2:=convert(%,polynom); |
> | SeriesSoln2:=plot(poly2,x=0..2*Pi,color=green): |
> | display(SeriesSoln,SeriesSoln2,AnalSoln); |
> | Order:=20; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly3:=convert(%,polynom); |
> | with(plots):AnalSoln:=plot(sin(x),x=0..3*Pi,color=red): |
> | SeriesSoln3:=plot(poly3,x=0..3*Pi,color=blue): |
> | display(SeriesSoln3,AnalSoln); |
> | Order:=24; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly4:=convert(%,polynom); |
> | with(plots):AnalSoln:=plot(sin(x),x=0..3.4*Pi,color=red): |
> | SeriesSoln4:=plot(poly4,x=0..3.4*Pi,color=blue): |
> | display(SeriesSoln4,AnalSoln); |
> | Order:=28; |
> | dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series); |
> | rhs(%); |
> | poly5:=convert(%,polynom); |
> | with(plots):AnalSoln:=plot(sin(x),x=0..3.6*Pi,color=red): |
> | SeriesSoln5:=plot(poly5,x=0..3.6*Pi,color=blue): |
> | display(SeriesSoln5,AnalSoln); |
> |