Second order ODE using method of undetermined coefﬁcients Question:
$$y''-2y'+2y=4e^x\sin x$$

Clearly the complementary function here is $(A+Bx)e^{2x}$ where $A$ and $B$ are constant. However, I am not sure for the Particular function here. Should the Particular function be $(C+Dx)x^2e^{2x}$?

Many Thanks.
Normally, using the method of undetermined coefficients you would be looking for a particular solution $y_p= (e^x)*(Acox(x)+Bsin(x))$ for the diff-equation you posted. Now when you have a product of sinusoids and an exponential as your "template" solution you have to check if $r+\mu*i$ is a solution to the characteristic equation. This comes about because the general form for the particular solution I presented is $(e^{rx})*(cos(\mu x)+sin(\mu x)) $ where this solution came about as linear combination of $e^{r+i *\mu}$. You should be able to convince yourself that this just makes the diff-eqn zero. 

Thus we have a problem is if $r+\mu*i$ is a solution to the characteristic equation. Because, if $r+\mu i$ is a solution, then the particular solution I posted is a solution to homogeneous equation. So to stop this we multiply by the whole thing by $x$ or by $(Gx+H)$, which makes no difference, but I like just multiplying it by $x$. So the particular solution is $y_p = (x)*(e^x)*(Acos(x)+Bsin(x))$. 

Now to explain some more things, if you have $y"+9y=x^2+cos(2x)$ as you asked. The particular solution would be $(Ax^2+Bx+C)+(Dcos(2x)+Esin(2x))$. As a result of the linear superposition principle. But let's make it more interesting, what if instead of y"+9y=... you had y'''+y"+9y'=... Now we have a problem with the polynomial part of the particular solution. we would then multiple just the polynomial part by $x$,so
$y_p$ becomes $x(Ax^2+Bx+C)+$... (the same sinusoids). Of course replacing $x(Ax^2+Bx+C)$ with $(Ax^3+Bx^2+Cx+F)$ makes no difference, but I just feel the first way is more of a generalization.

Hope this helps
First observe that $ y''_H - 2y'_h+2y_h = 0$ ($y$ homogenoeus) have solution $ y_h =e^{x}(c_1 \sin(x) + c_2 \cos(x)) $ and $y_p$ (y particular) should be linear independent of $y_h$. So that you are looking for solutions of the form:

$$ (C+Dx)\cdot e^{x} \cdot( \sin(x) + cos(x)) $$