Series Solutions with Maple

We will find the first 10 terms of the series solution of y''(x) + xy'(x) + y(x) = 0 for y(2)=3 and y'(2)=1. The series will be centered about 2.

First we load a package of commands called DEtools. Then we set the Order parameter to 10.

> with(DEtools):

> Order:=10:

Then we use dsolve and just add the option series at the end.

> dsolve({diff(y(x),x$2)+x*diff(y(x),x)+y(x)=0,y(2)=3,D(y)(2)=1},y(x),series);

y(x) = (series(3+(x-2)-5/2*(x-2)^2+4/3*(x-2)^3-1/24*(x-2)^4-1/4*(x-2)^5+13/144*(x-2)^6+5/504*(x-2)^7-37/2688*(x-2)^8+71/36288*(x-2)^9+O((x-2)^10),x = 2,10))

It is worth noting what this did not tell us. We do not get a formula for the terms and since Maple simplifies the fractions it is harder to see if there is an obvious pattern. It also tells us nothing about the radius of convergence. By a theorem  in the textbook it is infinite.

Next we plot the series solution out to 10 terms and compare this with a numerical solution.

> plot(3+x-2-5/2*(x-2)^2+4/3*(x-2)^3-1/24*(x-2)^4-1/4*(x-2)^5+13/144*(x-2)^6+5/504*(x-2)^7-37/2688*(x-2)^8+71/36288*(x-2)^9,x=0..4,color=black,thickness=3);

[Plot]

We can compare this with a plot of the numerical solution.

> DEplot({diff(y(x),x$2)+x*diff(y(x),x)+y(x)=0},{y(x)},x=0..4,[[y(2)=3,D(y)(2)=1]],linecolor=black);

[Plot]

Here is how to overlay the two graphs.

> with(plots):

> SeriesSolution := plot(3+x-2-5/2*(x-2)^2+4/3*(x-2)^3-1/24*(x-2)^4-1/4*(x-2)^5+13/144*(x-2)^6+5/504*(x-2)^7-37/2688*(x-2)^8+71/36288*(x-2)^9,x=0..4,color=blue,thickness=3):

> NumericalSolution := DEplot({diff(y(x),x$2)+x*diff(y(x),x)+y(x)=0},{y(x)},x=0..4,[[y(2)=3,D(y)(2)=1]],linecolor=red):

> display(SeriesSolution,NumericalSolution);

[Plot]

The fit is not bad.

What happens if x goes from -2 to 6 instead of 0 to 4?

> plot(3+x-2-5/2*(x-2)^2+4/3*(x-2)^3-1/24*(x-2)^4-1/4*(x-2)^5+13/144*(x-2)^6+5/504*(x-2)^7-37/2688*(x-2)^8+71/36288*(x-2)^9,x=-2..6,color=black,thickness=3);

[Plot]

> DEplot({diff(y(x),x$2)+x*diff(y(x),x)+y(x)=0},{y(x)},x=-2..6,[[y(2)=3,D(y)(2)=1]],linecolor=black);

[Plot]

Not even in the same ballpark.