# Second Order ODE $y'' - 2y' + y = e^{2x}$ by Method of Variation of Parameters

I'm having some trouble with solving this second-order ODE by the method of variation of parameters. The problem is: $y'' - 2y' + y = e^{2x}$. Here's what I've done thus far.

The homogeneous component has an auxiliary equation of $r^2 - 2 r + 1$, which has a single root of $r = 1$, so our complimentary equation is $y_c = c_1 e^{x}+ c_2 xe^{x}$.

So, we take $y_1 = y_2 = e^{x}$, and guess that our particular solution takes the form $y_p = u_1(x) y_1 + u_2 (x) y_2$. Differentiating in $x$ gives us \begin{align*} y'_p = \frac{d}{dx}[u_1 e^x+u_2 xe^x] = (u_1' e^x + u_2' xe^x) + u_1e^x+u_2e^x+u_2xe^x \end{align*} Then, we can assume that $u_1' e^x + u_2' xe^x = 0$, so $y_p' = u_1e^x+u_2e^x+u_2xe^x$. Differentiating in $x$ once more and using our earlier assumption gives us \begin{align*} y''_p = (u_1' e^x + u_2'xe^x)+u_1 e^x+2u_2e^x+u'_2e^x+u_2xe^x = u_1 e^x+2u_2e^x+u'_2e^x+u_2xe^x \end{align*} Substituting back into our differential equation gives us (pre-simplification) \begin{align*} y'' - 2y' + y = u_1 e^x+2u_2e^x+u'_2e^x+u_2xe^x - 2(u_1e^x+u_2e^x+u_2xe^x) + u_1 e^x + u_2 xe^x = e^{2x} \end{align*} After simplifying, I get $2u'_2 e^x = e^{2x}$, so $2u'_2 = e^x$, $u'_2 = \frac{1}{2} e^x$, and $u_2 = \frac{1}{2} e^x$. Since $u_1'e^x + u_2'xe^x = 0$ by assumption, and $u'_2 = \frac{1}{2}e^x$, we have $u_1'+ \frac{1}{2}e^x = 0$, and $u'_1 = - \frac{1}{2}e^x$, so we get $$y_p = \Big(-\frac{1}{2}e^x\Big)e^x + \Big(\frac{1}{2}e^x\Big)xe^x = - \frac{1}{2} e^{2x} + \frac{1}{2} xe^{2x}$$ Therefore, our general solution is $$y = c_1 e^{x}+ c_2 xe^{x} + - \frac{1}{2} e^{2x} + \frac{1}{2} xe^{2x}$$ This answer, however, is not correct. The right answer should be $y = e^x(c_1 + c_2x) + e^{2x}$, but I can't figure out where I went wrong.

Some help on this would be greatly appreciated.

$$y'' - 2y' + y = u_1 e^x+2u_2e^x+u'_2e^x+u_2xe^x - 2(u_1e^x+u_2e^x+u_2xe^x) + u_1 e^x + u_2 xe^x = e^{2x}\quad \text{is correct}.$$ Then you wrote : After simplifying, I get $\quad 2u'_2 e^x = e^{2x}.\quad$ The mistake is there, because it should be : $\quad u'_2 e^x = e^{2x}$
There is no problem after correction : $\quad u'_2=e^x \quad;\quad u_2=e^x$
$u_1' e^x + u_2' xe^x = 0 = u_1' e^x + xe^{2x}$
$u_1'=-xe^x \quad;\quad u_1=-xe^x+e^x$
$y_p=u_1e^x+u_2xe^x =(-xe^x+e^x)e^x+(e^x)xe^{2x}$ $$y_p=e^{2x}\quad\text{which is correct}.$$