# 2.7: Exact Differential Equations

Consider the equation

\[ f(x,y) = C. \]

Taking the gradient we get

\[ f_x(x,y)\hat{\textbf{i}} + f_y(x,y)\hat{\textbf{j}} = 0.\]

We can write this equation in differential form as

\[ f_x(x,y)\, dx+ f_y(x,y)\, dy = 0.\]

Now divide by \( dx \) (we are not pretending to be rigorous here) to get

\[ f_x(x,y)+ f_y(x,y) \dfrac{dy}{dx} = 0.\]

Which is a first order differential equation. The goal of this section is to go backward. That is if a differential equation if of the form above, we seek the original function \(f(x,y)\) (called a ** potential function**). A differential equation with a potential function is called

**. If you have had vector calculus, this is the same as finding the potential functions and using the fundamental theorem of line integrals.**

*exact*Example \(\PageIndex{1}\)

Solve

\[ 4xy + 1 + (2x^2 + \cos y)y' = 0. \]

**Solution**

We seek a function \(f(x,y)\) with

\[ f_x(x,y) = 4xy + 1 \]

and

\[ f_y(x,y) = 2x^2 + \cos y. \]

Integrate the first equation with respect to \(x\) to get

\[ f(x,y) = 2x^2y + x + C(y) . \]

Notice since \(y\) is treated as a constant, we write \(C(y)\). Now take the partial derivative with respect to \(y\) to get

\[ f_y(x,y) = 2x^2 + C'(y) .\]

We have two formulae for \( f_y(x,y) \) so we can set them equal to each other.

\[ 2x^2 + \cos y = 2x^2 + C'(y) \]

That is

\[ C'(y) = \cos\, y \]

or

\[ C(y) = \sin \, y .\]

Hence

\[ f(x,y) = 2x^2y + x + \sin \, y. \]

The solution to the differential equation is

\[ 2x^2y + x + \sin \, y = C. \]

Does this method always work? The answer is no. We can tell if the method works by remembering that for a function with continuous partial derivatives, the mixed partials are order independent. That is

\[ f_{xy} = f_{yx} .\]

If we have the differential equation

\[ M(x,y) + N(x,y)y' = 0 \]

then we say it is an *exact differential equation* if

\[ M_y(x,y) = N_x(x,y) . \]

Theorem (Solutions to Exact Differential Equations)

Let \(M\), \(N\), \(M_y\), and \(N_x\) be continuous with

\[ M_y = N_x.\]

Then there is a function \(f(x,y)\) with

\( f_x = M \) and \( f_y = N \)

such that

\[ f(x,y) = C \]

is a solution to the differential equation

\[ M(x,y) + N(x,y)y' = 0 .\]

Example \(\PageIndex{2}\)

Solve the differential equation

\[ y + (2xy - e^{-2y})y' = 0 . \]

**Solution**

We have

\[ M(x,y) = y\]

and

\[N(x,y) = 2xy - e^{-2y}. \]

Now calculate

\[ M_y = 1 \;\;\; \text{and} \;\;\; N_x = 2y. \]

Since they are not equal, finding a potential function \(f\) is hopeless. However there is a glimmer of hope if we remember how we solved first order linear differential equations. We multiplied both sides by an integrating factor \(m\). We do that here to get

\[ mM + mN_y' = 0 .\]

For this to be exact we must have

\[ (mM)_y = (mN)_x . \]

Using the product rule gives

\[ m_yM + mM_y = m_xN + mN_x . \]

We now have a new differential equation that is unfortunately more difficult to solve than the original differential equation. We simplify the equation by assuming that either m is a function of only \(x\) or only \(y\). If it is a function of only \(x\), then \( m_y = 0 \) and

\[ mM_y = m_xN + mN_x .\]

Solving for \(m_x\), we get

\[ m_x = \dfrac{M_y-N_x}{N}. \]

If this is a function of \(y\) only, then we will be able to find an integrating factor that involves \(y\) only. If it is a function of only \(y\), then \( m_x = 0\) and

\[ m_yM + mM_y = mN_x . \]

Solving for \(m_y\), we get

\[ m_y = \dfrac{N_x-M_y}{M} m .\]

If this is a function of \(y\) only, then we will be able to find an integrating factor that involves \(y\) only.

For our example

\[ m_y = \dfrac{N_x - M_y }{M} m = \dfrac{2y-1}{y} m = (2-\frac{1}{y})m .\]

Separating gives

\[ \dfrac{dm}{m} = (2-\frac{1}{y}) \,dy. \]

Integrating gives

\[ ln \, m = 2y - ln\, y. \]

\[ m = e^{2y - ln\, y} = y ^{-1}e^{2y}. \]

Multiplying both sides of the original differential equation by \(m\) gives

\[ y(y ^{-1}e^{2y}) + (y ^{-1}e^{2y})(2xy - e^{-2y})y' = 0 \]

\[ \implies e^{2y} + (2xe^{2y} - \frac{1}{y})y' = 0 . \]

Now we see that

\[ M_y = 2e^{2y} = N_x. \]

Which tells us that the differential equation is exact. We therefore have

\[ f_x (x,y) = e^{2y}. \]

Integrating with respect to \(x\) gives

\[ f(x,y) = xe^{2y} + C(y). \]

Now taking the partial derivative with respect to \(y\) gives

\[ f_y(x,y) = 2xe^{2y} + C'(y) = 2xe^{2y} - \frac{1}{y} .\]

So that

\[ C'(y) = \frac{1}{y}. \]

Integrating gives

\[ C(y) = ln\, y. \]

The final solution is

\[ xe^{2y} + ln\, y = 0. \]

### Contributors

- Larry Green (Lake Tahoe Community College)
Integrated by Justin Marshall.