Particular solution of $y''+4y=x\cos x$ 
Find both the general solution $y_h$ and a particular solution $y_p$ for
  $$y''+4y=x\cos x$$

So far I've got $y_h$ from factoring the characteristic polynomial:
$$y_h=C_1\sin2x+C_2\cos2x$$
But the $y_p$ part troubles me, any help?

Assume $y$ of the form $P(x)\cos x$ where $P$ is a polynomial, "to see".
Then
$$y''=P''(x)\cos x-2P'(x)\sin x-P(x)\cos x.$$
You can identify the term $x\cos x$ by setting $P(x)=x/3$,
$$y_1=\frac13x\cos x,$$ giving 
$$-\frac23\sin x-\frac13x\cos x+\frac43x\cos x\leftrightarrow x\cos x$$
and there will be a residual term 
$$-\frac23\sin x.$$
The latter can be compensated by 
$$y_0=\frac29\sin x.$$

The method can be made systematic for RHS of the form $P(x)\cos x+Q(x)\sin x$, as every step of identification will reduce the degrees of $P$ and $Q$ by at least one.
