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?
 A: Hint. Use the Method of undetermined coefficients. 
Since $x$ is a polynomial of degree one and $i$ is not a solution of the characteristic polynomial, you should try with
$$y_p(x)=(Ax+B)\cos(x)+(Cx+D)\sin(x)$$
where the constants $A,B,C,D$ have to be determined by plugging $y_p$ in the differential equation.
A: For $y_p$ use method of variation of parameter
$$
\begin{aligned}
& W=\left|\begin{array}{cc}
y_{1} & y_{2} \\
y_{1}^{\prime} & y_{2}^{\prime}
\end{array}\right| \\
& W=\left|\begin{array}{cc}
\sin 2 x & \cos 2 x \\
2 \cos 2 x & -2 \sin 2 x
\end{array}\right|=-2 \\
\therefore y_{p} &=-y_{1} \int \frac{y_{2} x}{w} d x+y_{2} \frac{y_{1} x}{w} d x .
\end{aligned}
$$
$y_{1}=\sin 2 x\\
y_{2}=\cos 2 x
$
[Solution by complement function.]
$x=x \cos x$ [Forcing function]
Original image
See the steps for finding particular integral.
Try using variation of parameter.
A: 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.
