Consider
$y''+y= 2x \sin (x)$
I have the solution for the homogeneous equation. Now i am trying to guess a particular solution for: $2x \sin (x)$
My first guess was: $(Ax+B) \cos x + (Cx +D) \sin x$ but i end up with the system:
$\left\{\begin{matrix} -2A & +2B& =0\\ 2C =0& & \end{matrix}\right.$
Then my quess was: $(Ax^2+xB) \cos x + (Cx^2 +xD) \sin x$ but that leaves me with:
$\left\{\begin{matrix} -Ax & -B & +4C & =0\\ 2A & 2D & =0 & \\ -4A & -Cx & -D & =0\\ -2B & 2C & =0 & \end{matrix}\right.$
I feel something is wrong.
So, i would like to know if mi guess is ok at least, then i will try to figure out how to arrange the equations in order to have something useful.
The last guess is true but your calculations are incorrect
The final equation should give $$2A+2D=0\\-2B+2C=0\\-4A=2\\4C=0$$ Thus $C=B=0,A=-D=-\frac{1}{2}$