How to Solve Exact Differential Equations: A Beginner-Friendly Tutorial with Worked Examples
Learning how to solve exact differential equations is an important step in learning first-order differential equations. Exact differential equations arise in many areas of mathematics, physics, and engineering, and they can be solved systematically once you understand how to recognize them. Unlike some differential equations that require substitutions or specialized techniques, exact equations have a built-in structure that allows us to find a solution by constructing a single function whose total differential matches the given equation.
In this tutorial, you will learn what an exact differential equation is, how to determine whether a differential equation is exact, and why the exactness condition works. We will also derive the solution method from first principles so that you can understand the underlying theory.
After developing the theory, we will present a practical step-by-step process that you can apply to any exact differential equation. Finally, we will work through several fully solved examples. By the end of this guide, you will have a solid understanding of exact differential equations.
What Is an Exact Differential Equation?
An exact differential equation is a first-order differential equation that can be written in the form
$$M(x,y)dx + N(x,y)dy = 0,$$
where \( M(x,y) \) and \( N(x,y) \) are functions of the variables \( x \) and \( y \), such that there exists a function \( \psi(x,y) \) such that
$$d\psi = M(x,y)dx + N(x,y)dy.$$
The Exactness Condition
Before learning how to identify exact differential equations, it is important to understand how derivatives and partial derivatives work. If you need a review of basic differentiation techniques, see the article How to Differentiate a Function Step by Step: A Beginner’s Guide. Likewise, because exact differential equations rely heavily on partial derivatives, you may find it helpful to review the article The Ultimate Beginner’s Guide to Partial Derivatives with Step-by-Step Examples.
Suppose there exists a function \( \psi(x,y) \) such that
$$d\psi = Mdx + Ndy.$$
From multivariable calculus, the total differential of \( \psi(x,y) \) is
$$d\psi = \psi_xdx + \psi_ydy.$$
Comparing this expression with
$$Mdx + Ndy,$$
we obtain
$$M = \psi_x.$$
and
$$N = \psi_y.$$
Now differentiate \( M \) with respect to \( y \):
$$M_y = \psi_{xy}.$$
Similarly, differentiate \( N \) with respect to \( x \):
$$N_x = \psi_{yx}.$$
Recall that mixed partial derivatives are equal. Therefore,
$$M_y = N_x.$$
This relationship is called the exactness condition.
To summarize, a differential equation of the form
$$M(x,y)dx + N(x,y)dy = 0$$
is exact if
$$M_y = N_x.$$
Deriving the Solution Method for Exact Differential Equations
In the previous section, we learned that an exact differential equation has the form
$$M(x,y)dx + N(x,y)dy = 0,$$
where
$$M_y = N_x.$$
Furthermore, if these conditions are true, then there exists a function \( \psi(x,y) \) whose total differential equals the left-hand side of the equation.
Rather than simply memorizing a procedure, it is helpful to understand where the solution method comes from. The derivation relies on ideas from both differentiation and integration. If you need a refresher on integration, see the article Basic Integration Problems for Beginners. Likewise, if you need a refresher on integrals for functions of multiple variables, you may find the article A Step-by-Step Beginner’s Tutorial for Double and Triple Integrals in Calculus helpful.
Suppose that the differential equation
$$M(x,y)dx + N(x,y)dy = 0$$
is exact.
By definition, there exists a function \( \psi(x,y) \), called a potential function such that
$$d\psi = M(x,y)dx + N(x,y)dy.$$
Our goal is to determine this unknown function \( \psi(x,y) \).
Recall from multivariable calculus that the total differential of a function \( \psi(x,y) \) is
$$d\psi = \psi_xdx + \psi_ydy.$$
Since
$$d\psi = M(x,y)dx + N(x,y)dy,$$
the coefficients of \( dx \) and \( dy \) must match. Therefore,
$$\psi_x = M(x,y)$$
and
$$\psi_y = N(x,y).$$
These two equations contain all the information we need to recover the potential function.
Because
$$\psi_x = M(x,y),$$
We can integrate both sides with respect to \( x \):
$$\psi(x,y) = \int M(x,y)dx.$$
At first glance, this looks similar to the integration problems for single-variable functions. However, there is one important difference. Since \( y \) is treated as a constant when integrating with respect to \( x \), our constant of integration is a function of \( y \). Hence, we have
$$\psi(x,y)=\int M(x,y) dx + g(y),$$
where \( g(y) \) is an unknown function.
To find \( g(y) \), differentiate the expression for \( \psi(x,y) \) with respect to \( y \). Starting with
$$\psi(x,y) = \int M(x,y) dx + g(y),$$
we obtain
$$\psi_y = \frac{\partial}{\partial y}\int M(x,y) dx + g'(y).$$
But from the exact differential equation, we already know that
$$\psi_y = N(x,y).$$
Substituting gives
$$N(x,y) = \frac{\partial}{\partial y}\int M(x,y) dx + g'(y).$$
Solving this equation allows us to determine \( g'(y) \), and integrating once more yields \( g(y) \).
Once \( g(y) \) is known, the potential function \( \psi(x,y) \) is completely determined.
After finding \( \psi(x,y) \), the original differential equation becomes
$$d\psi = 0.$$
A differential is zero whenever the function itself is constant. Therefore,
$$\psi(x,y) = C,$$
where \( C \) is an arbitrary constant.
This equation is the general solution of the exact differential equation.
Notice that the final answer is usually written in implicit form rather than solving explicitly for \( y \). In many cases, solving for \( y \) is unnecessary and may even be impossible.
How to Solve Exact Differential Equations Step by Step
Now that we understand what exact differential equations are and why the solution method works, we can develop a systematic procedure for solving them. One advantage of exact differential equations is that there are often two valid ways to construct the potential function. You can begin by integrating \( M(x,y) \) with respect to \( x \), or you can begin by integrating \( N(x,y) \) with respect to \( y \). Both approaches lead to the same final solution.
Step 1: Write the Differential Equation in Standard Form
Begin by writing the differential equation in the form
$$M(x,y)dx + N(x,y)dy = 0.$$
Step 2: Check Whether the Equation Is Exact
Check that
$$M_y = N_x.$$
Step 3: Construct the Potential Function
At this point, choose one of the following approaches.
Option A: Integrate \( M(x,y) \) with Respect to \( x \).
Option B: Integrate \( N(x,y) \) with Respect to \( y \).
Both approaches produce the same potential function. In practice, choose whichever integral appears simpler.
Step 4: Determine the Unknown Function
The next step depends on which function you integrated in Step 3.
If you integrated \( M(x,y) \) with respect to \( x \), differentiate the resulting expression with respect to \( y \). This allows you to solve for \( g'(y) \), and then integrate to find \( g(y) \).
If you integrated \( N(x,y) \) with respect to \( y \), differentiate the resulting expression with respect to \( x \). This allows you to solve for \( h'(x) \), and then integrate to find \( h(x) \).
After determining the unknown function, substitute it back into the potential function.
Step 5: Write the Implicit Solution
Once the potential function has been found, the general solution is
$$\psi(x,y) = C,$$
where \( C \) is an arbitrary constant.
Step 6: Find an Explicit Solution if Possible
Sometimes the implicit equation can be solved algebraically for \( y \). If this is possible, rewrite the solution as
$$y = f(x).$$
Step 7: Apply the Initial Condition (If Given)
If an initial condition is provided, substitute the given condition into the implicit or explicit solution. This allows you to determine the value of the arbitrary constant \( C \).
Worked Out Examples
Now let’s apply the procedure from the previous section to solve some exact differential equations.
Example 1: Solve the differential equations:
(a) \( (2x + y)dx + xdy = 0 \)
(b) \( ydx + (x + 2y)dy = 0 \).
Solution: (a) \( (2x + y)dx + xdy = 0 \).
The equation is already in standard form. We have
$$M(x,y) = 2x + y$$
and
$$N(x,y) = x.$$
We now show that
$$(2x + y)_y = (x)_x.$$
Using the sum rule, we find
$$(2x)_y + (y)_y = (x)_x.$$
Taking the partial derivatives, we get
$$0 + 1 = 1.$$
Adding we obtain
$$1 = 1.$$
Thus, the differential equation is exact. We now find the potential function. Integrating M with respect to x gives
$$\int M dx = \int 2x + y dx.$$
Using the sum rule, we find
$$\int M dx = \int 2x dx + \int y dx.$$
Therefore
$$\psi = x^2 + xy + g(y).$$
Differentiating both sides with respect to y, then gives
$$\psi_y = (x^2 + xy + g(y))_y.$$
Using the sum rule, we find
$$\psi_y = (x^2)_y + (xy)_y + (g(y))_y.$$
Taking the partial derivatives, we get
$$N = 0 + x + g'(y).$$
Adding we obtain
$$N = x + g'(y).$$
Substituting in for N, we find
$$x = x + g'(y).$$
Subtracting x from both sides, this is
$$0 = g'(y).$$
Integrating both sides with respect to y gives
$$\int 0 dy = \int g'(y) dy.$$
Therefore
$$C = g(y).$$
The potential function is then
$$\psi = x^2 + xy.$$
Our solution is then
$$x^2 + xy = C.$$
Subtracting \( x^2 \) from both sides, this is
$$xy = C – x^2.$$
Our final solution is then
$$y = \frac{C – x^2}{x}.$$
(b) \( ydx + (x + 2y)dy = 0 \).
The equation is already in standard form. We have
$$M(x,y) = y$$
and
$$N(x,y) = x + 2y.$$
We now show that
$$(y)_y = (x + 2y)_x.$$
Using the sum rule, we find
$$(y)_y = (x)_x + (2y)_x.$$
Taking the partial derivatives, we get
$$1 = 1 + 0.$$
Adding we obtain
$$1 = 1.$$
Thus, the differential equation is exact. We now find the potential function. Integrating N with respect to y gives
$$\int N dy = \int x + 2y dy.$$
Using the sum rule, we find
$$\int N dy = \int x dy + \int 2y dy.$$
Therefore
$$\psi = xy + y^2 + h(x).$$
Differentiating both sides with respect to x, then gives
$$\psi_x = (xy + y^2 + h(x))_x.$$
Using the sum rule, we find
$$\psi_x = (xy)_x + (y^2)_x + (h(x))_x.$$
Taking the partial derivatives, we get
$$M = y + 0 + h'(x).$$
Adding we obtain
$$M = y + h'(x).$$
Substituting in for M, we find
$$y = y + h'(x).$$
Subtracting y from both sides, this is
$$0 = h'(x).$$
Integrating both sides with respect to x gives
$$\int 0 dx = \int h'(x) dx.$$
Therefore
$$C = h(x).$$
The potential function is then
$$\psi = xy + y^2.$$
Our final solution is then
$$ xy + y^2 = C.$$
Conclusion
Understanding how to solve exact differential equations becomes much easier once you recognize that an exact differential equation comes from the total differential of a potential function. By verifying the exactness condition, constructing the potential function, and setting it equal to a constant, you can systematically solve a wide variety of first-order differential equations.
In this tutorial, we introduced the definition of an exact differential equation, derived the solution method from first principles, and developed a step-by-step procedure for solving these equations. We also saw that there are two equally valid approaches to finding the potential function. You can either integrate \( M(x,y) \) with respect to \( x \) and determine the unknown function of \( y \), or integrate \( N(x,y) \) with respect to \( y \) and determine the unknown function of \( x \). Both methods ultimately lead to the same solution.
The worked examples demonstrated how to check exactness, construct the potential function, and write the implicit solution.
Further Reading
A Step-by-Step Tutorial on Linear Differential Equations with Examples and Solutions – Linear differential equations are another one of the basic differential equations you should be able to solve. This article covers these equations in depth.
Separable Differential Equations Explained Step by Step: A Complete Beginner’s Guide – Likewise, separable differential equations are another one of the basic differential equations you should be able to solve. This article covers these equations in depth.
