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. Previously someone told me that $x^2-2$ is a solution as well, which makes the final solution
$$y=c_1\cos x + c_2\sin x +x^2-2$$
Which is correct. Could someone tell me how this $x^2-2$ can be found from that pattern? I am trying to do this problem using the power series method, so only answers showing how to solve it using THAT method are appreciated. I know how to do it using variation of parameters or undetermined coefficients.
So, how can one do it using the power series?