Example 5.2.1

DSolve[y''[x]-y[x]==0,y[x],x]

Example 5.2.2

DSolve[y''[x]-x y'[x]-y[x]==0,y[x],x]

(∑_(n=0)^∞)((2n!(x^(2n+1)))/((2n+1)!))

Example 5.2.21

L[y_]:=D[y,{x,2}]-2x D[y,{x,1}]+λ y==0

DSolve[L[y[x]],y[x],x]

We see that one of our solutions should be a Hermite poynomial, and the other a Hypergeometric function. This may be your first encounter with the Hypergeoemtric functions and Hermite polynomials.

Check the pattern recognition software (my brain):

f[k_]:=a[2k+2]==(Subscript[c, 1])(1/((2k+2)!))(∏_(i=0)^k)(4i-λ)
Table[f[k],{k,0,4}]//TableForm

g[k_]:=a[2k+3]==(Subscript[c, 2])(1/((2k+3)!))(((∏_(i=1)^(2k+1))(2i-λ))/((∏_(i=1)^k)(4i-λ)))
Table[g[k],{k,0,4}]//TableForm

Here are the solutions we found. Notice that one is the solution Mathematica found!

y1[x_]:=1+(∑_(k=0)^∞)(1/((2k+2)!))(x^(2k+2))((∏_(i=0)^k)(4i-λ))
y2[x_]:=x+(∑_(k=0)^∞)(1/((2k+3)!))(x^(2k+3))(((∏_(i=1)^(2k+1))(2i-λ))/((∏_(i=1)^k)(4i-λ)))

y1[x]
y2[x]

The Hermite polynomials are found from these solutions, and so they are also solutions to the differential equation. They are found by assuming λ=2n, where n is a positive integer.

Notice how the Hermite polynomials leap back and forth between y1 and y2. Also notice that our series solution determines the Hermite polynomials up to an overall constant multiple.

y1[x_,m_]:=1+(∑_(k=0)^(m/2))(1/((2k+2)!))(x^(2k+2))((∏_(i=0)^k)(4i-2m))
y2[x_,m_]:=x+(∑_(k=0)^((m-1)/2))(1/((2k+3)!))(x^(2k+3))(((∏_(i=1)^(2k+1))(2i-2m))/((∏_(i=1)^k)(4i-2m)))

Here are the even Hermite polynomials, up to a mupliplicative constant:

Table[{m,HermiteH[m,x],y1[x,m]},{m,0,8,2}]//TableForm

Here are the odd Hermite polynomials, up to a mupliplicative constant:

Table[{m,HermiteH[m,x],y2[x,m]},{m,1,9,2}]//TableForm

Here is the general solution if λ=2m:

L[y_,m_]:=D[y,{x,2}]-2x D[y,{x,1}]+2m y==0

DSolve[L[y[x],m],y[x],x]

Here is the general solution if m=1:

DSolve[L[y[x],1],y[x],x];
Simplify[%]

Which agrees with the series solution we worked out, where I have made the following replacement to avoid a computational division by zero which wouldn't occur if you did this by hand:

(((∏_(i=1)^(2k+1))(2i-2m))/((∏_(i=1)^k)(4i-2m)))

y1[x_,m_]:=1+(∑_(k=0)^∞)(1/((2k+2)!))(x^(2k+2))((∏_(i=0)^k)(4i-2m))
y2[x_,m_]:=x+(∑_(k=0)^∞)(1/((2k+3)!))(x^(2k+3))((2 Pochhammer[1-m,1+2 k])/(Pochhammer[1-(m/2),k]))

Simplify[y1[x,1]]
Simplify[y2[x,1]]

Example 5.3.7

Solve[1-x^3==0,x]
NSolve[1-x^3==0,x]

Here, the red dot is the dot we are expanding the series solution about, and the blue dots are the complex poles of p and q. The radius of convergence is the length of the blue line.

dot1[x_,y_,k_]:=Graphics[{Hue[k],Disk[{x,y},0.05]}]
di[x1_,y1_,x2_,y2_]:=Graphics[{Hue[0.6],Line[{{x1,y1},{x2,y2}}]}]

Show[dot1[0,0,0.0],dot1[1/2,(Sqrt[3])/2,0.7],dot1[1/2,-(Sqrt[3])/2,0.7],di[0,0,1/2,Sqrt[3]/2],PlotRange->{{-2,2},{-2,2}},AspectRatio->1,Axes->True,AxesLabel->{"Re","Im"},ImageSize->{400,Automatic}]

Show[dot1[2,0,0.0],dot1[1/2,(Sqrt[3])/2,0.7],dot1[1/2,-(Sqrt[3])/2,0.7],di[2,0,1/2,Sqrt[3]/2],PlotRange->{{-2.2,2.2},{-2.2,2.2}},AspectRatio->1,Axes->True,AxesLabel->{"Re","Im"},ImageSize->{400,Automatic}]

Example 5.3.11

Here are the truncated series manipulations. We have to ensure we go out far enough to get correct terms in the coefficients we use--the last term will always be missing something.

k=12;
 (∑_(n=0)^k)(n+2)(n+1)a[n+2](x^n)+((∑_(n=0)^k)((((-1))^n)/((2n+1)!))(x^(2n+1)))((∑_(n=0)^k)a[n](x^n));
Expand[%];
Collect[%,x];
Series[%,{x,0,9}]

k=4;
 (∑_(n=0)^k)(n+2)(n+1)a[n+2](x^n)+((∑_(n=0)^k)((((-1))^n)/((2n+1)!))(x^(2n+1)))((∑_(n=0)^k)a[n](x^n));
Expand[%];
Collect[%,x];
Series[%,{x,0,9}]

Notice the (x^5)term in the above is missing something that we had when we went out to 12 terms. This is not surprising, since we have truncated some of the series at (x^4).

Here is Mathematica's solution

Clear[y]
L[y_]:=D[y,{x,2}]+Sin[x]y
L[y[x]]
DSolve[L[y[x]]==0,y[x],x]

Opps, it can't do it. Looks like our series solution is a pretty awesome technique!

Example 5.3.11 Revisited: Mathematica to do it all for you.

Check out the other Mathematica file for today if you want a more detailed eplanation of the following procedure. You should be able to parse what is happening at each step. This gets the entire solution by evaluating one Mathematica cell, which is great if you know what is going on, not so great if you don't understand the manipulations Mathematica is doing for you and don't feel confident that you could do them by hand. Change k and get more terms in the solution.

Clear[a,x,y,i]
k=13;
y = (∑_(n=0)^k)a[n](x^n);
ddy = D[D[y,x],x];
ss = Normal[Series[Sin[x],{x,0,k}]];

eq1 = ddy + ss y;
eq1 = Expand[eq1];
eq1 = Collect[eq1,x];
Do[ sol = Solve[Coefficient[eq1,x,i-2]==0,a[i]];
a[i] = a[i] /. First[sol], {i,2,k}]

Collect[y,{a[0],a[1]}]

Let's check if this is correct:

Clear[y]
L[y_]:=D[y,{x,2}]+Sin[x]y

L[1-((x^3)/6)+((x^5)/120)+((x^6)/180)-((x^7)/5040)-((13 (x^8))/20160)-((x^9)/13440)+((x^10)/30240)+((569 (x^11))/39916800)-((37 (x^12))/79833600)-((7457 (x^13))/6227020800)]

Series[%,{x,0,10}]

L[x-((x^4)/12)+((x^6)/180)+((x^7)/504)-((x^8)/6720)-((7 (x^9))/25920)-((x^10)/50400)+((107 (x^11))/6652800)+((31 (x^12))/6842880)-((41 (x^13))/94348800)]

Series[%,{x,0,10}]

Both of our series solutions satisfy the differential equation.