2.1100   ODE No. 1100

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

\[ x y''(x)+2 y'(x)-x y(x)-e^x=0 \] Mathematica : cpu = 0.032129 (sec), leaf count = 37

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

Maple : cpu = 0.041 (sec), leaf count = 23

\[ \left \{ y \left ( x \right ) ={\frac {\sinh \left ( x \right ) {\it \_C2}}{x}}+{\frac {\cosh \left ( x \right ) {\it \_C1}}{x}}+{\frac {{{\rm e}^{x}}}{2}} \right \} \]

Hand solution

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

First method, much shorter, using transformation. Let \(y_{h}=\frac {u\left ( x\right ) }{x}\), hence (now we are solving only the homogeneous part).

\begin {align*} y^{\prime } & =\frac {u^{\prime }}{x}-\frac {u}{x^{2}}\\ y^{\prime \prime } & =\frac {u^{\prime \prime }}{x}-\frac {u^{\prime }}{x^{2}}-\frac {u^{\prime }}{x^{2}}+2\frac {u}{x^{3}} \end {align*}

And (1) becomes

\begin {align*} x\left ( \frac {u^{\prime \prime }}{x}-\frac {u^{\prime }}{x^{2}}-\frac {u^{\prime }}{x^{2}}+2\frac {u}{x^{3}}\right ) +2\left ( \frac {u^{\prime }}{x}-\frac {u}{x^{2}}\right ) -x\left ( \frac {u}{x}\right ) & =0\\ u^{\prime \prime }-2\frac {u^{\prime }}{x}+2\frac {u}{x^{2}}+\frac {2u^{\prime }}{x}-\frac {2u}{x^{2}}-u & =0\\ u^{\prime \prime }-u & =0 \end {align*}

Hence the roots of the characteristic equation are \(\pm 1\) and the solution is

\[ u=Ae^{x}+Be^{-x}\]

Hence

\[ y_{h}=\frac {1}{x}\left ( Ae^{x}+Be^{-x}\right ) \]

The particular solution is found below, and given in the second method.  The transformation method is much simpler.

The second method, which is much longer, using series method. This is used if a transformation is not known or can not be found. There is singularity at \(x=0\). We need to check if the singularity is regular or not. Writing in standard form \(y^{\prime \prime }+p\left ( x\right ) y^{\prime }+q\left ( x\right ) y=0\) gives (we are looking at the homogeneous part now only)\[ y^{\prime \prime }+\frac {2}{x}y^{\prime }-y=0 \]

Hence \(\lim _{x\rightarrow 0}xp\left ( x\right ) =\lim _{x\rightarrow 0}x\frac {2}{x}=2\) which is analytic at \(x=0\). And \(\lim _{x\rightarrow 0}x^{2}q\left ( x\right ) =\lim _{x\rightarrow 0}-x^{2}=0\) which is analytic. Hence the singularity is regular (removable). Using Frobenius series, assume that \[ y=\sum _{n=-\infty }^{\infty }c_{n}x^{n+r}\] Where \(c_{n}=0\) for \(n<0\). Hence\begin {align*} y^{\prime } & =\sum \left ( n+r\right ) c_{n}x^{n+r-1}\\ y^{\prime \prime } & =\sum \left ( n+r\right ) \left ( n+r-1\right ) c_{n}x^{n+r-2} \end {align*}

Substituting back in the original ODE gives\[ \sum \left ( n+r\right ) \left ( n+r-1\right ) c_{n}x^{n+r-1}+\sum 2\left ( n+r\right ) c_{n}x^{n+r-1}-\sum c_{n}x^{n+r+1}=0 \] Adjusting so that all have same power \(x^{n+r}\) gives\[ \sum \left ( n+r+1\right ) \left ( n+r\right ) c_{n+1}x^{n+r}+\sum 2\left ( n+r+1\right ) c_{n+1}x^{n+r}-\sum c_{n-1}x^{n+r}=0 \] Hence\begin {align} \left ( n+r+1\right ) \left ( n+r\right ) c_{n+1}+2\left ( n+r+1\right ) c_{n+1}-c_{n-1} & =0\nonumber \\ \left ( n+r+1\right ) \left ( 2+\left ( n+r\right ) \right ) c_{n+1}-c_{n-1} & =0 \tag {2} \end {align}

We want equation with \(c_{0}\) in it. Hence let \(n=-1\)\[ \left ( -1+r+1\right ) \left ( 2+\left ( -1+r\right ) \right ) c_{0}-c_{-2}=0 \] But \(c_{n}=0\) for all \(n<0\) hence\[ \left ( -1+r+1\right ) \left ( 2+\left ( -1+r\right ) \right ) c_{0}=0 \] But \(c_{0}\neq 0\), as this is the basis for this method. Therefore, we obtain the indicial equation for \(r\)\begin {align*} \left ( -1+r+1\right ) \left ( 2+\left ( -1+r\right ) \right ) & =0\\ r\left ( r+1\right ) & =0 \end {align*}

Hence \(r=0\) or \(r=-1\) are the roots. Now for each \(r\) we find a solution. Using \(r=0\), we go back the recurrence equation (2)\begin {align*} \left ( n+1\right ) \left ( 2+n\right ) c_{n+1}-c_{n-1} & =0\\ c_{n+1} & =\frac {c_{n-1}}{\left ( n+1\right ) \left ( 2+n\right ) } \end {align*}

For \(n=0\)\[ c_{1}=\frac {c_{-1}}{\left ( n+1\right ) \left ( 2+n\right ) }=0 \] For \(n=1\)\[ c_{2}=\frac {c_{0}}{\left ( 2\right ) \left ( 3\right ) }\] For \(n=2\)\[ c_{3}=\frac {c_{1}}{\left ( n+1\right ) \left ( 2+n\right ) }=0 \] For \(n=3\)\[ c_{4}=\frac {c_{2}}{\left ( 4\right ) \left ( 5\right ) }=\frac {c_{0}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) }\] And so on. Hence, for \(r=0\) we have\begin {align} y_{r=0} & =\sum _{n=0}^{\infty }c_{n}x^{n}=c_{0}+c_{1}x^{1}+c_{2}x^{2}+c_{3}x^{3}+\cdots \nonumber \\ & =c_{0}+\frac {c_{0}}{6}x^{2}+\frac {c_{0}}{120}x^{4}+\cdots \nonumber \\ & =A\left ( 1+\frac {1}{6}x^{2}+\frac {1}{120}x^{4}+\cdots \right ) \tag {3} \end {align}

