1.2.3.2.1 Example 1 \(\left ( x-x^{2}\right ) y^{\prime \prime }+3y^{\prime }+2y=3x^{2}\)

\[ \left ( x-x^{2}\right ) y^{\prime \prime }+3y^{\prime }+2y=3x^{2}\]
Comparing the above to \(y^{\prime \prime }+p\left ( x\right ) y^{\prime }+q\left ( x\right ) y=0\) shows that \(p\left ( x\right ) =\frac {3}{x\left ( 1-x\right ) },q\left ( x\right ) =\frac {2}{x\left ( x-1\right ) }\).  Hence there are two singular points, one at \(x=0\) and one at \(x=1\). Let the expansion be around \(x=0\). This means the solution will define up to \(x=1\), which is the next nearest singular point.
\[ p_{0}=\lim _{x\rightarrow 0}xp\left ( x\right ) =\lim _{x\rightarrow 0}x\frac {3}{x\left ( 1-x\right ) }=3 \]
And
\[ q_{0}=\lim _{x\rightarrow 0}x^{2}\frac {2}{x\left ( 1-x\right ) }=0 \]
Hence \(x_{0}=0\) is a regular singular point. The indicial equation is
\begin{align*} r\left ( r-1\right ) +p_{0}r+q_{0} & =0\\ r\left ( r-1\right ) +3r & =0\\ r^{2}-r+3r & =0\\ r^{2}+2r & =0\\ r\left ( r+2\right ) & =0 \end{align*}

Therefore \(r=0,r=-2\).  They differ by an integer \(N=2\). Therefore two linearly independent solutions can be constructed using

\begin{align*} y_{1} & =\sum _{n=0}^{\infty }a_{n}x^{n+r_{1}}\\ y_{2} & =Cy_{1}\ln \left ( x\right ) +\sum _{n=0}^{\infty }b_{n}x^{n+r_{2}}\end{align*}

Where \(C\) above can be zero depending on a condition given below. Now we will work out the solution for a general \(r\). Let

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

The homogeneous ode becomes

\begin{align*} \left ( x-x^{2}\right ) y^{\prime \prime }+3y^{\prime }+2y & =0\\ \left ( x-x^{2}\right ) \sum _{n=0}^{\infty }\left ( n+r\right ) \left ( n+r-1\right ) a_{n}x^{n+r-2}+3\sum _{n=0}^{\infty }\left ( n+r\right ) a_{n}x^{n+r-1}+2\sum _{n=0}^{\infty }a_{n}x^{n+r} & =0\\ \sum _{n=0}^{\infty }\left ( n+r\right ) \left ( n+r-1\right ) a_{n}x^{n+r-1}-\sum _{n=0}^{\infty }\left ( n+r\right ) \left ( n+r-1\right ) a_{n}x^{n+r}+\sum _{n=0}^{\infty }3\left ( n+r\right ) a_{n}x^{n+r-1}+\sum _{n=0}^{\infty }2a_{n}x^{n+r} & =0 \end{align*}

Re indexing to lowest powers on \(x\) gives

\begin{equation} \sum _{n=0}^{\infty }\left ( n+r\right ) \left ( n+r-1\right ) a_{n}x^{n+r-1}-\sum _{n=1}^{\infty }\left ( n+r-1\right ) \left ( n+r-2\right ) a_{n-1}x^{n+r-1}+\sum _{n=0}^{\infty }3\left ( n+r\right ) a_{n}x^{n+r-1}+\sum _{n=1}^{\infty }2a_{n-1}x^{n+r-1}=0 \tag {1A}\end{equation}
For \(n=0\)
\begin{align} \left ( n+r\right ) \left ( n+r-1\right ) a_{n}x^{n+r-1}+3\left ( n+r\right ) a_{n}x^{n+r-1} & =0\nonumber \\ \left ( r\left ( r-1\right ) +3r\right ) a_{0}x^{r-1} & =\nonumber \\ \left ( r^{2}+2r\right ) a_{0}x^{r-1} & =0 \tag {1B}\end{align}

Since \(a_{0}\neq 0\), then \(r=0,r=-2\) as was found above. Hence \(N=2\) which is the difference between the two roots. The homogenous ode therefore satisfies

\[ \left ( x-x^{2}\right ) y^{\prime \prime }+3y^{\prime }+2y=0 \]
The recurrence relation is when \(n\geq 1\) from (1A) and is given by
\[ \left ( n+r\right ) \left ( n+r-1\right ) a_{n}-\left ( n+r-1\right ) \left ( n+r-2\right ) a_{n-1}+3\left ( n+r\right ) a_{n}+2a_{n-1}=0 \]
Keeping larger \(a_{n}\) on the left and all lower \(a_{n}\) on the right gives
\begin{align} a_{n} & =\frac {-2+\left ( n+r-1\right ) \left ( n+r-2\right ) }{\left ( n+r\right ) \left ( n+r-1\right ) +3\left ( n+r\right ) }a_{n-1}\nonumber \\ a_{n} & =\frac {n+r-3}{n+r+2}a_{n-1} \tag {1}\end{align}

Now we find \(y_{h}=c_{1}y_{1}+c_{2}y_{2}\).  For \(n=1\) and letting \(a_{0}=1\) then (1) gives

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

For \(n=2\) Eq. (1) gives

\begin{align*} a_{2} & =\frac {-1+r}{4+r}a_{1}\\ & =\left ( \frac {-1+r}{4+r}\right ) \left ( \frac {-2+r}{3+r}\right ) \\ & =\left ( \frac {-1}{4}\right ) \left ( \frac {-2}{3}\right ) =\frac {1}{6}\end{align*}

For \(n=3\) Eq. (1) gives

