Integrating Factor for First Order ODE/Function of One Variable

Theorem
Let the first order ordinary differential equation:
 * $(1): \quad M \left({x, y}\right) + N \left({x, y}\right) \dfrac {\mathrm d y} {\mathrm d x} = 0$

be non-homogeneous and not exact.

Suppose that:
 * $g \left({x}\right) = \dfrac {\dfrac {\partial M} {\partial y} - \dfrac {\partial N} {\partial x} } {N \left({x, y}\right)}$

is a function of $x$ only.

Then:
 * $\mu \left({x}\right) = e^{\int g \left({x}\right) \mathrm d x}$

is an integrating factor for $(1)$.

Similarly, suppose that:
 * $h \left({y}\right) = \dfrac {\dfrac {\partial M} {\partial y} - \dfrac {\partial N} {\partial x} } {M \left({x, y}\right)}$

is a function of $y$ only.

Then:
 * $\mu \left({y}\right) = e^{\int -h \left({y}\right) \mathrm d y}$

is an integrating factor for $(1)$.

Proof for Function of $x$ or $y$ only
Suppose that $\mu$ is a function of $x$ only.

Then:
 * $\dfrac {\partial \mu} {\partial x} = \dfrac {d \mu} {d x}, \dfrac {\partial \mu} {\partial y} = 0$

which, when substituting in $(3)$, leads us to:
 * $\dfrac 1 \mu \dfrac {\mathrm d \mu} {\mathrm d x} = \dfrac {P \left({x, y}\right)} {N \left({x, y}\right)} = g \left({x}\right)$

where $g \left({x}\right)$ is the function of $x$ that we posited.

Similarly, if $\mu$ is a function of $y$ only, we find that
 * $\dfrac 1 \mu \dfrac {\mathrm d \mu} {\mathrm d y} = \dfrac {P \left({x, y}\right)} {-M \left({x, y}\right)} = h \left({y}\right)$

where $h \left({y}\right)$ is the function of $y$ that we posited.