Where \(A\) is used as arbitrary constant instead of \(a_{0}\). Now we find the solution for \(r=-1.\) we go back the recurrence equation (2)\begin {align*} \left ( n-1+1\right ) \left ( 2+\left ( n-1\right ) \right ) c_{n+1}-c_{n-1} & =0\\ n\left ( 1+n\right ) c_{n+1}-c_{n-1} & =0\\ c_{n+1} & =\frac {c_{n-1}}{n\left ( 1+n\right ) } \end {align*}

For \(n=0\)\[ c_{1}=\frac {c_{-1}}{n\left ( 1+n\right ) }=0 \] For \(n=1\)\[ c_{2}=\frac {c_{0}}{2}\] For \(n=2\)\[ c_{3}=\frac {c_{1}}{n\left ( 1+n\right ) }=0 \] For \(n=3\)\[ c_{4}=\frac {c_{2}}{\left ( 3\right ) \left ( 4\right ) }=\frac {c_{0}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) }\] For \(n=4\)\[ c_{5}=\frac {c_{3}}{n\left ( 1+n\right ) }=0 \] For \(n=5\)\[ c_{6}=\frac {c_{4}}{\left ( 5\right ) \left ( 6\right ) }=\frac {c_{0}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) \left ( 6\right ) }\] And so on. Hence solution is\begin {align*} y_{r=-1} & =\frac {1}{x}\sum _{n=0}^{\infty }c_{n}x^{n}=\frac {1}{x}\left ( c_{0}+\frac {c_{0}}{2}x^{2}+\frac {c_{0}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) }x^{4}+\frac {c_{0}}{\left ( 2\right ) \left ( 3\right ) \left ( 4\right ) \left ( 5\right ) \left ( 6\right ) }x^{6}+\cdots \right ) \\ & =\frac {B}{x}\left ( 1+\frac {1}{2}x^{2}+\frac {1}{24}x^{4}+\frac {1}{720}x^{6}+\cdots \right ) \end {align*}

