How resolve $y''+y=\sin(x)$ by power series around the point $x_0=0$ The ODE I tried to solve is:
$$y''+y=\sin(x)$$
using the power series method around the point $x_0=0$, with the conditions:
$$y(0)=0,\qquad y'(0)=0$$
Let
\begin{align}
y(x) &= \sum_{n=0}^{\infty} a_{n} \, x^n \\
y^{'}(x) &= \sum_{n=0}^{\infty} (n+1) \, a_{n+1} \, x^n \\
y^{''}(x) &= \sum_{n=0}^{\infty} (n+1)(n+2) \, a_{n+2} \, x^n.
\end{align}
then the differential equation gives
\begin{align}
\sum_{n=0}^{\infty} (n+1)(n+2) \, a_{n+2} \, x^n + \sum_{n=0}^{\infty} a_{n} \, x^n &= \sin(x) \\
\sum_{n=0}^{\infty} ( (n+1)(n+2) \, a_{n+2} + a_{n} ) \, x^n &= \sum_{n=0}^{\infty} \frac{(-1)^n \, x^{2n+1}}{(2 n +1)!}.
\end{align}
I got stuck in this last line, there I see that the sums on both sides are not very identical. So I want to know what change of variable I could apply to the index $n$ in order to find the values of $a_n$. Thanks.
 A: The difficulty as stated in the work of the proposed problem the left-hand side should be broken into even and odd index to match the right-hand side. Doing so gives the desired recurrence equations and thus solution.
This solution takes a similar but different path. Let
$$ y(x) = \sum_{n=0}^{\infty} a_{n} \, x^n $$
which leads to
\begin{align}
y(x) &= \sum_{n=0}^{\infty} a_{n} \, x^n \\
y^{'}(x) &= \sum_{n=0}^{\infty} (n+1) \, a_{n+1} \, x^n \\
y^{''}(x) &= \sum_{n=0}^{\infty} (n+1)(n+2) \, a_{n+2} \, x^n.
\end{align}
Now, by using
$$ \sin(x) = \frac{e^{i x} - e^{-i x}}{2 i} = \sum_{n=0}^{\infty} \frac{i^{n-1} \, (1 - (-1)^n)}{2 \, n!} \, x^n, $$
the differential equation becomes
\begin{align}
y^{''} + y &= \sin(x) \\
\sum_{n=0}^{\infty} \left( (n+1)(n+2) \, a_{n+2} + a_{n} \right) \, x^n &= \sum_{n=0}^{\infty} \frac{i^{n-1} \, (1-(-1)^n)}{2 \, n!} \, x^n 
\end{align}
which gives the recurrence
$$ a_{n+2} = - \frac{a_{n}}{(n+1)(n+2)} + \frac{i^{n-1} \, (1-(-1)^n)}{2 \, (n+2)!}. $$
From this is can be seen that when $n$ is even the term with $1 - (-1)^n$ is zero and leads to
$$ a_{2n} = - \frac{a_{0}}{(2 n)!}. $$
The odd values take the form
\begin{align}
a_{1} &= a_{1} \\
a_{3} &= \frac{1}{3!} - \frac{a_{1}}{3!} \\
a_{5} &= - \frac{2}{5!} + \frac{a_{1}}{5!} \\
a_{7} &= \frac{3}{7!} - \frac{a_{1}}{7!} \\
\cdots &= \cdots
\end{align}
This leads to
$$ y(x) = - a_{0} \, \cos(x) - a_{1} \, \sin(x) - \frac{x \, \cos(x)}{2}. $$
Applying the initial conditions $y(0) = y^{'}(0) = 0$ gives
$$ y(x) = \frac{\sin(x) - x \, \cos(x)}{2}. $$
