Solution to Linear First Order Ordinary Differential Equation

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

has the general solution:
 * $$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) \frac {dy} {dx} = 0$$

We can put our equation:
 * $$(1) \qquad \frac {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:
 * $$\frac {\partial M}{\partial y} - \frac {\partial N}{\partial x} = P \left({x}\right)$$

and hence:
 * $$P \left({x}\right) = \frac {\frac {\partial M}{\partial y} - \frac {\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} \frac {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, we merely need to note that:
 * $$\frac d {dx} \left({e^{\int P \left({x}\right) dx} y}\right) = e^{\int P \left({x}\right) dx} \frac {dy}{dx} + y e^{\int P \left({x}\right) dx} P \left({x}\right) = e^{\int P \left({x}\right) dx} \left({\frac {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:
 * $$\frac 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:
 * $$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."