# Problem solving a non-homogeneous differential equation by series expansion method

I am trying to solve the DE $y''+y=x^2$ using the series expansion method. First, I assume that there exists a solution

$$y=a_0+a_1 x+a_2 x^2+a_3 x^3+a_4 x^4+a_5x^5+...$$

$$\therefore y'=0+a_1 +2a_2 x+3a_3 x^2+4a_4x^3+5a_5x^4...$$

$$\therefore y''=0+0 +2a_2 +6a_3 x+12a_4x^2+20a_5x^3...$$

Substituting into the DE,

$$(2a_2 +6a_3 x+12a_4x^2+20a_5x^3+...)+(a_0+a_1 x+a_2 x^2+a_3 x^3+a_4 x^4+...)=x^2$$

and then equating coefficients of like-powers,

$$x^0\Rightarrow2a_2+a_0=0$$ $$x^1\Rightarrow6a_3+a_1=0$$ $$x^2\Rightarrow12a_4+a_2=1$$ $$x^3\Rightarrow20a_5+a_3=0$$

So then solving for the recursion relations, given that the RHS isn't $x^2$ but $0$ instead, a very simple Maclaurin series appears, giving $\sin x$ and $\cos x$. But it isn't $0$. There's a discontinuity in the pattern because a random 1 comes out from the $x^2$ term. How does one account for this? Could I simple do the term for all terms $=0$ and THEN subtracting it from the sin or cos term, then adding the proper term with the 1 for $x^2$? Maybe that's confusing... anyway could someone fill me in on the next step? Literally all the answers on here for questions like mine didn't help me. Thanks

You properly identified the solution of $y''+y=0$. May be, you could also notice that $y=x^2-2$ is a solution of the equation. So $$y=c_1\cos(x)+c_2\sin(x)+x^2-2$$ could make you happy !
• wow ok. mind kind of messed up a little bit. which DE did that $y=x^2-2$ come from? thanks man really helping here, merry christmas to you too – M98B-PRO Dec 25 '16 at 15:17
• sorry, i meant where did $y=x^2-2$ come from, how did you derive it? was it done using power series expansion? because i want to do this using power series – M98B-PRO Dec 25 '16 at 15:26
• @M98B-PRO. I did the same as you did but looked at the extra terms beside $\cos(x)$ and $\sin(x)$ – Claude Leibovici Dec 26 '16 at 6:55
• where were these extra terms? when I did it they weren't in the form of $x^2-2$. could you enlighten me how you got it in that form – M98B-PRO Dec 26 '16 at 7:09