Integrating Factors

Very few differential equations are exact. So are exact equations worth discussing at all? Yes, because a non-exact equation can often be made exact by multiplying through by a suitable function I ( x , y ) , called an integrating factor. This section shows that such a factor always exists in principle, that it is never unique, and gives two practical formulas that find it in the most common cases.

Quick Reference

Item Statement
Integrating factor I ( x , y ) such that I ( M d x + N d y ) = 0 is exact
Existence Any equation M d x + N d y = 0 with a solution has at least one integrating factor
Uniqueness Never unique. If I works so does k I , and so does I F ( f ) for any function F
Defining condition 1 I ( M I y N I x ) = N x M y
Factor of x alone If 1 N ( M y N x ) = A ( x ) , then I ( x ) = e A ( x ) d x
Factor of y alone If 1 M ( M y N x ) = B ( y ) , then I ( y ) = e B ( y ) d y
Memory aid Divide by N for a factor in x ; divide by M for a factor in y , and flip the sign

A Motivating Example

Consider the following differential equation:

x^2 - y^2 + 2xy\,y' = 0 \qquad \text{or} \qquad x^2 - y^2 + 2xy\frac{dy}{dx} = 0 .

Multiplying both sides by d x , we can rewrite it in the form M d x + N d y = 0 as

( x 2 y 2 ) d x + 2 x y d y = 0 .

Here

M y = 2 y N x = 2 y ,

so this equation is not exact. Now multiply through by the factor 1 / x 2 . The equation becomes

x 2 y 2 x 2 d x + 2 y x d y = 0 .

We know that this equation is exact, since

y ( x 2 y 2 x 2 ) = 2 y x 2 = x ( 2 y x ) .

The factor 1 / x 2 is called an integrating factor.

A function I ( x , y ) is called an integrating factor for the equation M d x + N d y = 0 if the equation

I ( x , y ) { M ( x , y ) d x + N ( x , y ) d y } = 0

is exact.

Multiplying by I does not change the solution curves, as long as I is never zero on the region of interest, because the equation still asserts that the same expression equals zero. What changes is the form, and the new form is one we know how to solve.

Now the question is: when does such an integrating factor exist?

Which Equations Have Integrating Factors?

Suppose f ( x , y ) = c is the general solution of M ( x , y ) d x + N ( x , y ) d y = 0 . Because d f = d c = 0 and

d f = f x d x + f y d y ,

we have

\frac{\partial f}{\partial x}\,dx + \frac{\partial f}{\partial y}\,dy = 0 \quad \Longrightarrow \quad \frac{dy}{dx} = -\frac{\dfrac{\partial f}{\partial x}}{\dfrac{\partial f}{\partial y}} . \tag{i}

It also follows from the equation M ( x , y ) d x + N ( x , y ) d y = 0 that

\frac{dy}{dx} = -\frac{M(x,y)}{N(x,y)} . \tag{ii}

Comparing (i) and (ii),

f x f y = M ( x , y ) N ( x , y )

or, cross-multiplying,

f x M ( x , y ) = f y N ( x , y ) .

Let us denote this common ratio by I ( x , y ) :

f x M = f y N = I ( x , y ) .

Therefore

I ( x , y ) M ( x , y ) = f x , I ( x , y ) N ( x , y ) = f y ,

and consequently

I ( x , y ) M ( x , y ) f / x d x + I ( x , y ) N ( x , y ) f / y d y = d f = 0 .

Any differential equation M d x + N d y = 0 that has a solution possesses at least one integrating factor. Moreover, if the solution is known, the integrating factor can be determined from it directly.

Note carefully what this theorem does and does not give you. It guarantees existence, and it converts a known solution into an integrating factor. It does not tell you how to find the factor when the solution is unknown, which is the situation you are usually in. The rest of this section is about the cases where the factor can be found in advance.

The Integrating Factor Is Not Unique

If I ( x , y ) is an integrating factor for M ( x , y ) d x + N ( x , y ) d y = 0 , then so is k I ( x , y ) for any real constant k , since multiplying an exact equation by a constant leaves it exact.

More generally, if a solution of the equation is f ( x , y ) = c , then I ( x , y ) F ( f ( x , y ) ) is also an integrating factor, where F is an arbitrary function. To see why,

\begin{aligned} I(x,y)F(f)\left[M(x,y)\,dx + N(x,y)\,dy\right] &= F(f)\left[\underbrace{IM}_{\partial f/\partial x}\,dx + \underbrace{IN}_{\partial f/\partial y}\,dy\right] \\ &= F(f)\,df \\ &= d\left[\int F(f)\,df\right] = 0 . \end{aligned}

The last line is the key step: F ( f ) d f is itself a total differential, namely of any antiderivative of F evaluated at f .

If an equation has one integrating factor, then it has infinitely many.

This is good news in practice. You need only find some factor, not the "right" one, and different valid factors lead to solutions that differ only by relabeling the arbitrary constant.