\[ a_{3}=\frac {3+r-3}{3+r+2}a_{n-1}=0 \]
And all other higher \(a_{n}=0\). Hence
\begin{align*} y_{1} & =\sum _{n=0}^{\infty }a_{n}x^{n}\\ & =a_{0}+a_{1}x+a_{2}x^{2}\\ & =1-\frac {2}{3}x+\frac {1}{6}x^{2}\end{align*}

Now we need to find \(y_{2}\). We first check if \(y_{2}\) can be found using standard method as was done above for \(y_{1}\).  We need to evaluate

\begin{align*} \lim _{r\rightarrow r_{2}}a_{N}\left ( r\right ) & =\lim _{r\rightarrow -2}a_{2}\left ( r\right ) \\ & =\lim _{r\rightarrow -2}\left ( \frac {-1+r}{4+r}\right ) \left ( \frac {-2+r}{3+r}\right ) \\ & =\lim _{r\rightarrow -2}\left ( \frac {-1-2}{4-2}\right ) \left ( \frac {-2-2}{3-2}\right ) \\ & =6 \end{align*}

Since limit exist then \(C=0\) and we do not need the log term.

\[ y_{2}=\sum _{n=0}^{\infty }b_{n}x^{n+r_{2}}\]
From (1) and using \(b\) instead of \(a\) and using \(r=r_{2}=-2\) gives
\begin{align*} b_{n} & =\frac {n+r-3}{n+r+2}b_{n-1}\\ & =\frac {n-2-3}{n-2+2}b_{n-1}\\ & =\frac {n-5}{n}b_{n-1}\end{align*}

Hence for \(n=1\) and using \(b_{0}=1\) as we did for \(a_{0}\) gives

\[ b_{1}=-4b_{0}=-4 \]
For \(n=N=2\) which is the special case,
\[ b_{n}=\frac {-3}{2}b_{1}=6 \]
Since \(b_{N}\) is defined, we can continue and \(y_{2}\) is found using same recurrence relation. Hence this is subcase one. For \(n=3\)
\[ b_{3}=\frac {-2}{3}b_{2}=-4 \]
For \(n=4\)
\[ b_{4}=\frac {-1}{4}b_{3}=1 \]
And so on. Hence
\begin{align*} y_{2} & =\frac {1}{x^{2}}\sum _{n=0}^{\infty }b_{n}x^{n}\\ & =\frac {1}{x^{2}}\left ( b_{0}+b_{1}x+b_{2}x^{2}+b_{3}x^{3}+b_{4}x^{4}\right ) \\ & =\frac {1}{x^{2}}\left ( 1-4x+6x^{2}-4x^{3}+x^{4}\right ) \end{align*}

Therefore

\begin{align*} y_{h} & =c_{1}y_{1}+c_{2}y_{2}\\ & =c_{1}\left ( 1-\frac {2}{3}x+\frac {1}{6}x^{2}\right ) +c_{2}\left ( \frac {1}{x^{2}}\left ( 1-4x+6x^{2}-4x^{3}+x^{4}\right ) \right ) \end{align*}

Now we find \(y_{p}\). From earlier we found in (1B) the balance equation which gives

\[ \left ( x-x^{2}\right ) y^{\prime \prime }+3y^{\prime }+2y=3x^{2}\]
The balance relation is \(\left ( r^{2}+2r\right ) c_{0}x^{r-1}=3x^{2}\). This implies \(r-1=2\) or \(r=3\). Therefore \(\left ( r^{2}+2r\right ) c_{0}=3\) or \(\left ( 9+6\right ) c_{0}=3\) which gives \(c_{0}=\frac {3}{15}=\frac {1}{5}\). Hence
\begin{align*} y_{p} & =\sum _{n=0}^{\infty }c_{n}x^{n+r}\\ & =x^{3}\sum _{n=0}^{\infty }c_{n}x^{n}\end{align*}

To find \(c_{n}\), the same recurrence relation given in (1) is used again but \(a\) replaced by \(c\). This gives the recurrence relation to find coefficients of the particular solution as

\[ c_{n}=\frac {n+r-3}{n+r+2}c_{n-1}\]
For \(r=3\) the above becomes
\begin{align*} c_{n} & =\frac {n+3-3}{n+3+2}c_{n-1}\\ & =\frac {n}{n+5}c_{n-1}\end{align*}

For \(n=1\)

\[ c_{1}=\frac {1}{6}c_{0}=\frac {1}{6}\left ( \frac {1}{5}\right ) =\frac {1}{30}\]
For \(n=2\)
\[ c_{2}=\frac {2}{2+5}c_{1}=\frac {2}{7}\left ( \frac {1}{30}\right ) =\frac {1}{105}\]
And so on. Hence
\begin{align*} y_{p} & =x^{3}\sum _{n=0}^{\infty }c_{n}x^{n}\\ & =x^{3}\left ( c_{0}+c_{1}x+c_{2}x^{2}+\cdots \right ) \\ & =x^{3}\left ( \frac {1}{5}+\frac {1}{30}x+\frac {1}{105}x^{2}+\cdots \right ) \end{align*}

Hence the final solution

\begin{align*} y & =y_{h}+y_{p}\\ & =c_{1}\left ( 1-\frac {2}{3}x+\frac {1}{6}x^{2}\right ) +c_{2}\left ( \frac {1}{x^{2}}\left ( 1-4x+6x^{2}-4x^{3}+x^{4}\right ) \right ) +\left ( \frac {1}{5}x^{3}+\frac {1}{30}x^{4}+\frac {1}{105}x^{5}+\cdots \right ) \end{align*}

If we try to find \(y_{p}\) by assuming \(y_{p}=\sum _{n=0}^{\infty }c_{n}x^{n}\) and substituting into the ode and try to match coefficients, we can not always be successful. The above method using the balance equation always works and that is what I am using in my solver.