Check Solution: $x^2y''+xy'-y=x^2e^x$ via Variation of Parameters I was revisiting differential equations and I came across the following question:

By method of variation of parameters, the particular solution of the equation $$x^2y''+xy'-y=x^2e^x$$is:
$(a) \ e^x+\frac1x$ 
$(b)\ e^x- \frac{e^x}x$
$(c)\ e^x+\frac{e^x}x$
$(d)\ e^x-\frac1x$

My attempt: 

Let $x=e^z$. Then the differential equation becomes: $$\frac{d^2y}{dz^2}-y=e^{2z}e^{e^z}$$
  Solution of the homogenous equation is :$y_c=c_1 e^z + c_2 e^{-z}$ where $c_1$ and $c_2$ are arbitrary constants. Thus, solution of original homogenous equation is $y_c=c_1x+c_2\frac1x$.
I calculated the Wronskian which came out to be $\frac{-2}{x}$. Therefore, particular solution is 
  $$y_p=-x\int \frac{x^2e^x}{-2}+\frac1x \int \frac{x^4e^x}{-2}=\frac x2 \int x^2e^x-\frac{1}{2x} \int x^4 e^x $$
On simplifying : 
$$-\frac32 x^2 e^x-\frac{11}2 xe^x +12e^x\left(1-\frac1x\right)$$

Where have I gone wrong? I realized that even if I made mistake right in the end while simplifying there will be a term involving $x^2$ and none of the four options have any such term.
The answer given is $(b)$.
 A: Recall that the formula for the particular solution is:
$$y_p=-y_1 \int \frac{y_2 r(x)}{W(y_1,y_2)}~dx+y_2 \int \frac{y_1 r(x)}{W(y_1,y_2)}~dx$$
For a differential equation in the following form:
$$y''+p(x)y'+q(x)y=r(x) \tag{1}$$

Therefore, your mistake is that you forgot to divide your ODE by $x^2$ to get it in the form of $(1)$:
$$y''+\frac{y'}{x}-\frac{y}{x^2}=e^x$$
Hence, your particular solution should be:
$$\begin{align} y_p&=-x\int \frac{\frac{1}{x}\cdot e^x}{-\frac{2}{x}}~dx+\frac{1}{x}\int \frac{x\cdot e^x}{-\frac{2}{x}}~dx\\ &=x\int \frac{e^x}{2}~dx-\frac{1}{x}\int \frac{x^2\cdot e^x}{2}~dx\end{align}$$
Doing the integration correctly gives you the correct answer, b).
A: Define $L(y)=x^2y''+xy'-y$. Then $L(e^x)=(x^2+x-1)e^x$. The non-quadratic terms times the exponential can not be canceled by $L(\frac1x)$, so a) and d) are out.
$$
L(x^{-1}e^x)=x^2(2x^{-3}-2x^{-2}+x^{-1})e^x+x(-x^{-2}+x^{-1})e^x-x^{-1}e^x
\\
=(-1+x)e^x
$$
so that the difference as in b) gives the right side in question.
