2.1111   ODE No. 1111

\[ x y''(x)-(x+1) y'(x)+y(x)=0 \] Mathematica : cpu = 0.0202992 (sec), leaf count = 20

DSolve[y[x] - (1 + x)*Derivative[1][y][x] + x*Derivative[2][y][x] == 0,y[x],x]
 

\[\left \{\left \{y(x)\to c_1 e^x+c_2 (-x-1)\right \}\right \}\] Maple : cpu = 0.017 (sec), leaf count = 13

dsolve(x*diff(diff(y(x),x),x)-(1+x)*diff(y(x),x)+y(x)=0,y(x))
 

\[y \left (x \right ) = c_{2} {\mathrm e}^{x}+x c_{1}+c_{1}\]

Hand solution

\begin {equation} xy^{\prime \prime }-\left ( x+1\right ) y^{\prime }+y=0\tag {1} \end {equation}

Taking Laplace transform of each term and using property of \(\mathcal {L}\left ( xf\left ( x\right ) \right ) =-\frac {d}{ds}F\left ( s\right ) \) where \(F\left ( s\right ) =\mathcal {L}f\left ( x\right ) \), then\[\mathcal {L}\left ( xy^{\prime \prime }\right ) =-\frac {d}{ds}\left ( \mathcal {L}y^{\prime \prime }\right ) \]

Let \(\mathcal {L}y\left ( x\right ) =Y\left ( s\right ) \equiv Y\).  Now \(\mathcal {L}y^{\prime \prime }=s^{2}Y-sy\left ( 0\right ) -y^{\prime }\left ( 0\right ) \). Assuming \(y\left ( 0\right ) =A,y^{\prime }\left ( 0\right ) =B\) then\begin {align*} \mathcal {L}\left ( xy^{\prime \prime }\right ) & =-\frac {d}{ds}\left ( s^{2}Y-As-B\right ) \\ & =-\left ( 2sY+s^{2}Y^{\prime }-A\right ) \end {align*}

And \begin {align*} \mathcal {L}\left ( \left ( x+1\right ) y^{\prime }\right ) & =\mathcal {L}\left ( xy^{\prime }+y^{\prime }\right ) \\ & =-\frac {d}{ds}\left ( \mathcal {L}y^{\prime }\right ) +\mathcal {L}y^{\prime }\\ & =-\frac {d}{ds}\left ( sY-y\left ( 0\right ) \right ) +\left ( sY-y\left ( 0\right ) \right ) \\ & =-\frac {d}{ds}\left ( sY-A\right ) +\left ( sY-y\left ( 0\right ) \right ) \\ & =-\left ( Y+sY^{\prime }\right ) +\left ( sY-A\right ) \\ & =-Y-sY^{\prime }+sY-A \end {align*}

Hence Laplace transform of the ODE becomes\begin {align*} -\left ( 2sY+s^{2}Y^{\prime }-A\right ) -\left ( -Y-sY^{\prime }+sY-A\right ) +Y & =0\\ -2sY-s^{2}Y^{\prime }+A+Y+sY^{\prime }-sY+A+Y & =0\\ Y^{\prime }\left ( s-s^{2}\right ) +Y\left ( -2s+1-s+1\right ) & =-2A\\ Y^{\prime }\left ( s^{2}-s\right ) +Y\left ( 3s-2\right ) & =2A\\ Y^{\prime }+\frac {\left ( 3s-2\right ) }{s\left ( s-1\right ) }Y & =\frac {2A}{s\left ( s-1\right ) } \end {align*}

The integrating factor is \(\mu =e^{\int \frac {\left ( 3s-2\right ) }{s\left ( s-1\right ) }}=e^{\ln \left ( s-1\right ) +2\ln \left ( s\right ) }=\left ( s-1\right ) s^{2}\), hence\begin {align*} d\left ( \left ( s-1\right ) s^{2}Y\right ) & =\left ( s-1\right ) s^{2}\frac {2A}{s\left ( s-1\right ) }\\ \left ( s-1\right ) s^{2}Y & =2A\int sds+c_{1}\\ \left ( s-1\right ) s^{2}Y & =2A\frac {s^{2}}{2}+c_{1}\\ Y & =\frac {As^{2}+c_{1}}{\left ( s-1\right ) s^{2}} \end {align*}

Inverse Laplace transform gives\begin {align*} y\left ( x\right ) & =-c_{1}+\left ( A+c_{1}\right ) e^{x}-c_{1}x\\ & =-c_{1}\left ( 1+x\right ) +\left ( A+c_{1}\right ) e^{x} \end {align*}

Let \(-c_{1}=A_{0},A+c_{1}+B_{0}\), hence\[ y\left ( x\right ) =A_{0}\left ( 1+x\right ) +B_{0}e^{x}\]

Verification

rrestart; 
ode:=x*diff(diff(y(x),x),x)-(1+x)*diff(y(x),x)+y(x)=0; 
y0:=_C0*(1+x)+_C1*exp(x); 
odetest(y(x)=y0,ode); 
0