$$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.

  • 2
    $\begingroup$ $C_3 \frac{e^x}{x} - \frac{e^x}{4x}=C_5 \frac{e^x}{x}$ $\endgroup$ May 24, 2021 at 9:11
  • 1
    $\begingroup$ Looking at all your wrote,, making from the start $y(x)=\frac{e^x}x z(x)$ gives the simple $z''+2z'=1$. Reduction of order gives $z'=\frac 12+c_1 e^{-2x}$ then $z=\frac x 2+c_1 e^{-2x}+c_2$. Multiply by $\frac{e^x}x$ and expand. In any manner, you cannot have more than two arbitrary constants. $\endgroup$ May 24, 2021 at 9:24
  • $\begingroup$ @ClaudeLeibovici I do not have more than two constants. I couldn't name the new constants C1 and C2 because I used that notation already. I could have called them $K_1$ and $K_2$ though. $\endgroup$
    – john doe
    May 24, 2021 at 9:30
  • $\begingroup$ And isn't $u(x) = \frac{1}{x} $ ? $\endgroup$
    – john doe
    May 24, 2021 at 9:31
  • 2
    $\begingroup$ You did not make anything wrong. My first comment was just $Cte+Cte=Cte$. My second comment was to show that, starting from your work, we could to it a bit faster. That's all. $\endgroup$ May 24, 2021 at 9:56

3 Answers 3


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} $$


$$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}$$


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} $$


$$ 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} $$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.