Where \(B\) is used as arbitrary constant instead of \(a_{0}\). Therefore, the homogeneous solution found is\begin {align*} y_{h} & =y_{r=0}+y_{r=-1}\\ & =A\left ( 1+\frac {1}{6}x^{2}+\frac {1}{120}x^{4}+\cdots \right ) +\frac {B}{x}\left ( 1+\frac {1}{2}x^{2}+\frac {1}{24}x^{4}+\frac {1}{720}x^{6}+\cdots \right ) \end {align*}

But \begin {equation} e^{x}=1+x+\frac {1}{2}x^{2}+\frac {1}{6}x^{3}+\frac {1}{24}x^{4}+\frac {1}{120}x^{5}+\cdots \tag {3} \end {equation} And \begin {equation} e^{-x}=1-x+\frac {1}{2}x^{2}-\frac {1}{6}x^{3}+\frac {1}{24}x^{4}-\frac {1}{120}x^{5}+\cdots \tag {4} \end {equation} Hence adding (3)+(4) gives\begin {align*} e^{x}+e^{-x} & =2+2\frac {1}{2}x^{2}+2\frac {1}{24}x^{4}+\cdots \\ & =2\left ( 1+\frac {1}{2}x^{2}+\frac {1}{24}x^{4}+\frac {1}{720}x^{6}\cdots \right ) \end {align*}

But \(y_{r=-1}=\frac {B}{x}\left ( 1+\frac {1}{2}x^{2}+\frac {1}{24}x^{4}+\frac {1}{720}x^{6}+\cdots \right ) \), therefore comparing the result we found above, we see that we can write \(y_{r=-1}\) as\[ y_{r=-1}=\frac {B}{x}\left ( \frac {e^{x}+e^{-x}}{2}\right ) \] Similarly, we obtain \(y_{r=0}\) expression\begin {align} \frac {1}{x}e^{x} & =\frac {1}{x}\left ( 1+x+\frac {1}{2}x^{2}+\frac {1}{6}x^{3}+\frac {1}{24}x^{4}+\frac {1}{120}x^{5}+\cdots \right ) \nonumber \\ & =\frac {1}{x}+1+\frac {1}{2}x+\frac {1}{6}x^{2}+\frac {1}{24}x^{3}+\frac {1}{120}x^{4}+\cdots \tag {3A} \end {align}

And\begin {align} \frac {1}{x}e^{-x} & =\frac {1}{x}\left ( 1-x+\frac {1}{2}x^{2}-\frac {1}{6}x^{3}+\frac {1}{24}x^{4}-\frac {1}{120}x^{5}+\cdots \right ) \nonumber \\ & =\frac {1}{x}-1+\frac {1}{2}x-\frac {1}{6}x^{2}+\frac {1}{24}x^{3}-\frac {1}{120}x^{4}+\cdots \tag {4A} \end {align}

Now (3A)-(4A) gives\begin {align*} \frac {1}{x}e^{x}-\frac {1}{x}e^{-x} & =\left ( \frac {1}{x}+1+\frac {1}{2}x+\frac {1}{6}x^{2}+\frac {1}{24}x^{3}+\frac {1}{120}x^{4}+\cdots \right ) -\left ( \frac {1}{x}-1+\frac {1}{2}x-\frac {1}{6}x^{2}+\frac {1}{24}x^{3}-\frac {1}{120}x^{4}+\cdots \right ) \\ & =2+2\frac {1}{6}x^{2}+2\frac {1}{120}x^{4}+\cdots \\ & =2\left ( 1+\frac {1}{6}x^{2}+\frac {1}{120}x^{4}+\cdots \right ) \end {align*}

Hence\[ \left ( 1+\frac {1}{6}x^{2}+\frac {1}{120}x^{4}+\cdots \right ) =\frac {1}{2x}\left ( e^{x}-e^{-x}\right ) \] But \(y_{r=0}=A\left ( 1+\frac {1}{6}x^{2}+\frac {1}{120}x^{4}+\cdots \right ) \), therefore comparing the result we found above, wee see that we can write \(y_{r=0}\) as\begin {align*} y_{r=0} & =A\left ( \frac {1}{2x}\left ( e^{x}-e^{-x}\right ) \right ) \\ & =\frac {A}{2x}\left ( e^{x}-e^{-x}\right ) \end {align*}

