Integrating Factor for First Order ODE

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

be non-homogeneous and not exact.

By Existence of Integrating Factor, if $(1)$ has a general solution, there exists an integrating factor $\mu \left({x, y}\right)$ such that:
 * $\displaystyle \mu \left({x, y}\right) \left({M \left({x, y}\right) + N \left({x, y}\right) \frac {\mathrm d y} {\mathrm d x} }\right) = 0$

is an exact differential equation.

Unfortunately, there is no systematic method of finding such a $\mu \left({x, y}\right)$ for all such equations $(1)$.

However, there are certain types of first order ODE for which an integrating factor can be found procedurally.

Function of x or y only
Suppose that:
 * $\displaystyle g \left({x}\right) = \frac {\frac {\partial M}{\partial y} - \frac {\partial N}{\partial x}}{N}$

is a function of $x$ only.

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

is an integrating factor for $(1)$.

Suppose that:
 * $\displaystyle h \left({y}\right) = \frac {\frac {\partial M}{\partial y} - \frac {\partial N}{\partial x}}{M}$

is a function of $y$ only.

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

is an integrating factor for $(1)$.

Function of x + y
Suppose that:
 * $\displaystyle g \left({z}\right) = \frac {\frac {\partial M}{\partial y} - \frac {\partial N}{\partial x}}{N - M}$

is a function of $z$, where $z = x + y$.

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

is an integrating factor for $(1)$.

Function of xy
Suppose that:
 * $\displaystyle g \left({z}\right) = \frac {\frac {\partial M}{\partial y} - \frac {\partial N}{\partial x}}{N y - M x}$

is a function of $z$, where $z = x y$.

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

is an integrating factor for $(1)$.

Proof
Let us for ease of manipulation express $(1)$ in the form of differentials:
 * $(2) \qquad M \left({x, y}\right) \mathrm d x + N \left({x, y}\right) \mathrm d y = 0$

Now, suppose $\mu$ is an integrating factor for $(2)$.

Then, by definition, $\mu M \left({x, y}\right) \mathrm d x + \mu N \left({x, y}\right) \mathrm d y = 0$ is exact.

By Solution to Exact Differential Equation, we have that:
 * $\displaystyle \frac {\partial \left({\mu M}\right)} {\partial y} = \frac {\partial \left({\mu N}\right)} {\partial x}$

Evaluating this, using the Product Rule, we get:
 * $\displaystyle \mu \frac {\partial M} {\partial y} + M \frac {\partial \mu} {\partial y} = \mu \frac {\partial N} {\partial x} + N \frac {\partial \mu} {\partial x}$

which leads us to:
 * $\displaystyle \frac 1 \mu \left({N \frac {\partial \mu} {\partial x} - M \frac {\partial \mu} {\partial y}}\right) = \frac {\partial M} {\partial y} - \frac {\partial N} {\partial x}$.

Let us use $\displaystyle P \left({x, y}\right)$ for $\frac {\partial M} {\partial y} - \frac {\partial N} {\partial x}$.

Thus we have:
 * $\displaystyle (3) \qquad \frac 1 \mu = \frac {P \left({x, y}\right)} {N \frac {\partial \mu} {\partial x} - M \frac {\partial \mu} {\partial y}}$

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

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

which, when substituting in $(3)$, leads us to:
 * $\displaystyle \frac 1 \mu \frac {\mathrm d \mu} {\mathrm d x} = \frac {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.

That is the proof of necessary condition, we need to proove the sufficient condition

Assume that
 * $\displaystyle  \frac {\frac {\partial M}{\partial y} - \frac {\partial N}{\partial x}}{N} = g \left({x}\right) $

is a function of $x$ only,

and


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

is NOT an integrating factor for $(1)$.

So


 * $\displaystyle \frac {\partial \left({\mu M}\right)} {\partial y} \ne \frac {\partial \left({\mu N}\right)} {\partial x}$


 * $\displaystyle \frac {\partial \left({e^{\int g \left({x}\right) \mathrm d x} M}\right)} {\partial y} \ne \frac {\partial \left({e^{\int g \left({x}\right) \mathrm d x} N}\right)} {\partial x}$


 * $\displaystyle e^{\int g \left({x}\right) \mathrm d x} \frac {\partial {M}} {\partial y} \ne N g \left({x}\right) e^{\int g \left({x}\right) \mathrm d x}  +  e^{\int g \left({x}\right) \mathrm d x} \frac {\partial {N}} {\partial x} $

So
 * $\displaystyle  \frac {\frac {\partial M}{\partial y} - \frac {\partial N}{\partial x}}{N} \ne g \left({x}\right) $

it's a contradiction.

Similarly, if $\mu$ is a function of $y$ only, we find that
 * $\displaystyle \frac 1 \mu \frac {\mathrm d \mu} {\mathrm d y} = \frac {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.

Proof for Function of x + y
Suppose that $\mu$ is a function of $z = x + y$.

Then:
 * $\displaystyle \frac {\partial z} {\partial x} = 1 = \frac {\partial z} {\partial y}$

Thus:
 * $\displaystyle \frac {\partial \mu} {\partial x} = \frac {d \mu} {d z} \frac {\partial z} {\partial x} = \frac {\mathrm d \mu} {\mathrm d z} = \frac {\mathrm d \mu} {\mathrm d z} \frac {\partial z} {\partial y} = \frac {\partial \mu} {\partial y}$

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

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

Proof for Function of x y
Suppose that $\mu$ is a function of $z = x y$.

Then:
 * $\displaystyle \frac {\partial z} {\partial x} = y, \frac {\partial z} {\partial y} = x$.

Thus:
 * $\displaystyle \frac {\partial \mu} {\partial x} = \frac {\mathrm d \mu} {\mathrm d z} \frac {\partial z} {\partial x} = y \frac {\mathrm d \mu} {\mathrm d z}, \frac {\partial \mu} {\partial y} = \frac {\mathrm d \mu} {\mathrm d z} \frac {\partial z} {\partial y} = x \frac {\mathrm d \mu} {\mathrm d z}$

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

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

Final part of proof
We now have four equations of the form:
 * $\displaystyle \frac 1 \mu \frac {\mathrm d \mu} {\mathrm d w} = f \left({w}\right)$

which is what you get when you apply the Chain Rule and Derivative of Logarithm Function to:
 * $\displaystyle \frac {\mathrm d \left({\ln \mu}\right)}{\mathrm d w} = f \left({w}\right)$

Thus:
 * $\displaystyle \ln \mu = \int f \left({w}\right) \mathrm d w$

and so:
 * $\displaystyle \mu = e^{\int f \left({w}\right) \mathrm d w}$

Hence the results as stated.

Technique for finding an Integrating Factor
Suppose, therefore, you were given a differential equation which is in (or can be manipulated into) the form:
 * $\displaystyle M \left({x, y}\right) + N \left({x, y}\right) \frac {\mathrm d y} {\mathrm d x} = 0$

and it was not homogeneous, exact or even linear.

Then what you can do is evaluate:
 * $\displaystyle \frac {\partial M}{\partial y} - \frac {\partial N}{\partial x}$

and see what you get when you divide it by each of $N$, $M$, $N - M$ and $N y - M x$ in turn.

Then examine what you get to see if you have a function in $x$ only, $y$ only, $x + y$ or $xy$ respectively.

If you do, then you have found an integrating factor and can solve the equation by using the technique defined in Solution to Exact Differential Equation.