# Exact Equations and Integrating Factors

Hi! You might like to learn about differential equations and partial derivatives first!

## Exact Equation

An "exact" equation is where a first-order differential equation like this:

M(x, y)dx + N(x, y)dy = 0

has some special function I(x, y) whose partial derivatives can be put in place of M and N like this:

∂I∂xdx + ∂I∂ydy = 0

and our job is to find that magical function I(x, y) if it exists.

### We can know at the start if it is an exact equation or not!

Imagine we do these further partial derivatives:

∂M∂y = 2I∂y ∂x

∂N∂x = 2I∂y ∂x

they end up the same! And so this will be true:

∂M∂y = ∂N∂x

When it is true we have an an "exact equation" and we can proceed.

And to discover I(x, y) we do EITHER:

• I(x, y) = M(x, y) dx (with x as an independent variable), OR
• I(x, y) = N(x, y) dy (with y as an independent variable)

And then there is some extra work (we will show you) to arrive at the general solution

I(x, y) = C

Let's see it in action.

### Example 1: Solve

(3x2y3 − 5x4) dx + (y + 3x3y2) dy = 0

In this case we have:

• M(x, y) = 3x2y3 − 5x4
• N(x, y) = y + 3x3y2

We evaluate the partial derivatives to check for exactness.

• ∂M∂y = 9x2y2
• ∂N∂x = 9x2y2

They are the same! So our equation is exact.

We can proceed.

Now we want to discover I(x, y)

Let's do the integration with x as an independent variable:

I(x, y) = M(x, y) dx

= (3x2y3 − 5x4) dx

= x3y3 − x5 + f(y)

Note: f(y) is our version of the constant of integration "C" because (due to the partial derivative) we had y as a fixed parameter that we know is really a variable.

So now we need to discover f(y)

At the very start of this page we said that N(x, y) can be replaced by ∂I∂y, so:

∂I∂y = N(x, y)

Which gets us:

3x3y2 + dfdy = y + 3x3y2

Cancelling terms:

dfdy = y

Integrating both sides:

f(y) = y22 + C

We have f(y). Now just put it in place:

I(x, y) = x3y3 − x5 + y22 + C

and the general solution (as mentioned before this example) is:

I(x, y) = C

Ooops! That "C" can be a different value to the "C" just before. But they both mean "any constant", so let's call them C1 and C2 and then roll them into a new C below by saying C=C1+C2

So we get:

x3y3 − x5 + y22 = C

And that's how this method works!

Since that was our first example, let's go further and make sure our solution is correct.

Let's derive I(x, y) with respect to x, that is:

Evaluate ∂I∂x

I(x, y) = x3y3 − x5 + y22

Using implicit differentiation we get

∂I∂x = x33y2y' + 3x2y3 − 5x4 + yy'

Simplify

∂I∂x =  3x2y3 − 5x4 + y'(y +  3x3y2)

We use the facts that y' = dydx and ∂I∂x = 0, then multiply everything by dx to finally get:

(y +  3x3y2)dy + (3x2y3 − 5x4)dx = 0

which is our original differential equation.

And so we know our solution is correct.

### Example 2: Solve

(3x2 − 2xy + 2)dx + (6y2 − x2 + 3)dy = 0

• M = 3x2 − 2xy + 2
• N = 6y2 − x2 + 3

So:

• ∂M∂y = −2x
• ∂N∂x = −2x

The equation is exact!

Now we are going to find the function I(x, y)

This time let's try I(x, y) = N(x, y)dy

So I(x, y) = (6y2 − x2 + 3)dy

I(x, y) = 2y3 − x2y + 3y + g(x)    (equation 1)

Now we differentiate I(x, y) with respect to x and set that equal to M:

∂I∂x = M(x, y)

0 − 2xy + 0 + g'(x) = 3x2 − 2xy + 2

−2xy + g'(x) = 3x2 − 2xy + 2

g'(x) = 3x2 + 2

And integration yields:

g(x) = x3 + 2x + C     (equation 2)

Now we can replace the g(x) in equation 2 in equation 1:

I(x, y) = 2y3 − x2y + 3y + x3 + 2x + C

And the general solution is of the form

I(x, y) = C

and so (remembering that the previous two "C"s are different constants that can be rolled into one by using C=C1+C2) we get:

2y3 − x2y + 3y + x3 + 2x = C

Solved!

### Example 3: Solve

(xcos(y) − y)dx + (xsin(y) + x)dy = 0

We have:

M = (xcos(y) − y)dx

∂M∂y = −xsin(y) − 1

N = (xsin(y) + x)dy

∂N∂x = sin(y) +1

Thus

∂M∂y∂N∂x

So this equation is not exact!

### Example 4: Solve

[y2 − x2sin(xy)]dy + [cos(xy) − xy sin(xy) + e2x]dx = 0

M = cos(xy) − xy sin(xy) + e2x

∂M∂y = −x2y cos(xy) − 2x sin(xy)

N = y2 − x2sin(xy)

∂N∂x = −x2y cos(xy) − 2x sin(xy)

They are the same! So our equation is exact.

This time we will evaluate I(x, y) = M(x, y)dx

I(x, y) = (cos(xy) − xy sin(xy) + e2x)dx

Using Integration by Parts we get:

I(x, y) = 1ysin(xy) + x cos(xy) − 1ysin(xy) + 12e2x + f(y)

I(x, y) = x cos(xy) + 12e2x + f(y)

Now we evaluate the derivative with respect to y

