2.1043   ODE No. 1043

  1. Problem in Latex
  2. Mathematica input
  3. Maple input

\[ y''(x)-x y'(x)+2 y(x)=0 \] Mathematica : cpu = 0.0475565 (sec), leaf count = 55

\[\left \{\left \{y(x)\to c_1 \left (x^2-1\right )-\frac {1}{4} c_2 \left (2 e^{\frac {x^2}{2}} x-\sqrt {2 \pi } \left (x^2-1\right ) \text {erfi}\left (\frac {x}{\sqrt {2}}\right )\right )\right \}\right \}\]

Maple : cpu = 0.211 (sec), leaf count = 39

\[ \left \{ y \left ( x \right ) =-2\,{{\rm e}^{1/2\,{x}^{2}}}{\it \_C1}\,x+ \left ( x-1 \right ) \left ( 1+x \right ) \left ( \sqrt {\pi }\sqrt {2}{\it erfi} \left ( {\frac {\sqrt {2}x}{2}} \right ) {\it \_C1}+{\it \_C2} \right ) \right \} \]

Hand solution

\begin {equation} y^{\prime \prime }-xy^{\prime }+2y=0\tag {1} \end {equation}

Second order with varying coefficient. Using power series, let \(y=\sum _{n=0}^{\infty }c_{n}x^{n}\), hence\begin {align*} y^{\prime } & =\sum _{n=0}^{\infty }nc_{n}x^{n-1}=\sum _{n=1}^{\infty }nc_{n}x^{n-1}=\sum _{n=0}^{\infty }\left ( n+1\right ) c_{n+1}x^{n}\\ y^{\prime \prime } & =\sum _{n=0}^{\infty }n\left ( n+1\right ) c_{n+1}x^{n-1}=\sum _{n=1}^{\infty }n\left ( n+1\right ) c_{n+1}x^{n-1}=\sum _{n=0}^{\infty }\left ( n+1\right ) \left ( n+2\right ) c_{n+2}x^{n} \end {align*}

Substituting back in the original ODE gives\begin {align*} \sum _{n=0}^{\infty }\left ( n+1\right ) \left ( n+2\right ) c_{n+2}x^{n}-x\sum _{n=0}^{\infty }\left ( n+1\right ) c_{n+1}x^{n}+2\sum _{n=0}^{\infty }c_{n}x^{n} & =0\\ \sum _{n=0}^{\infty }\left ( n+1\right ) \left ( n+2\right ) c_{n+2}x^{n}-\sum _{n=0}^{\infty }\left ( n+1\right ) c_{n+1}x^{n+1}+\sum _{n=0}^{\infty }2c_{n}x^{n} & =0\\ \sum _{n=0}^{\infty }\left ( n+1\right ) \left ( n+2\right ) c_{n+2}x^{n}-\sum _{n=1}^{\infty }nc_{n}x^{n}+\sum _{n=0}^{\infty }2c_{n}x^{n} & =0 \end {align*}

For \(n=0\)\begin {align*} \left ( n+1\right ) \left ( n+2\right ) c_{n+2}+2c_{n} & =0\\ \left ( 1\right ) \left ( 2\right ) c_{2}+2c_{0} & =0\\ c_{2} & =-c_{0} \end {align*}

For \(n\geq 1\)\begin {align*} \left ( n+1\right ) \left ( n+2\right ) c_{n+2}-nc_{n}+2c_{n} & =0\\ c_{n+2} & =\frac {c_{n}\left ( n-2\right ) }{\left ( n+1\right ) \left ( n+2\right ) } \end {align*}

Hence for \(n=1\)\[ c_{3}=\frac {-c_{1}}{\left ( 2\right ) \left ( 3\right ) }\] For \(n=2\)\[ c_{4}=\frac {c_{2}\left ( 2-2\right ) }{\left ( 3\right ) \left ( 4\right ) }=0 \] For \(n=3\)\[ c_{5}=\frac {c_{3}}{\left ( 4\right ) \left ( 5\right ) }=\frac {-c_{1}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) }\] For \(n=4\) and since \(c_{4}=0\) then\[ c_{6}=\frac {c_{4}\left ( n-2\right ) }{\left ( n+1\right ) \left ( n+2\right ) }=0 \] For \(n=5\)\[ c_{7}=\frac {3c_{5}}{\left ( 6\right ) \left ( 7\right ) }=-\frac {3c_{1}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) \left ( 6\right ) \left ( 7\right ) }\] For \(n=6\) and since \(c_{6}=0\) then\[ c_{8}=\frac {c_{6}\left ( n-2\right ) }{\left ( n+1\right ) \left ( n+2\right ) }=0 \] For \(n=7\)\[ c_{9}=\frac {5c_{7}}{\left ( 8\right ) \left ( 9\right ) }=-\frac {\left ( 3\right ) \left ( 5\right ) c_{1}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) \left ( 6\right ) \left ( 7\right ) \left ( 8\right ) \left ( 9\right ) }\] And so on. Hence\begin {align*} y & =\sum _{n=0}^{\infty }c_{n}x^{n}\\ & =c_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+\cdots \\ & =c_{0}+c_{1}x-c_{0}x^{2}-\frac {c_{1}}{\left ( 2\right ) \left ( 3\right ) }x^{3}-\frac {c_{1}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) }x^{5}-\frac {3c_{1}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) \left ( 6\right ) \left ( 7\right ) }x^{7}-\frac {\left ( 3\right ) \left ( 5\right ) c_{1}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) \left ( 6\right ) \left ( 7\right ) \left ( 8\right ) \left ( 9\right ) }x^{9}-\cdots \\ & =c_{0}\left ( 1-x^{2}\right ) +c_{1}\left ( x-\frac {1}{\left ( 2\right ) \left ( 3\right ) }x^{3}-\frac {1}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) }x^{5}-\frac {3}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) \left ( 6\right ) \left ( 7\right ) }x^{7}-\frac {\left ( 3\right ) \left ( 5\right ) }{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) \left ( 6\right ) \left ( 7\right ) \left ( 8\right ) \left ( 9\right ) }x^{9}\right ) \\ & =c_{0}\left ( 1-x^{2}\right ) +c_{1}\left ( x-\frac {1}{3!}x^{3}-\frac {1}{5!}x^{5}-\frac {3}{7!}x^{7}-\frac {15}{9!}x^{9}-\cdots \right ) \end {align*}

Hence\[ y\left ( x\right ) =c_{0}\left ( 1-x^{2}\right ) +c_{1}\left ( x-\frac {1}{6}x^{3}-\frac {1}{120}x^{5}-\frac {1}{1680}x^{7}-\frac {1}{24\,192}x^{9}-\cdots \right ) \]

Verification

restart; 
Order:=10: 
sol:=dsolve(ode,y(x),series): 
subs({y(0)=c0,D(y)(0)=c1},rhs(sol)): 
sol:=convert(%,polynom): 
 
sol:=collect(sol,{c0,c1}); 
sol := (-x^2+1)*c0+(x-(1/6)*x^3-(1/120)*x^5-(1/1680)*x^7-(1/24192)*x^9)*c1