# Exact Equations and Integrating Factors

Hi! You should have a rough idea about differential equations and partial derivatives before proceeding!

## 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

In that case it is an "exact equation" and we can proceed.

Then 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.

We can 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 + C1

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

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

and the general solution is:

I(x,y) = C2

or

x3y3 − x5 + y22 = C

(where the constant C replaces the other arbitrary constants C1 and C2)

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 dIdx

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

Using implicit differentiation we get

dIdx = x33y2y' + 3x2y3 − 5x4 + yy'

Simplify

dIdx =  3x2y3 − 5x4 + y'(y +  3x3y2)

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

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

which is our original differential equation.

Hence 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)  ...  (1)

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

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

So g'(x) = 3x2 + 2

And integration yields:

g(x) = x3 + 2x  ...  (2)*

Now we substitute (2) into (1) to obtain the general solution:

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

Solved!

* Note that we didn't have to add the integration constant C1 since it will merge at the last step anyways.

### 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) − xysin(xy) + e2x]dx = 0

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

∂M∂y = −x2ycos(xy) − 2xsin(xy)

N = y2 − x2sin(xy)

∂N∂x = −x2ycos(xy) − 2xsin(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) − xysin(xy) + e2x)dx

= 1ysin(xy) + xcos(xy) − 1ysin(xy) + 12e2x + f(y)

= xcos(xy) + 12e2x + f(y)

Now we evaluate the derivative with respect to y

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

And that is equal to N, so

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

So

f'(y) = y2

f(y) = 13y3

So our general solution is

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

However, we will try to make it exact by multiplying the equation by xmyn

Our equation becomes:

(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

Now we multiply our original differential equation by y−3:

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

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

dIdx = y−1 + g'(x)

And that is equal to M, so

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

Hence,

g'(x) = 3x

g(x) = 32x2

And the substitution gives:

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

which is our general solution!

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

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

The expression

1N[My − Nx]

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

If the above condition is true then we call that expression Z(x) and 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.

But, if we consider the expression

1N[My∂N∂x]

= x − yx(x − y) = 1x

We can tell that it's a function only of x.

So Z(x) = 1x

So our integrating factor will be given by

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 − y2)dx + (x3 − x2y)dy = 0

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

M = 3x2y − y2

∂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 − y2)dx

= x3y − xy2 + f(y)

To find the function f(y) we evaluate

dIdy = x3 − 2xy + f'(y)

And that must be equal to

N = x3 − x2y

So we have

x3 − 2xy + f'(y) = x3 − x2y

So

f'(y) = 2xy − x2y

We integrate to get

f(y) = xy212x2y2

Substituting we get the general solution:

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)dx

And we can continue just like the previous example

And there you have it!