How to Find Integrating Factors

Because I ( x , y ) M ( x , y ) d x + I ( x , y ) N ( x , y ) d y = 0 is exact, the exactness test applied to the new coefficients gives

y [ I ( x , y ) M ( x , y ) ] = x [ I ( x , y ) N ( x , y ) ] .

Expanding both sides with the product rule,

\begin{aligned} M\frac{\partial I}{\partial y} + I\frac{\partial M}{\partial y} &= N\frac{\partial I}{\partial x} + I\frac{\partial N}{\partial x} \\ \Longrightarrow \quad \frac{1}{I}\left(M\frac{\partial I}{\partial y} - N\frac{\partial I}{\partial x}\right) &= \frac{\partial N}{\partial x} - \frac{\partial M}{\partial y} \end{aligned} \tag{7}

This is a partial differential equation for I , which looks more complicated than the original equation we set out to solve. That is the honest situation: finding integrating factors in general is harder than the problem it was meant to simplify. What saves the method is that a few special assumptions collapse (7) into something easy.

When the Integrating Factor Depends on x or y Alone

Assume I is a function of x alone. Then I y = 0 and I x = d I d x , so (7) reduces to

1 I ( x ) d I d x = M y N x N .

Because the left-hand side is a function of x alone, the right-hand side must be a function of x alone as well. This gives a usable test. Let

M y N x N = A ( x ) ,

then

1 I ( x ) d I d x = A ( x ) or d I I = A ( x ) d x .

Integrating,

d I I = ln I ( x ) = A ( x ) d x

\therefore \quad I(x) = e^{\int A(x)\,dx} \tag{8}

The argument is reversible: if ( y M x N ) / N turns out to be a function of x alone, then I ( x ) given by (8) really is an integrating factor for M d x + N d y = 0 .

Similarly, if ( y M x N ) / M = B ( y ) is a function of y alone, then I ( y ) = exp ( B ( y ) d y ) .

The two working formulas.



If 1 N ( M y N x ) = A ( x ) depends only on x , then

I ( x ) = e A ( x ) d x .

If 1 M ( M y N x ) = B ( y ) depends only on y , then

I ( y ) = e B ( y ) d y .

In words: form the difference y M x N once. Divide it by N and check whether the y variables cancel; if so, exponentiate the integral. If not, divide the same difference by M and check whether the x variables cancel; if so, exponentiate minus the integral. The sign difference between the two formulas is the detail most often forgotten.

Worked Examples

Find an integrating factor for ( x 2 y 2 ) d x + 2 x y d y = 0 .

Solution

Here M = x 2 y 2 and N = 2 x y , so y M = 2 y and x N = 2 y . Testing the first formula,

y M x N N = 2 y 2 y 2 x y = 4 y 2 x y = 2 x ,

which is a function of x only. According to formula (8), an integrating factor is

\begin{aligned} I(x) &= \exp\left(\int -\frac{2}{x}\,dx\right) \\ &= \exp\left(-2\ln|x|\right) \\ &= \exp\left(\ln\frac{1}{x^2}\right) \qquad \text{(recall } y\ln x = \ln x^{y}\text{)} \\ &= \frac{1}{x^2} . \end{aligned}

This confirms the factor guessed at the start of the section.

Find an integrating factor for e x ( x + 1 ) d x + ( y e y x e x ) d y = 0 and solve the equation.

Solution

Here

M = e x ( 1 + x ) , N = y e y x e x

so

y M = 0 , x N = e x x e x = e x ( x + 1 ) .

Try the x -only formula first: dividing by N would leave y terms behind, so it fails. Try the y -only formula:

y M x N M = 0 + e x ( x + 1 ) e x ( x + 1 ) = 1 = B ( y ) ,

a constant, which certainly qualifies as a function of y alone.

The integrating factor is

I ( y ) = e 1 d y = e y .

Now multiply the equation by e y :

e y e x ( x + 1 ) d x + e y ( y e y x e x ) d y = 0

and since e y y e y = y ,

e y e x ( x + 1 ) d x + ( y x e x e y ) d y = 0 .

You can verify that this equation is exact. Suppose f ( x , y ) = c is the general solution. Then

f x = x e x e y + e x e y

so

\begin{aligned} f(x,y) &= \int e^{-y}e^{x}(x+1)\,dx + g(y) \\ &= e^{-y}\int \frac{d}{dx}\left(x e^{x}\right)dx + g(y) \\ &= x e^{-y}e^{x} + g(y) \end{aligned}

where g ( y ) is the "constant" of integration. The middle step used the observation that d d x ( x e x ) = e x + x e x = e x ( x + 1 ) , which is exactly the integrand; integration by parts gives the same result.

Now impose f y = N :

-x e^{-y}e^{x} + g'(y) = y - x e^{-y}e^{x} \quad \Longrightarrow \quad g'(y) = y \quad \Longrightarrow \quad g(y) = \frac{1}{2}y^2 .

