4.3.2.1 Euler ode \(x^{2}y^{\prime \prime }+xy^{\prime }+y=f\left ( x\right ) \)
4.3.2.1.1 Example 1 \(x^{2}y^{\prime \prime }+xy^{\prime }+y=x\)
4.3.2.1.2 Example 2 \(\left ( x-2\right ) ^{2}y^{\prime \prime }+\left ( x-2\right ) y^{\prime }+y=x\)

ode internal name "second order euler ode"

Solved by substitution \(y=x^{r}\) and solving for \(r\). Solution will be \(y=c_{1}x^{r_{1}}+c_{2}x^{r_{2}}\) where \(r_{1},r_{2}\) are the roots of the characteristic equation. For repeated root, the second solution is multiplied by extra \(\ln \left ( x\right ) \) and not extra \(x\) as is the case with standard constant coefficient ode. The particular solution is found in the same way using variation of parameters. Can not use undetermined coefficient method since this is not constant coefficients ode. The basis functions here are \(x^{r_{1}},x^{r_{2}}\) if not repeated roots, else the basis are \(x^{r_{1}},\ln \left ( x\right ) x^{r_{2}}\).

Initial conditions for Euler ode can not be at \(x=0\).  For ode of the form

\[ \left ( x-a\right ) ^{2}y^{\prime \prime }+\left ( x-a\right ) y^{\prime }+y=f\left ( x\right ) \]

This is still Euler ode. We start by substitution \(X=x-a\) which gives

\[ X^{2}y^{\prime \prime }+Xy^{\prime }+y=f\left ( X+a\right ) \]

This is now solved using \(y=X^{r}\) as before. When we obtain the solution \(y\left ( X\right ) \) then every \(X\) is replaced back by \(x-a\) to obtain the final solution. Below are two examples.

4.3.2.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*}

4.3.2.1.2 Example 2 \(\left ( x-2\right ) ^{2}y^{\prime \prime }+\left ( x-2\right ) y^{\prime }+y=x\) This examples shows how to solve the Euler ode when coefficients have constant shift as in this example. This method only work when the shift is the same on both coefficients of \(y^{\prime \prime }\) and \(y^{\prime }\). We start by assuming \(X=x-2\) or \(x=X+2\). The ode becomes

\[ X^{2}y^{\prime \prime }+Xy^{\prime }+y=X+2 \]

In the above, \(y\) is now a function of \(X\) and not \(x\). We always start by solving \(y_{h}\) from

\[ X^{2}y^{\prime \prime }+Xy^{\prime }+y=0 \]

As we did in the above example, the solution is

\[ y_{h}\left ( X\right ) =c_{1}\cos \left ( \ln X\right ) +c_{2}\sin \left ( \ln X\right ) \]

Now we find the particular solution where now \(f\left ( X\right ) =X+2\) and not \(x\).  Hence the solution is

\[ y=y_{h}+y_{p}\]

\(y_{p}\) is found from variation of parameters as before.

\[ 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+2\) in this case, since this is the forcing function in the rhs of the original ode and \(W\) is the wronskian which is \(\frac {1}{X}\) as was found in the first example. Hence \(u_{1},u_{2}\) become

\begin{align*} u_{1} & =-\int \frac {\left ( X+2\right ) \sin \left ( \ln X\right ) }{X^{2}\left ( \frac {1}{X}\right ) }dX=-\int \frac {\left ( X+2\right ) \sin \left ( \ln X\right ) }{X}dX=2\cos \left ( \ln X\right ) +\frac {1}{2}X\cos \left ( \ln X\right ) -\frac {1}{2}X\sin \left ( \ln X\right ) \\ u_{2} & =\int \frac {\left ( X+2\right ) \cos \left ( \ln \left ( x\right ) \right ) }{X^{2}\left ( \frac {1}{X}\right ) }dX=\int \frac {\left ( X+2\right ) \cos \left ( \ln \left ( x\right ) \right ) }{X}dX=2\sin \left ( \ln X\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 ( 2\cos \left ( \ln X\right ) +\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 ( 2\sin \left ( \ln X\right ) +\frac {1}{2}X\cos \left ( \ln X\right ) +\frac {1}{2}X\sin \left ( \ln X\right ) \right ) \sin \left ( \ln X\right ) \\ & =2\cos ^{2}\left ( \ln X\right ) +\frac {1}{2}X\cos ^{2}\left ( \ln X\right ) -\frac {1}{2}X\sin \left ( \ln X\right ) \cos \left ( \ln \left ( X\right ) \right ) +2\sin ^{2}\left ( \ln X\right ) +\frac {1}{2}X\cos \left ( \ln X\right ) \sin \left ( \ln X\right ) +\frac {1}{2}X\sin ^{2}\left ( \ln X\right ) \\ & =2+\frac {1}{2}X \end{align*}

Therefore the solution is

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

The solution to the original ode is now found by replacing \(X=x-2\) which gives

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