Therefore\begin {align*} y_{h} & =y_{r=0}+y_{r=-1}\\ & =\frac {A}{2x}\left ( e^{x}-e^{-x}\right ) +\frac {B}{2x}\left ( e^{x}+e^{-x}\right ) \\ & =\frac {1}{x}\left ( \frac {A}{2}e^{x}-\frac {A}{2}e^{-x}+\frac {B}{2}e^{x}+\frac {B}{2}e^{-x}\right ) \\ & =\frac {1}{x}\left ( e^{x}\left ( \frac {A}{2}+\frac {B}{2}\right ) +e^{-x}\left ( -\frac {A}{2}+\frac {B}{2}\right ) \right ) \end {align*}

Let \(\frac {A+B}{2}=A_{0},\frac {B-A}{2}=B_{0}\) hence the above becomes\[ y_{h}=\frac {1}{x}\left ( A_{0}e^{x}+B_{0}e^{-x}\right ) \]

We see this is the same solution using the transformation method given above. We now need to find particular solution. Let \(y_{1}=\frac {e^{x}}{x},y_{2}=\frac {e^{-x}}{x}\), hence \(y_{1}^{\prime }=\frac {e^{x}}{x}-\frac {e^{x}}{x^{2}}\) and \(y_{2}^{\prime }=\frac {-e^{-x}}{x^{2}}-\frac {e^{-x}}{x}\), hence the Wronskian is\begin {align*} W & =\begin {vmatrix} y_{1} & y_{2}\\ y_{1}^{\prime } & y_{2}^{\prime }\end {vmatrix} \\ & =\begin {vmatrix} \frac {e^{x}}{x} & \frac {e^{-x}}{x}\\ \frac {e^{x}}{x}-\frac {e^{x}}{x^{2}} & \frac {-e^{-x}}{x^{2}}-\frac {e^{-x}}{x}\end {vmatrix} \\ & =\frac {e^{x}}{x}\left ( \frac {-e^{-x}}{x^{2}}-\frac {e^{-x}}{x}\right ) -\frac {e^{-x}}{x}\left ( \frac {e^{x}}{x}-\frac {e^{x}}{x^{2}}\right ) \\ & =\left ( \frac {-1}{x^{3}}-\frac {1}{x^{2}}\right ) -\left ( \frac {1}{x^{2}}-\frac {1}{x^{3}}\right ) \\ & =-\frac {2}{x^{2}} \end {align*}

Therefore, let \(y_{p}=u_{1}y_{1}+u_{2}y_{2}\) and hence\[ u_{1}=-\int \frac {y_{2}}{aW}e^{x}dx \] Where \(a=x\) since the original ODE is \(xy^{\prime \prime }+2y^{\prime }-xy=e^{x}\), and \(a\) is the coefficient of \(y^{\prime \prime }\) always. Hence the above becomes\[ u_{1}=-\int \frac {\frac {e^{-x}}{x}}{x\left ( -\frac {2}{x^{2}}\right ) }e^{x}dx=\int \frac {e^{-x}}{2}e^{x}dx=\int \frac {1}{2}dx=\frac {x}{2}\] And\[ u_{2}=\int \frac {\frac {e^{x}}{x}}{x\left ( -\frac {2}{x^{2}}\right ) }e^{x}dx=-\int \frac {\frac {e^{x}}{x}}{\frac {2}{x}}e^{x}dx=-\frac {1}{2}\int e^{2x}dx=-\frac {1}{2}\frac {e^{2x}}{2}=\frac {-1}{4}e^{2x}\] Hence \begin {align*} y_{p} & =u_{1}y_{1}+u_{2}y_{2}\\ & =\frac {x}{2}\frac {e^{x}}{x}-\frac {1}{4}e^{2x}\frac {e^{-x}}{x}\\ & =\frac {1}{2}e^{x}-\frac {1}{4x}e^{x} \end {align*}

Therefore \[ y_{p}=e^{x}\left ( \frac {1}{2}-\frac {1}{4x}\right ) \] Hence the general solution is\begin {align*} y & =y_{h}+y_{p}\\ & =\frac {1}{x}\left ( A_{0}e^{x}+B_{0}e^{-x}\right ) +e^{x}\left ( \frac {1}{2}-\frac {1}{4x}\right ) \end {align*}

Verification

restart; 
ode:=x*diff(diff(y(x),x),x)+2*diff(y(x),x)-x*y(x)=exp(x); 
y0:=1/x*( _C1* exp(x)+ _C2*exp(-x))+ (1/2-1/(4*x))*exp(x); 
odetest(y(x)=y0,ode); 
0