Therefore the general solution of this differential equation is

f ( x , y ) = x e y e x + 1 2 y 2 = c .

Exercises

Find an integrating factor for ( 2 y 2 + 3 x ) d x + 2 x y d y = 0 and solve.

Solution

With M = 2 y 2 + 3 x and N = 2 x y , we get y M = 4 y and x N = 2 y , so the equation is not exact.

y M x N N = 4 y 2 y 2 x y = 2 y 2 x y = 1 x ,

a function of x alone. So I ( x ) = e d x / x = e ln | x | = x .

Multiplying through, ( 2 x y 2 + 3 x 2 ) d x + 2 x 2 y d y = 0 . Now y ( 2 x y 2 + 3 x 2 ) = 4 x y = x ( 2 x 2 y ) , confirming exactness.

Integrating the new M in x : f = x 2 y 2 + x 3 + g ( y ) . Then \partial f/\partial y = 2x^2 y + g'(y), matching N gives g'(y) = 0.

The general solution is x 2 y 2 + x 3 = C .

Find an integrating factor for y d x + ( 2 x y e y ) d y = 0 and solve.

Solution

With M = y and N = 2 x y e y , we get y M = 1 and x N = 2 .

y M x N N = 1 2 x y e y ,

which still contains y , so no factor of x alone. Try the other formula:

y M x N M = 1 2 y = 1 y = B ( y ) .

Therefore

I ( y ) = e ( 1 / y ) d y = e ln | y | = y .

Multiplying, y 2 d x + ( 2 x y y 2 e y ) d y = 0 , which satisfies y ( y 2 ) = 2 y = x ( 2 x y y 2 e y ) .

Integrating in x : f = x y 2 + g ( y ) , so \partial f/\partial y = 2xy + g'(y) = 2xy - y^2 e^{y}, giving g'(y) = -y^2 e^{y}. Integrating by parts twice,

y 2 e y d y = y 2 e y 2 y e y + 2 e y ,

so g ( y ) = e y ( y 2 2 y + 2 ) .

The general solution is x y 2 e y ( y 2 2 y + 2 ) = C .

Verify directly that if I is an integrating factor, so is 2 I . Why does this not give a genuinely different solution?

Solution

If I ( M d x + N d y ) = d f for some f , then 2 I ( M d x + N d y ) = 2 d f = d ( 2 f ) , which is again a total differential, so 2 I is an integrating factor with potential function 2 f .

The solution it produces is 2 f ( x , y ) = C , that is, f ( x , y ) = C / 2 . Since C is arbitrary, so is C / 2 , and the family of solution curves is identical. Different integrating factors relabel the constant, not the curves.

Frequently Asked Questions

What is an integrating factor?

It is a function I ( x , y ) that you multiply an equation by to make it exact. The original equation M d x + N d y = 0 fails the test M / y = N / x ; the new equation I M d x + I N d y = 0 passes it, and has the same solution curves.


Does every equation have an integrating factor?

Every equation that has a solution has one, and in fact infinitely many. But the theorem giving this is not constructive: the proof builds the factor out of the solution, which is what you were trying to find. In practice you rely on the two special formulas, on recognizable patterns, or on inspection.


Why does making the equation exact not change the solutions?

Because both equations say that the same quantity equals zero. If M d x + N d y = 0 then multiplying by any nonzero I preserves the equality. The caveat is the word nonzero: on a curve where I vanishes, the multiplied equation is satisfied trivially, so spurious solutions can be introduced there and should be checked.


How do I decide which of the two formulas to try?

Compute the difference y M x N once, then test both quotients. Divide by N : if the result is free of y , use I ( x ) = e A d x . Divide by M : if the result is free of x , use I ( y ) = e B d y . If neither quotient simplifies, these two methods do not apply and you need a different form of factor.


Why does the y formula have a minus sign in the exponent?

It comes from the position of the terms in the general condition (7). Setting I / x = 0 leaves M I d I d y = x N y M , and dividing by M puts the negative of B ( y ) on the right. The asymmetry is real, and reversing the sign is the most common error in these problems.


What if neither formula works?

Try a factor of the form x a y b and solve for the exponents that force exactness, which handles many equations built from monomials. Some equations respond to a factor depending on the combination x y or x + y . And a handful of expressions are worth memorizing on sight: y d x x d y y 2 = d ( x y ) and y d x x d y x 2 + y 2 = d ( arctan x y ) appear constantly.


Is the linear equation y' + P(x)y = Q(x) related to this?

Directly. In differential form it reads ( P ( x ) y Q ( x ) ) d x + d y = 0 , and the first formula gives A ( x ) = P ( x ) , hence I ( x ) = e P d x . That is exactly the integrating factor derived in the next section. Linear equations are the single most important family for which the x -only formula always succeeds.