MapleDEseriesNonLin.mws

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).

diff(y(x),`$`(x,2))+2*x*diff(y(x),x)+sin(y(x)) = -sin(x)+2*x*cos(x)+sin(sin(x))

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));

ode := diff(y(x),`$`(x,2))+2*x*diff(y(x),x)+sin(y(x)) = -sin(x)+2*x*cos(x)+sin(sin(x))

>    Order:=12;

Order := 12

>    dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series);

y(x) = series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+O(x^12),x,12)

>    rhs(%);

series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+O(x^12),x,12)

>    poly:=convert(%,polynom);

poly := x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11

>    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);

[Maple Plot]

>    Order:=16;

Order := 16

>    dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series);

y(x) = series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+O(x^16),x,16)

>    rhs(%);

series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+O(x^16),x,16)

>    poly2:=convert(%,polynom);

poly2 := x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15

>    SeriesSoln2:=plot(poly2,x=0..2*Pi,color=green):

>    display(SeriesSoln,SeriesSoln2,AnalSoln);

[Maple Plot]

>    Order:=20;

Order := 20

>    dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series);

y(x) = series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+O(x^20),x,20)
y(x) = series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+O(x^20),x,20)

>    rhs(%);

series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+O(x^20),x,20)
series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+O(x^20),x,20)

>    poly3:=convert(%,polynom);

poly3 := x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19
poly3 := x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19

>    with(plots):AnalSoln:=plot(sin(x),x=0..3*Pi,color=red):

>    SeriesSoln3:=plot(poly3,x=0..3*Pi,color=blue):

>    display(SeriesSoln3,AnalSoln);

[Maple Plot]

>    Order:=24;

Order := 24

>    dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series);

y(x) = series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/2585201...
y(x) = series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/2585201...

>    rhs(%);

series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/25852016738884...
series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/25852016738884...

>    poly4:=convert(%,polynom);

poly4 := x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/25852016738884...
poly4 := x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/25852016738884...

>    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);

[Maple Plot]

>    Order:=28;

Order := 28

>    dsolve({ode,y(0)=0,D(y)(0)=1},y(x),type=series);

y(x) = series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/2585201...
y(x) = series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/2585201...
y(x) = series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/2585201...

>    rhs(%);

series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/25852016738884...
series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/25852016738884...
series(1*x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/25852016738884...

>    poly5:=convert(%,polynom);

poly5 := x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/25852016738884...
poly5 := x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/25852016738884...
poly5 := x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9-1/39916800*x^11+1/6227020800*x^13-1/1307674368000*x^15+1/355687428096000*x^17-1/121645100408832000*x^19+1/51090942171709440000*x^21-1/25852016738884...

>    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);

[Maple Plot]

>