3.5.1.1 Example 1 \(x^{2}y^{\prime \prime }+xy^{\prime }+y=x\)

We always start by solving \(y_{h}\) from

\[ x^{2}y^{\prime \prime }+xy^{\prime }+y=0 \]
Let \(y=x^{r}\) then \(y^{\prime }=rx^{r-1},y^{\prime \prime }=r\left ( r-1\right ) x^{r-2}\) and the above becomes
\begin{align*} x^{2}r\left ( r-1\right ) x^{r-2}+xrx^{r-1}+x^{r} & =0\\ r\left ( r-1\right ) x^{r}+rx^{r}+x^{r} & =0\\ r\left ( r-1\right ) +r+1 & =0 \end{align*}

The roots are \(i,-i\). Hence the two basis solutions are \(y_{1}=x^{i},y_{2}=x^{-i}\). The solution is

\begin{align*} y_{h} & =c_{1}x^{i}+c_{2}x^{-i}\\ & =c_{1}e^{\ln x^{i}}+c_{2}e^{\ln x^{-i}}\\ & =c_{1}e^{i\ln x}+c_{2}e^{-i\ln x}\\ & =c_{1}\cos \left ( \ln x\right ) +c_{2}\sin \left ( \ln x\right ) \end{align*}

Hence the solution is

\[ y=y_{h}+y_{p}\]
\(y_{p}\) is found from variation of parameters.
\[ y_{p}=u_{1}y_{1}+u_{2}y_{2}\]
Where
\begin{align*} u_{1} & =-\int \frac {y_{2}f\left ( x\right ) }{aW}dx\\ u_{2} & =\int \frac {y_{1}f\left ( x\right ) }{aW}dx \end{align*}

Where \(f=x\) in this case, since this is the forcing function in the rhs of the original ode and \(W\) is the wronskian

\begin{align*} W & =\begin {vmatrix} y_{1} & y_{2}\\ y_{1}^{\prime } & y_{2}^{\prime }\end {vmatrix} =\begin {vmatrix} \cos \left ( \ln \left ( x\right ) \right ) & \sin \left ( \ln x\right ) \\ -\frac {\sin \left ( \ln \left ( x\right ) \right ) }{x} & \frac {\cos \left ( \ln \left ( x\right ) \right ) }{x}\end {vmatrix} =\frac {1}{x}\cos \left ( \ln x\right ) ^{2}+\frac {1}{x}\sin \left ( \ln x\right ) ^{2}\\ & =\frac {1}{x}\end{align*}

And \(a=x^{2}\) which is the coefficient of the \(y^{\prime \prime }\) term in the original ode. Hence \(u_{1},u_{2}\) become

\begin{align*} u_{1} & =-\int \frac {x\sin \left ( \ln x\right ) }{x^{2}\left ( \frac {1}{x}\right ) }dx=-\int \sin \left ( \ln x\right ) dx=-\frac {1}{2}x\left ( -\cos \left ( \ln x\right ) +\sin \left ( \ln x\right ) \right ) =\frac {1}{2}x\cos \left ( \ln x\right ) -\frac {1}{2}x\sin \left ( \ln x\right ) \\ u_{2} & =\int \frac {x\cos \left ( \ln \left ( x\right ) \right ) }{x^{2}\left ( \frac {1}{x}\right ) }dx=\int \cos \left ( \ln \left ( x\right ) \right ) dx=\frac {1}{2}x\left ( \cos \left ( \ln x\right ) +\sin \left ( \ln x\right ) \right ) =\frac {1}{2}x\cos \left ( \ln x\right ) +\frac {1}{2}x\sin \left ( \ln x\right ) \end{align*}

Hence

\begin{align*} y_{p} & =u_{1}y_{1}+u_{2}y_{2}\\ & =\left ( \frac {1}{2}x\cos \left ( \ln x\right ) -\frac {1}{2}x\sin \left ( \ln x\right ) \right ) \cos \left ( \ln \left ( x\right ) \right ) +\left ( \frac {1}{2}x\cos \left ( \ln x\right ) +\frac {1}{2}x\sin \left ( \ln x\right ) \right ) \sin \left ( \ln x\right ) \\ & =\frac {1}{2}x\left ( \cos \left ( \ln x\right ) ^{2}-\sin \left ( \ln x\right ) \cos \left ( \ln x\right ) +\cos \left ( \ln x\right ) \sin \left ( \ln x\right ) +\sin \left ( \ln x\right ) ^{2}\right ) \\ & =\frac {1}{2}x \end{align*}

Therefore the solution is

\begin{align*} y & =y_{h}+y_{p}\\ & =\frac {1}{2}x+c_{1}\cos \left ( \ln x\right ) +c_{2}\sin \left ( \ln x\right ) \end{align*}