1.2.2.5 Example 5. \(y^{\prime }+xy=x^{2}\)

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

Looking first at \(y^{\prime }+xy=0\). Expansion around \(x=0\). This is an ordinary point. Hence standard power series will be used. let \(y=\sum _{n=0}^{\infty }a_{n}x^{n}\). Substituting into the ode gives

\begin{align*} \sum _{n=1}^{\infty }na_{n}x^{n-1}+x\sum _{n=0}^{\infty }a_{n}x^{n} & =0\\ \sum _{n=1}^{\infty }na_{n}x^{n-1}+\sum _{n=0}^{\infty }a_{n}x^{n+1} & =0 \end{align*}

We always want to power on \(x\) be the same in each sum and be \(x^{n}\). Adjusting gives

\begin{equation} \sum _{n=0}^{\infty }\left ( n+1\right ) a_{n+1}x^{n}+\sum _{n=1}^{\infty }a_{n-1}x^{n}=0 \tag {3A}\end{equation}

For \(n=0\) we have

\[ a_{1}x^{0}=x^{0}\]

Hence \(a_{1}=1\). The recurrence relation is for \(n>0\). From (3A) we have

\begin{align*} \left ( n+1\right ) a_{n+1}x^{n}+a_{n-1}x^{n} & =0\\ \left ( \left ( n+1\right ) a_{n+1}+a_{n-1}\right ) x^{n} & =0\\ \left ( n+1\right ) a_{n+1}+a_{n-1} & =0 \end{align*}

For \(n=1\)

\begin{align*} 2a_{2}+a_{0} & =0\\ a_{2} & =-\frac {a_{0}}{2}\end{align*}

For \(n=2\)

\begin{align*} 3a_{3}+a_{1} & =0\\ a_{3} & =0 \end{align*}

For \(n=3\)

\begin{align*} 4a_{4}+a_{2} & =0\\ a_{4} & =-\frac {a_{2}}{4}\\ & =\frac {a_{0}}{8}\end{align*}

And so on. Hence

\begin{align*} y_{h} & =\sum _{n=0}^{\infty }a_{n}x^{n}\\ & =a_{0}+a_{1}x+a_{2}x^{2}+a_{3}x^{3}+a_{4}x^{4}+\cdots \\ & =a_{0}-\frac {a_{0}}{2}x^{2}+\frac {a_{0}}{8}x^{4}-\frac {a_{0}}{48}x^{6}-\cdots \\ & =a_{0}\left ( 1-\frac {1}{2}x^{2}+\frac {1}{8}x^{4}-\frac {1}{48}x^{6}-\cdots \right ) \end{align*}

Now we find \(y_{p}\). Let

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

Let us start by trying the undetermined coefficients method. We will see this will fail. Let \(y_{p}=c_{2}x^{2}+c_{1}x+c_{0}\). Substituting this into the ode gives

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

Hence \(c_{1}=1,c_{2}=0,c_{1}=0.\) We see this did not work. We get both \(c_{1}=0\) and \(c_{1}=1.\) What went wrong? The problem is that we used undetermined coefficients on an ode with non constant coefficients. And this is a no-no. Undetermined coefficients can sometimes work on ode with non constant coefficients but by chance as we see in earlier examples.

In solving an ode not the series method and if the ode have non constant coefficients, we should also not use undetermined coefficient but use the variation of parameters method which works on constant and non constant coefficients. We can not use variation of parameters here, since we are solving using series and do not have basis functions for integration.

So what to do now? How to find \(y_{p}\)? We use the same balance equation method as was done in earlier examples for singular point. This example was added here to show that undetermined coefficients can fail when finding \(y_{p}\) even on ordinary point.  Assuming \(y_{p}\) is

\begin{align*} y_{p} & =\sum _{n=0}^{\infty }c_{n}x^{n}\\ y_{p}^{\prime } & =\sum _{n=0}^{\infty }nc_{n}x^{n-1}\end{align*}

Substituting this into the ode gives

\begin{align*} \sum _{n=0}^{\infty }nc_{n}x^{n-1}+x\sum _{n=0}^{\infty }c_{n}x^{n} & =x^{2}\\ \sum _{n=0}^{\infty }nc_{n}x^{n-1}+\sum _{n=0}^{\infty }c_{n}x^{n+1} & =x^{2}\\ \sum _{n=1}^{\infty }nc_{n}x^{n-1}+\sum _{n=0}^{\infty }c_{n}x^{n+1} & =x^{2}\\ \sum _{n=0}^{\infty }\left ( n+1\right ) c_{n+1}x^{n}+\sum _{n=1}^{\infty }c_{n-1}x^{n} & =x^{2}\end{align*}

And the above is what will be used to obtain the \(c_{n}\) and \(y_{p}\). For \(n=0\)

\[ c_{1}x^{0}=x^{2}\]

No balance. Hence \(c_{1}=0\). For \(n=1\)

\begin{align*} 2c_{2}x+c_{0}x & =x^{2}\\ \left ( 2c_{2}+c_{0}\right ) x & =x^{2}\end{align*}

No balance. Hence \(2c_{2}+c_{0}=0\). Here, we are free to choose \(c_{0}=0\). Therefore \(c_{2}=0\). For \(n=2\)

\begin{align*} 3c_{3}x^{2}+c_{1}x^{2} & =x^{2}\\ \left ( 3c_{3}+c_{1}\right ) x^{2} & =x^{2}\end{align*}

Balance exist. Hence \(3c_{3}+c_{1}=1\). But \(c_{1}=0\), which gives \(c_{3}=\frac {1}{3}\).  For \(n=3\)

\[ 4c_{4}x^{3}+c_{2}x^{3}=x^{2}\]

No balance. Hence \(4c_{4}+c_{2}=0\) But \(c_{2}=0\) then \(c_{4}=0\). For \(n=4\)

\[ 5c_{5}x^{4}+c_{3}x^{4}=x^{2}\]

No balance. Hence \(5c_{5}+c_{3}=0\) or \(c_{5}=-\frac {1}{15}\). For \(n=5\)

\[ 6c_{6}x^{6}+c_{4}x^{6}=x^{2}\]

No balance. Hence \(6c_{6}+c_{4}=0\). But \(c_{4}=0\), hence \(c_{6}=0\). For \(n=6\)

\[ 7c_{7}x^{6}+c_{5}x^{6}=x^{2}\]

No balance. Hence \(7c_{7}+c_{5}=0\). But \(c_{5}=-\frac {1}{15}\), therefore \(c_{7}=\frac {1}{105}\) and so on. Therefore

\begin{align*} y_{p} & =\sum _{n=0}^{\infty }c_{n}x^{n}\\ & =c_{0}+c_{1}x+c_{2}x^{2}+c_{3}x^{3}+\cdots \\ & =0+0+0+\frac {1}{3}x^{3}+0-\frac {1}{15}x^{5}+0+\frac {1}{105}x^{7}-\cdots \\ & =\frac {1}{3}x^{3}-\frac {1}{15}x^{5}+\frac {1}{105}x^{7}-\frac {1}{945}x^{9}+\cdots \end{align*}

The final solution is

\begin{align*} y & =y_{h}+y_{p}\\ & =a_{0}\left ( 1-\frac {1}{2}x^{2}+\frac {1}{8}x^{4}-\frac {1}{48}x^{6}-\cdots \right ) +\left ( \frac {1}{3}x^{3}-\frac {1}{15}x^{5}+\frac {1}{105}x^{7}-\frac {1}{945}x^{9}+\cdots \right ) \end{align*}

In this example, we choose \(c_{0}=0\). This was arbitrary choice.