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

\frac{∂I}{∂x}dx + \frac{∂I}{∂y}dy = 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:

\frac{∂M}{∂y} = \frac{∂^{2}I}{∂y ∂x}

\frac{∂N}{∂x} = \frac{∂^{2}I}{∂y ∂x}

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

\frac{∂M}{∂y} = \frac{∂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

(3x^{2}y^{3} − 5x^{4}) dx + (y + 3x^{3}y^{2}) dy = 0

In this case we have:

- M(x, y) = 3x
^{2}y^{3}− 5x^{4} - N(x, y) = y + 3x
^{3}y^{2}

We evaluate the partial derivatives to check for exactness.

- \frac{∂M}{∂y} = 9x
^{2}y^{2} - \frac{∂N}{∂x} = 9x
^{2}y^{2}

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

= ∫(3x^{2}y^{3} − 5x^{4}) dx

= x^{3}y^{3} − x^{5} +* 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 \frac{∂I}{∂y}, so:

\frac{∂I}{∂y} = N(x, y)

Which gets us:

3x^{3}y^{2} + \frac{df}{dy} = y + 3x^{3}y^{2}

Cancelling terms:

\frac{df}{dy} = y

Integrating both sides:

f(y) = \frac{y^{2}}{2} + C

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

I(x, y) = x^{3}y^{3} − x^{5} + \frac{y^{2}}{2} + 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 C_{1} and C_{2} and then roll them into a new C below by saying C=C_{1}+C_{2}

So we get:

x^{3}y^{3} − x^{5} + \frac{y^{2}}{2} = 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 \frac{∂I}{∂x}

Start with:

I(x, y) = x^{3}y^{3} − x^{5} + \frac{y^{2}}{2}

Using implicit differentiation we get

\frac{∂I}{∂x} = x^{3}3y^{2}y'
+ 3x^{2}y^{3} − 5x^{4} + yy'

Simplify

\frac{∂I}{∂x} = 3x^{2}y^{3} − 5x^{4} + y'(y + 3x^{3}y^{2})

We use the facts that y' = \frac{dy}{dx} and \frac{∂I}{∂x} = 0, then multiply everything by dx to finally get:

(y + 3x^{3}y^{2})dy
+ (3x^{2}y^{3} − 5x^{4})dx =
0

which is our original differential equation.

And so we know our solution is correct.

**Example 2:** Solve

(3x^{2} − 2xy + 2)dx + (6y^{2} − x^{2} + 3)dy = 0

- M = 3x
^{2}− 2xy + 2 - N = 6y
^{2}− x^{2}+ 3

So:

- \frac{∂M}{∂y} = −2x
- \frac{∂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) = ∫(6y^{2} − x^{2} + 3)dy

I(x, y) = 2y^{3} − x^{2}y
+ 3y + g(x) (equation 1)

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

\frac{∂I}{∂x} = M(x, y)

0 − 2xy + 0 + g'(x) = 3x^{2} − 2xy + 2

−2xy + g'(x) = 3x^{2} − 2xy + 2

g'(x) = 3x^{2} + 2

And integration yields:

g(x) = x^{3} +
2x + C (equation 2)

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

I(x, y) = 2y^{3} − x^{2}y + 3y + x^{3} + 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=C_{1}+C_{2}) we get:

2y^{3} − x^{2}y + 3y + x^{3} + 2x = C

**Solved!**

**Example 3:** Solve

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

We have:

M = (xcos(y) − y)dx

\frac{∂M}{∂y} = −xsin(y) − 1

N = (xsin(y) + x)dy

\frac{∂N}{∂x} = sin(y) +1

Thus

\frac{∂M}{∂y} ≠ \frac{∂N}{∂x}

**So this equation is not exact!**

**Example 4:** Solve

[y^{2} − x^{2}sin(xy)]dy +
[cos(xy) − xy sin(xy) + e^{2x}]dx = 0

M = cos(xy) − xy sin(xy) + e^{2x}

\frac{∂M}{∂y} = −x^{2}y cos(xy) − 2x sin(xy)

N = y^{2} − x^{2}sin(xy)

\frac{∂N}{∂x} = −x^{2}y 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) + e^{2x})dx

Using Integration by Parts we get:

I(x, y) = \frac{1}{y}sin(xy) +
x cos(xy) − \frac{1}{y}sin(xy)
+ \frac{1}{2}e^{2x} + f(y)

I(x, y) = x cos(xy) + \frac{1}{2}e^{2x} + f(y)

Now we evaluate the derivative with respect to y

\frac{∂I}{∂y} =
−x^{2}sin(xy) + f'(y)

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

