# Find the complete solution of differential equation

I´m having trouble with getting the complete solution for this equation.

${dy\over dx}=-y+2e^{-x}-1$

Somehow I´m not getting the same result as my answerlist or CAS tool.

I´m supposed to solve it using: ${dy\over dx}+p(x) y = q(x)$

$y={1\over v(x)}\int (v(x)q(x)+c)$

$v(x)=e^{P(x)}$

$P(x)=\int p(x)$ ...

I moved it to be:

${dy\over dx}+y=2e^{-x}-1$

And found:

$v(x)=e^{x}$

$P(x)=x$

Inserted into my equation for the full solution:

$y={1\over e^{x}}\int e^{x}2e^{-x}+c)$

I have however no idea what to do with the -1 from the provided equation.

• about the integration constant? – Narasimham Apr 27 '16 at 16:17
• So when the provided equation give me -1 I just insert it as c? – Simon Nielsen Apr 27 '16 at 16:24

This equation, $\;y' + y \;= \; 2e^{-x} \; – \; 1,\;$ is first order linear and thus it can be solved by finding an integrating factor.

The integrating factor is $\;\exp\left(\int p(x) \, dx\right) \; = \; \exp\left(\int 1 \, dx\right) \; = \; e^{x},\;$ so multiply both sides by $e^{x}.$ This gives

$$e^{x}y' \; + \;e^{x}y \;\; = \;\; e^{x} \cdot 2e^{-x} \; - \; e^{x} \;\; = \;\; 2 \;– \; e^x$$

The left side "factors" as the derivative of $y$ times the integrating factor. This always happens because of the way the integrating factor was defined. Your book will probably show this, but I'll do it below anyway. In class I used to explain how this is analogous to solving a quadratic equation by completing the square.

$$(ye^{x})' \; = \; 2 \; – \; e^x$$

Note that by using the product rule you can verify that $\;(ye^{x})' = e^{x}y' + e^{x}y.\;$ Now integrate both sides:

$$ye^{x} \; = \; 2x \; – \; e^x \; + \; C$$

Now divide both sides by $e^x$ and you'll get

$$y \; = \; 2xe^{-x} \; – \; 1 \; + \; Ce^{-x}$$

Here's why the integrating factor stuff works. The general equation has the form

$$y' \; + \; p(x)y \; = \; q(x)$$

Multiply both sides by $e^{\int p(x) \, dx},$ which is the integrating factor:

$$e^{\int p(x) \, dx}y' \; + \; e^{\int p(x) \, dx}p(x)y \;\; = \;\; e^{\int p(x) \, dx}q(x)$$

I claim that the left side can be "factored" to give

$$(ye^{\int p(x) \, dx})' \;\; = \;\; e^{\int p(x) \, dx}q(x)$$

To see that these two left hand sides are the same, use the product rule to expand $(ye^{\int p(x) \, dx})',$ which gives

$$y' \cdot e^{\int p(x) \, dx} \;\; + \;\; y \cdot \frac{d}{dx} \left( e^{\int p(x) \, dx}\right)$$ $$y' \cdot e^{\int p(x) \, dx} \;\; + \;\; y \cdot e^{\int p(x) \, dx} \cdot \frac{d}{dx}\int p(x) \, dx$$ $$y' \cdot e^{\int p(x) \, dx} \;\; + \;\; y \cdot e^{\int p(x) \, dx} \cdot p(x)$$

In the last three equations, I made use of the $(e^u)' = e^{u}u'$ formula for differentiating "$e$ raised to a power" and the fact that the derivative undoes the antidifferentiation operation.

Finally, a natural question that textbooks don't always discuss is why we choose "$C=0$" when performing the integration to obtain the integrating factor. The most instructive way I know to show students is to pick a specific equation, say the equation solved above, and instead of using $e^x$ for the integrating factor, use $\;e^{x + 5}\;$ and see what happens. In effect, all you're doing is multiplying both sides by an additional nonzero constant factor, which neither contributes anything nor messes anything up (except the details are very slightly messier).

• You´re the best, thanks for the long and very fulfilling answer :) You just tought me, what my teacher could not :D – Simon Nielsen Apr 27 '16 at 17:48

That's the issue with solving a problem by using "the formula".

You found that the integrating factor is $e^x$. The point of this is that now $$e^xy'+e^xy=(e^xy)'.$$ So, if you multiply your equation by $e^x$, you get $$e^xy'+e^xy=2-e^x,$$ or $$(e^xy)'=2-e^x.$$ If you now get the antiderivative on both sides, $$e^xy=2x-e^x+c,$$ and then $$y(x)=2xe^{-x}-1+ce^{-x}$$