<s>[INST] Solve $y''+y=p(x)$ where $p$ is a polynomial function The equation is $$y'' + y=p(x)$$ Let $p(x)=\sum\limits_{k=0}^n a_k x^k$
The homogeneous solution to the equation is $y_h = a\cos(x)+b\sin(x)$. I can look for a particular solution of the form  $y_p=\sum\limits_{k=0}^n b_k x^k$. 
We get $$\sum\limits_{k=0}^{n-2} ((k+2)(k+1)b_{k+2}+b_k)x^k+b_{n-1}x^{n-1}+b_nx^n=\sum\limits_{k=0}^n a_kx^k$$  Hence, if $0\le k \le n-2$, $(k+2)(k+1)b_{k+2}+b_k=a_k$ and $b_{n-1}=a_{n-1}$, $b_n=a_n$
I'm trying to show that $y_p=\sum\limits_{n=0}^{\infty}(-1)^n p^{(2n)}(x)$ from here, how do I proceed?
 [/INST] As you stated, you have $b_n=a_n$ and $b_{n-1}=a_{n-1}$. You also have that, for $0 \le k \le n - 2$ that
$$(k+2)(k+1)b_{k+2}+b_k=a_k \implies b_k = a_k - (k+2)(k+1)b_{k+2} \tag{1}\label{eq1A}$$
Thus, you can start from $k = n - 2$ and work down to $k = 0$ to get each value of $b_k$ in turn. For example with the next $3$ values of $b_k$, you have
$$\begin{equation}\begin{aligned}
b_{n-2} & = a_{n-2} - (n)(n-1)b_{n} \\
& = a_{n-2} - (n)(n-1)a_{n}
\end{aligned}\end{equation}\tag{2}\label{eq2A}$$
$$\begin{equation}\begin{aligned}
b_{n-3} & = a_{n-3} - (n-1)(n-2)b_{n-1} \\
& = a_{n-3} - (n-1)(n-2)a_{n - 1}
\end{aligned}\end{equation}\tag{3}\label{eq3A}$$
$$\begin{equation}\begin{aligned}
b_{n-4} & = a_{n-4} - (n-2)(n-3)b_{n-2} \\
& = a_{n-3} - (n-2)(n-2)(a_{n-2} - (n)(n-1)a_{n})
\end{aligned}\end{equation}\tag{4}\label{eq4A}$$
With these coefficients $b_k$ determined, as Mick's question comment suggests, you can then calculate the coefficients of each $x^k$ of what you're trying to show, i.e., $y_p=\sum\limits_{n=0}^{\infty}(-1)^n p^{(2n)}(x)$, to see whether or not they match the determined $b_k$ coefficients.
</s>