\frac{∂I}{∂y} = N(x, y)

−x^{2}sin(xy) +
f'(y) = y^{2} − x^{2}sin(xy)

f'(y) = y^{2} − x^{2}sin(xy) + x^{2}sin(xy)

f'(y) = y^{2}

f(y) = \frac{1}{3}y^{3}

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

xcos(xy) + \frac{1}{2}e^{2x} + \frac{1}{3}y^{3} = 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

**u(x, y) = x**^{m}y^{n}**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 ...

### Integrating Factors using u(x, y) = x^{m}y^{n}

**Example 5:** (y^{2} + 3xy^{3})dx + (1 −
xy)dy = 0

M = y^{2} + 3xy^{3}

\frac{∂M}{∂y} = 2y + 9xy^{2}

N = 1 − xy

\frac{∂N}{∂x} = −y

So it's clear that \frac{∂M}{∂y} ≠ \frac{∂N}{∂x}

But we can try to *make it exact* by multiplying each part of the
equation by** x ^{m}y^{n}**:

^{m}y

^{n}y

^{2}+ x

^{m}y

^{n}3xy

^{3}) dx + (x

^{m}y

^{n}− x

^{m}y

^{n}xy) dy = 0

Which "simplifies" to:

(x^{m}y^{n+2} + 3x^{m+1}y^{n+3})dx
+ (x^{m}y^{n} − x^{m+1}y^{n+1})dy =
0

And now we have:

M = x^{m}y^{n+2} + 3x^{m+1}y^{n+3}

\frac{∂M}{∂y} = (n + 2)x^{m}y^{n+1} + 3(n + 3)x^{m+1}y^{n+2}

N = x^{m}y^{n} − x^{m+1}y^{n+1}

\frac{∂N}{∂x} = mx^{m−1}y^{n} − (m + 1)x^{m}y^{n+1}

And we **want** \frac{∂M}{∂y} = \frac{∂N}{∂x}

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

Set them equal:

(n + 2)x^{m}y^{n+1} + 3(n + 3)x^{m+1}y^{n+2} = mx^{m−1}y^{n} − (m + 1)x^{m}y^{n+1}

Re-order and simplify:

[(m + 1) + (n + 2)]x^{m}y^{n+1} + 3(n + 3)x^{m+1}y^{n+2} − mx^{m−1}y^{n} = 0

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

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

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

And the result is:

x^{m}y^{n} =
y^{−3}

We now know to multiply our original differential equation by **y ^{−3}**:

^{−3}y

^{2}+ y

^{−3}3xy

^{3}) dx + (y

^{−3}− y

^{−3}xy) 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

\frac{∂M}{∂y} = −y^{−2}

N = y^{−3} − xy^{−2}

\frac{∂N}{∂x} = −y^{−2}

\frac{∂M}{∂y} = \frac{∂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) = \frac{−1}{2}y^{−2} + xy^{−1} + g(x)

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

\frac{∂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) = \frac{3}{2}x^{2}

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

\frac{−1}{2}y^{−2} + xy^{−1} + \frac{3}{2}x^{2} = C

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

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

The expression:

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) = e^{∫Z(x)dx}

Let's try an example:

**Example 6:** (3xy − y^{2})dx + x(x − y)dy = 0

M = 3xy − y^{2}

\frac{∂M}{∂y} = 3x − 2y

N = x(x − y)

\frac{∂N}{∂x} = 2x − y

\frac{∂M}{∂y} ≠ \frac{∂N}{∂x}

So, our equation is**not**exact.

Let us work out Z(x):

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

So our **integrating factor** is

u(x) = e^{∫Z(x)dx}

= e^{∫(1/x)dx}

= e^{ln(x)}

= **x**

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

x[(3xy − y^{2})dx +
x(x − y)dy = 0]

and we get

(3x^{2}y − xy^{2})dx
+ (x^{3} − x^{2}y)dy = 0

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

M = 3x^{2}y − xy^{2}

\frac{∂M}{∂y} = 3x^{2} − 2xy

N = x^{3} − x^{2}y

\frac{∂N}{∂x} = 3x^{2} − 2xy

\frac{∂M}{∂y} = \frac{∂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

= ∫(3x^{2}y − xy^{2})dx

= x^{3}y − \frac{1}{2}x^{2}y^{2} + c_{1}

x^{3}y − \frac{1}{2}x^{2}y^{2} + c_{1} = c

Combine the constants:

x^{3}y − \frac{1}{2}x^{2}y^{2} = 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

\frac{1}{M}[\frac{∂N}{∂x}−\frac{∂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) = e^{∫Z(y)dy}

And we can continue just like the previous example

And there you have it!