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

\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}

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

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

We can 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_{1}

We have f(y) ... !

Now just put it in place:

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

and the general solution is:

I(x,y) = C_{2}

or

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

(where the constant C replaces the other arbitrary constants C_{1} and C_{2})

Evaluate \frac{dI}{dx}

Start with:

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

Using implicit differentiation we get

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

Simplify

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

We use the facts that y' = \frac{dy}{dx}, \frac{dI}{dx} = 0, and 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) ... (1)

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

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

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

And integration yields:

g(x) = x^{3} +
2x ... (2)*

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

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

**Solved!**

_{1}since it will merge at the last step anyway.

**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) − xysin(xy) + e^{2x}]dx = 0

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

\frac{∂M}{∂y} = −x^{2}ycos(xy) − 2xsin(xy)

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

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

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

= xcos(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, so

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

So

f'(y) = y^{2}

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

So our general solution is

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}

However, we will try to *make it exact* by multiplying the
equation by** x ^{m}y^{n}**

Our equation becomes:

(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}

Now we multiply our original differential equation by ** y ^{−3}**:

y^{−3}[(y^{2} + 3xy^{3})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

\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{dI}{dx} = y^{−1} + g'(x)

And that is equal to M, so

y^{−1} + 3x = y^{−1} + g'(x)

Hence,

g'(x) = 3x

g(x) = \frac{3}{2}x^{2}

And the substitution gives:

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

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

\frac{1}{N}[M_{y} − N_{x}]

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) = 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.

But, if we consider the expression

\frac{1}{N}[M_{y} −\frac{∂N}{∂x}]

= \frac{x − y}{x(x − y)} = \frac{1}{x}

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) = 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 − y^{2})dx
+ (x^{3} − x^{2}y)dy = 0

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

M = 3x^{2}y − y^{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 − y^{2})dx

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

To find the function f(y) we evaluate

\frac{dI}{dy} = x^{3} − 2xy + f'(y)

And that must be equal to

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

So we have

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

So

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

We integrate to get

f(y) = xy^{2} − \frac{1}{2}x^{2}y^{2}

Substituting we get the general solution:

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!