The Oscillating Pendulum
Linear and Non-Linear Models
Truncated series solutions to the non-linear model are graphed in blue (SeriesSoln). The analytical solution to the linear model is graphed in red (AnalSoln).
| > | ode:=diff(y(x),x,x)+sin(y(x))=0; |
| > | Order:=12; |
| > | dsolve({ode,y(0)=Pi/6,D(y)(0)=0},y(x),type=series); |
| > | rhs(%); |
| > | poly:=convert(%,polynom); |
| > | with(plots):AnalSoln:=plot((Pi/6)*cos(x),x=0..Pi,color=red): |
| > | SeriesSoln:=plot(poly,x=0..Pi,color=blue): |
| > | display(SeriesSoln,AnalSoln); |
| > | Order:=16; |
| > | dsolve({ode,y(0)=Pi/6,D(y)(0)=0},y(x),type=series); |
| > | rhs(%); |
| > | poly:=convert(%,polynom); |
| > | with(plots):AnalSoln:=plot((Pi/6)*cos(x),x=0..Pi,color=red): |
| > | SeriesSoln:=plot(poly,x=0..Pi,color=blue): |
| > | display(SeriesSoln,AnalSoln); |
| > | Order:=20; |
| > | dsolve({ode,y(0)=Pi/6,D(y)(0)=0},y(x),type=series); |
| > | rhs(%); |
| > | poly:=convert(%,polynom); |
| > | with(plots):AnalSoln:=plot((Pi/6)*cos(x),x=0..9*Pi/8,color=red): |
| > | SeriesSoln:=plot(poly,x=0..9*Pi/8,color=blue): |
| > | display(SeriesSoln,AnalSoln); |
| > | Order:=24; |
| > | dsolve({ode,y(0)=Pi/6,D(y)(0)=0},y(x),type=series); |
| > | rhs(%); |
| > | poly:=convert(%,polynom); |
| > | with(plots):AnalSoln:=plot((Pi/6)*cos(x),x=0..9*Pi/8,color=red): |
| > | SeriesSoln:=plot(poly,x=0..9*Pi/8,color=blue): |
| > | display(SeriesSoln,AnalSoln); |
| > | Order:=32; |
| > | dsolve({ode,y(0)=Pi/6,D(y)(0)=0},y(x),type=series); |
| > | rhs(%); |
| > | poly:=convert(%,polynom); |
| > | with(plots):AnalSoln:=plot((Pi/6)*cos(x),x=0..9*Pi/8,color=red): |
| > | SeriesSoln:=plot(poly,x=0..9*Pi/8,color=blue): |
| > | display(SeriesSoln,AnalSoln); |
| > |