Solution to Linear First Order Ordinary Differential Equation

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

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

Proof
Consider the first order ordinary differential equation:


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

We can put our equation:
 * $(1) \qquad \dfrac {dy}{dx} + 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) dx} \dfrac {dy}{dx} + e^{\int P \left({x}\right) dx} P \left({x}\right) y = e^{\int P \left({x}\right) dx} 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 d {dx} \left({e^{\int P \left({x}\right) dx} y}\right) = e^{\int P \left({x}\right) dx} \dfrac {dy}{dx} + y e^{\int P \left({x}\right) dx} P \left({x}\right) = e^{\int P \left({x}\right) dx} \left({\dfrac {dy}{dx} + P \left({x}\right) y}\right)$

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

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

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

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) dx}$ and integrate."