Second order linear non-homogenous ODE - checking my solution $$xy'' + 2y' - xy = e^x$$
is the equation. Here's what I did:
Divide by x
First, solve the homogenous equation.
$$y'' + \frac{2}{x}y' - y =0$$
Perform a substitution $y=u(x) \cdot z(x)$, where $u(x) = e^{-\frac{1}{2}\int{p(x)dx}}$
In this case, $p(x) = \frac{2}{x}$, and $q(x) = -1$
Find $u', u''$
After plugging in the necessary values, we get an equation: $$z'' - z = 0$$, the solution of which is $$C_1e^x + C_2e^{-x}$$
We plug this in $y=u\cdot z$ and get:
$$y=C_1 \frac{e^x}{x} + C_2 \frac{e^{-x}}{x}$$
I am fairly sure I made no mistakes up until this point. Next, I tried to solve the equation by variation of constants, where I get the Wronskian $-\frac{2}{x^2}$.
Thus, $C_1' = \frac{1}{2}$, so $C_1 = \frac{x}{2} + C_3$
And $C_2' = -\frac{e^{2x}}{2}$, so $C_2 = -\frac{e^{2x}}{4} + C_4$
When I plug in these values into $y$, I get
$$y=\frac{e^x}{2} + C_3 \frac{e^x}{x} - \frac{e^x}{4x} + C_4\frac{e^{-x}}{x}$$
Now, when I check the solution on WolframAlpha, the third term in my solution is extra. Can anyone spot my mistake because I am unable to do so? I have been trying for at least several hours.
NOTE: It is imperative for this exercise to be done with variation of constants.
 A: One could also simply observe that from the general Leibniz rule for product differentiation $$xy''+2y'=(xy)''$$ and compute the particular solution via undetermined coefficients,
$$
z''-z=e^x,~~~ z_p=Axe^x\implies 2A=1
\\~\\
z(x)=xy(x)=\frac12xe^x+C_1e^x+C_2e^{-x}
$$
A: $$xy'' + 2y' - xy = e^x$$
$$(xy'+y)'-xy=e^x$$
$$(xy)''-xy=e^x$$
$$(xy)''-(xy)'+(xy)'-xy=e^x$$
$$(e^{-x}(xy)')'+(xye^{-x})'=1$$
$$(e^{-x}(xy)'+xye^{-x})'=1$$
$$(e^{-2x}(xye^{x})')'=1$$
Integrate.
$$\boxed {xy=c_1e^x+c_2e^{-x}+\dfrac 12 xe^x}$$
A: First the homogeneous solution is $y_h = \frac{c_1 e^{-x}}{x}+\frac{c_2 e^x}{x}$
Second, making the particular as $y_p = \frac{c_1(x) e^{-x}}{x}+\frac{c_2(x) e^x}{x}$ after substitution into the complete ODE we have
$$
e^{-x} c_1''(x)-2 e^{-x} c_1'(x)+e^x c_2''(x)+2 e^x c_2'(x)-e^x=0
$$
due to de  independence between $c_1$ and $c_2$ we can arrange this as
$$
\cases{
e^{-x} c_1''(x)-2 e^{-x} c_1'(x)-e^x = 0\\
e^x c_2''(x)+2 e^x c_2'(x) = 0
}
$$
making $u_1 = c_1',\ \ u_2 = c_2'$ we follow with
$$
\cases{
e^{-x} u_1'(x)-2 e^{-x} u_1(x)-e^x = 0\\
e^x u_2'(x)+2 e^x u_2(x) = 0
}
$$
with particular solutions
$$
\cases{
u_1(x) = x e^{2 x}\\
u_2(x) = 0
}
$$
or integrating particularly
$$
\cases{
c_1(x) = \frac{1}{4} e^{2 x} (2 x-1)\\
c_2(x) = 0
}
$$
then finally
$$
y(x) = y_h+y_p = \frac{c_1 e^{-x}}{x}+\frac{c_2 e^x}{x}+\frac{e^x \left(2 x-1\right)}{4 x}
$$
or
$$
y(x) = \frac{c_1 e^{-x}}{x}+\left(\frac{c_2 e^x}{x}-\frac{e^x}{4x}\right)+\frac{x e^x}{2}
$$
