# Power series solution for a DE

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?

Hint: If you had $c_1$ instead of $c_1-1$ in your formula for $c_{2n+1}$, then you would really get $\sin x$ without $x$. But now you have to check carefully what that "$-1$" does...
• Yes, I forgot to mention that but wouldn't we just group the constants together? So we write $c_1-1=c_2$? – Hautdesert Apr 18 '12 at 23:04
• @Hautdesert: you can't do that since $c_1-1=b$ with $b$ the constant of the $\sin(x)$. – Raymond Manzoni Apr 18 '12 at 23:12
• @Hautdesert: just set $b:=c_1−1$ then the odd terms of $y$ will give you $c_1 x+c_3 x^3+c_5 x^5 −\cdots = (b+1)x - b \dfrac{x^3}{3!} +b \dfrac{x^5}{5!}-\cdots= b\sin(x) + x\$ (sorry for the edits...) – Raymond Manzoni Apr 18 '12 at 23:49