∂I∂y = −x2sin(xy) + f'(y)

And that is equal to N, that equal to M:

∂I∂y = N(x, y)

−x2sin(xy) + f'(y) = y2 − x2sin(xy)

f'(y) = y2 − x2sin(xy) + x2sin(xy)

f'(y) = y2

f(y) = 13y3

So our general solution of I(x, y) = C becomes:

xcos(xy) + 12e2x + 13y3 = C

Done!

## Integrating Factors

Some equations that are not exact may be multiplied by some factor, a function u(x, y), to make them exact.

When this function u(x, y) exists it is called an integrating factor. It will make valid the following expression:

∂(u·N(x, y))∂x = ∂(u·M(x, y))∂y

There are some special cases:

• u(x, y) = xmyn
• u(x, y) = u(x) (that is, u is a function only of x)
• u(x, y) = u(y) (that is, u is a function only of y)

Let's look at those cases ...

### Example 5:(y2 + 3xy3)dx + (1 − xy)dy = 0

M = y2 + 3xy3

∂M∂y = 2y + 9xy2

N = 1 − xy

∂N∂x = −y

So it's clear that ∂M∂y∂N∂x

But we can try to make it exact by multiplying each part of the equation by xmyn:

(xmyny2 + xmyn3xy3) dx + (xmyn − xmynxy) dy = 0

Which "simplifies" to:

(xmyn+2 + 3xm+1yn+3)dx + (xmyn − xm+1yn+1)dy = 0

And now we have:

M = xmyn+2 + 3xm+1yn+3

∂M∂y = (n + 2)xmyn+1 + 3(n + 3)xm+1yn+2

N = xmyn − xm+1yn+1

∂N∂x = mxm−1yn − (m + 1)xmyn+1

And we want ∂M∂y = ∂N∂x

So let's choose the right values of m and n to make the equation exact.

Set them equal:

(n + 2)xmyn+1 + 3(n + 3)xm+1yn+2 = mxm−1yn − (m + 1)xmyn+1

Re-order and simplify:

[(m + 1) + (n + 2)]xmyn+1 + 3(n + 3)xm+1yn+2 − mxm−1yn = 0

For it to be equal to zero, every coefficient must be equal to zero, so:

1. (m + 1) + (n + 2) = 0
2. 3(n + 3) = 0
3. m = 0

That last one, m = 0, is a big help! With m=0 we can figure that n = −3

And the result is:

xmyn = y−3

We now know to multiply our original differential equation by y−3:

(y−3y2 + y−33xy3) dx + (y−3 − y−3xy) dy

Which becomes:

(y−1 + 3x)dx + (y−3 − xy−2)dy = 0

And this new equation should be exact, but let's check again:

M = y−1 + 3x

∂M∂y = −y−2

N = y−3 − xy−2

∂N∂x = −y−2

∂M∂y = ∂N∂x

They are the same! Our equation is now exact!

So let's continue:

I(x, y) = N(x, y)dy

I(x, y) = (y−3 − xy−2)dy

I(x, y) = −12y−2 + xy−1 + g(x)

Now, to determine the function g(x) we evaluate

∂I∂x = y−1 + g'(x)

And that equals M = y−1 + 3x, so:

y−1 + g'(x) = y−1 + 3x

And so:

g'(x) = 3x

g(x) = 32x2

So our general solution of I(x, y) = C is:

−12y−2 + xy−1 + 32x2 = C

### Integrating Factors using u(x, y) = u(x)

For u(x, y) = u(x) we must check for this important condition:

The expression:

Z(x) = 1N [∂M∂y∂N∂x]

must not have the y term, so that the integrating factor is only a function of x

If the above condition is true then our integrating factor is:

u(x) = eZ(x)dx

Let's try an example:

### Example 6: (3xy − y2)dx + x(x − y)dy = 0

M = 3xy − y2

∂M∂y = 3x − 2y

N = x(x − y)

∂N∂x = 2x − y

∂M∂y∂N∂x

So, our equation is not exact.

Let us work out Z(x):
Z(x) = 1N [∂M∂y∂N∂x ]
= 1N [ 3x−2y − (2x−y) ]
= x−yx(x−y)
= 1x

So Z(x) is a function only of x, yay!

So our integrating factor is

u(x) = eZ(x)dx

= e(1/x)dx

= eln(x)

= x

Now that we found the integrating factor, let's multiply the differential equation by it.

x[(3xy − y2)dx + x(x − y)dy = 0]

and we get

(3x2y − xy2)dx + (x3 − x2y)dy = 0

It should now be exact. Let's test it:

M = 3x2y − xy2

∂M∂y = 3x2 − 2xy

N = x3 − x2y

∂N∂x = 3x2 − 2xy

∂M∂y = ∂N∂x

So our equation is exact!

Now we solve in the same way as the previous examples.

I(x, y) = M(x, y)dx

= (3x2y − xy2)dx

= x3y − 12x2y2 + c1

And we get the general solution I(x, y) = c :

x3y − 12x2y2 + c1 = c

Combine the constants:

x3y − 12x2y2 = c

Solved!

### Integrating Factors using u(x, y) = u(y)

u(x, y) = u(y) is very similar to the previous case u(x, y) = u(x)

So, in a similar way, we have:

The expression

1M[∂N∂x∂M∂y]

must not have the x term in order for the integrating factor to be a function of only y.

And if that condition is true, we call that expression Z(y) and our integrating factor is

u(y) = eZ(y)dy

And we can continue just like the previous example

And there you have it!