We have a non homogeneous ODE $$y^{(4)} + 2y'' + y = x \sin x$$
with characteristic equation I get $(l^2+1)^2 = 0$ so $l = -i ,i$ and so the answer of homogeneous ODE is a linear combination of $\sin x , \cos x , x \sin x , x\cos x$.
For finding the Particular solution first I assumed $y_p = (Ax+B)(C\sin x + D \cos x)$ and it didn't work. Then $y_p = x(Ax+B)(C\sin x + D \cos x)$ and it didn't work. At last, $y_p = x^2(Ax+B)(C\sin x + D \cos x)$ worked and the answer was $-1/24 x^3 \sin x -1/8 x^2 \cos x$ worked but it took a lot of time to find that the other two don't work.
I want to know is there any way to guess the leading $x^n$ term and not testing different situations? (In this case $n=2$) I know it can be solved with a way involving Wronskian and Cramer's rule (but that way needs a 4x4 determinant which takes time to calculate) but I want to solve with undetermined coefficients rule so I want to find a better way for guessing the answer format.