Example 4 Solved using power series

\[ y^{\prime }+y=\sin x \] Expansion is around \(x=0\). The (homogenous) ode has the form \(y^{\prime }+p\left ( x\right ) y=0\). We see that \(p\left ( x\right ) \) is defined as is at \(x=0\). Hence this is ordinary point, also the RHS has series expansion at \(x=0\).

Let \(y=\sum _{n=0}^{\infty }a_{n}x^{n},y^{\prime }=\sum _{n=0}^{\infty }na_{n}x^{n-1}=\sum _{n=1}^{\infty }na_{n}x^{n-1}\). The ode becomes\[ \sum _{n=1}^{\infty }na_{n}x^{n-1}+\sum _{n=0}^{\infty }a_{n}x^{n}=\sin x \] Indexing so all powers of \(x\) start at \(n\) gives\[ \sum _{n=0}^{\infty }\left ( n+1\right ) a_{n+1}x^{n}+\sum _{n=0}^{\infty }a_{n}x^{n}=\sin x \] Expanding \(\sin x\) in series gives\[ \sum _{n=0}^{\infty }\left ( n+1\right ) a_{n+1}x^{n}+\sum _{n=0}^{\infty }a_{n}x^{n}=x-\frac {x^{3}}{3!}+\frac {x^{5}}{5!}-\cdots \] For \(n=0\), there is no term on RHS with \(x^{0}\), hence we obtain\begin {align*} a_{1}+a_{0} & =0\\ a_{1} & =-a_{0} \end {align*}

For \(n=1\) there is one term \(x^{1}\) on RHS, hence\begin {align*} 2a_{2}+a_{1} & =1\\ a_{2} & =\frac {1-a_{1}}{2}=\frac {1+a_{0}}{2} \end {align*}

For \(n=2\) there is no term on RHS with \(x^{2}\) hence\begin {align*} 3a_{3}+a_{2} & =0\\ a_{3} & =-\frac {a_{2}}{3}=-\frac {\frac {1+a_{0}}{2}}{3}=-\frac {1}{6}a_{0}-\frac {1}{6} \end {align*}

For \(n=3\) there is term \(-\frac {1}{6}x^{3}\) on RHS, hence\begin {align*} 4a_{4}+a_{3} & =-\frac {1}{6}\\ a_{4} & =\frac {-\frac {1}{6}-a_{3}}{4}=\frac {-\frac {1}{6}-\left ( -\frac {1}{6}a_{0}-\frac {1}{6}\right ) }{4}=\frac {1}{24}a_{0} \end {align*}

And so on. The solution is\begin {align*} y & =\sum _{n=0}^{\infty }a_{n}x^{n}\\ & =a_{0}+a_{1}x+a_{2}x^{2}+\cdots \\ & =a_{0}-a_{0}x+\left ( \frac {1+a_{0}}{2}\right ) x^{2}+\left ( -\frac {1}{6}a_{0}-\frac {1}{6}\right ) x^{3}+\left ( \frac {1}{24}a_{0}\right ) x^{4}+\cdots \\ & =a_{0}\left ( 1-x+\frac {1}{2}x^{2}-\frac {1}{6}x^{3}+\frac {1}{24}x^{4}-\cdots \right ) +\left ( \frac {1}{2}x^{2}-\frac {1}{6}x^{3}+\cdots \right ) \end {align*}