I am trying to find the general solution of the DE $y''+y=x$ with a Maclaurin series. I know that I could solve this using the Principle of Superposition by finding a particular solution and the general solution to the homogeneous $y''+y=0$ (which yields the solution $y=acosx+bsinx+x$) but I am looking for what I am doing wrong.
If we let $y=\sum_{n=0}^{\infty}c_nx^n$ then, by substituting into the original DE we can obtain a recursive relation. After substituting and rearranging I obtained:$2c_2+c_0+[6c_3+c_1]x+\sum_{n=2}^{\infty}c_{n+1}(n+2)(n+1)+c_n=0+x+\sum_{n=2}^\infty0$ This gives the recurrence relation $c_{n+2}=-\frac{c_n}{(n+2)(n+1)}, n>1$ and the relationships $2c_2+c_0=0$ and $6c_3+c_1=1$ which allows us to solve $c_2$ and $c_3$ in terms of $c_0$ and $c_1$: $c_2=-\frac{c_0}{2}$, $c_3$=$-\frac{c_1-1}{6}$.
The solution for the recurrence relation is given by $c_{2n}=(-1)^n\frac{c_0}{(2n)!}, c_{2n+1}=(-1)^n\frac{c_1-1}{(2n+1)!},n\in\mathbb{Z}^+$
However, if I substitute these solutions into the assumed form $\sum_{n=0}^{\infty}c_nx^n=\sum_{n=0}^{\infty}c_{2n}x^{2n}+\sum_{n=0}^{\infty}c_{2n+1}x^{2n+1}$ we obtain the Maclaurin series for $cosx$ and $sinx$ but no $x$. What happened to the $x$? What did I do wrong?