Solution to Linear First Order Ordinary Differential Equation

Theorem
A linear first order ordinary differential equation in the form:
 * $\dfrac {\mathrm d y}{\mathrm d x} + P \left({x}\right) y = Q \left({x}\right)$

has the general solution:
 * $\displaystyle y = e^{-\int P \ \mathrm d x} \left({\int Q e^{\int P \ \mathrm d x} \ \mathrm d x + C}\right)$

Proof
Consider the first order ordinary differential equation:


 * $M \left({x, y}\right) + N \left({x, y}\right) \dfrac {\mathrm d y} {\mathrm d x} = 0$

We can put our equation:
 * $(1) \quad \dfrac {\mathrm d y}{\mathrm d x} + P \left({x}\right) y = Q \left({x}\right)$

into this format by identifying:
 * $M \left({x, y}\right) \equiv P \left({x}\right) y - Q \left({x}\right), N \left({x, y}\right) \equiv 1$

We see that:
 * $\dfrac {\partial M} {\partial y} - \dfrac {\partial N}{\partial x} = P \left({x}\right)$

and hence:
 * $P \left({x}\right) = \dfrac {\dfrac {\partial M} {\partial y} - \dfrac {\partial N}{\partial x}} N$

is a function of $x$ only.

It immediately follows from Integrating Factors for First Order Equations that:
 * $e^{\int P \left({x}\right) dx}$

is an integrating factor for $(1)$.

So, multiplying $(1)$ by this factor, we get:
 * $e^{\int P \left({x}\right) \ \mathrm d x} \dfrac {\mathrm d y} {\mathrm d x} + e^{\int P \left({x}\right) \ \mathrm d x} P \left({x}\right) y = e^{\int P \left({x}\right) \ \mathrm d x} Q \left({x}\right)$

We can now slog through the technique of Solution to Exact Differential Equation.

Alternatively, from the Product Rule for Derivatives, we merely need to note that:
 * $\dfrac {\mathrm d} {\mathrm d x} \left({e^{\int P \left({x}\right) \ \mathrm d x} y}\right) = e^{\int P \left({x}\right) \ \mathrm d x} \dfrac {\mathrm d y} {\mathrm d x} + y e^{\int P \left({x}\right) \ \mathrm d x} P \left({x}\right) = e^{\int P \left({x}\right) \ \mathrm d x} \left({\dfrac {\mathrm d y} {\mathrm d x} + P \left({x}\right) y}\right)$

So, if we multiply $(1)$ all through by $e^{\int P \left({x}\right) \ \mathrm d x}$, we get:
 * $\dfrac {\mathrm d} {\mathrm d x} \left({e^{\int P \left({x}\right) \ \mathrm d x} y}\right) = Q \left({x}\right)e^{\int P \left({x}\right) \ \mathrm d x}$

Integrating w.r.t. $x$ now gives us:
 * $\displaystyle e^{\int P \left({x}\right) \ \mathrm d x} y = \int Q \left({x}\right) e^{\int P \left({x}\right) \ \mathrm d x} \ \mathrm d x + C$

whence we get the result by dividing by $e^{\int P \left({x}\right) \ \mathrm d x}$.

Also denoted as
This result is also reported as:
 * $\displaystyle y e^{\int P \ \mathrm d x} = \int Q e^{\int P \ \mathrm d x} \ \mathrm d x + C$

Comment
This technique is known as Solution by Integrating Factor, and can easily be remembered by the procedure: "Multiply by $e^{\int P \left({x}\right) \ \mathrm d x}$ and integrate."