In short

An equation of the form M(x, y)\,dx + N(x, y)\,dy = 0 is called exact if it is the total differential dF = 0 of some function F(x, y) — equivalently, if \partial M/\partial y = \partial N/\partial x. When the equation is exact, you can find F directly by integration, and the solution is F(x, y) = C. When it is not exact, sometimes an integrating factor (a function you multiply by) turns it into an exact one.

Here is a peculiar equation:

(2xy + 3)\,dx + (x^2 - 4y)\,dy = 0

It does not look like any of the families you have met. It is not separable — the 2xy term tangles x and y together. It is not linear — there is no dy/dx in sight, just differentials. It is not a Bernoulli equation. What is it?

The observation that unlocks everything: this entire equation is the total differential of a single function. If you stare at it and guess,

F(x, y) = x^2 y + 3x - 2y^2

does the job. To check, take the total differential:

dF = \frac{\partial F}{\partial x}\,dx + \frac{\partial F}{\partial y}\,dy = (2xy + 3)\,dx + (x^2 - 4y)\,dy

The equation (2xy + 3)\,dx + (x^2 - 4y)\,dy = 0 is exactly dF = 0, which means F is constant along any solution. So the solution is

x^2 y + 3x - 2y^2 = C

for some constant C. One line, no integration trickery, no substitution.

Of course, you cannot just guess F every time. There is a systematic method: a single test to check whether the equation is the differential of something, and an algorithm to recover that something when it is. That is this article.

The total differential and exactness

Recall from multivariable calculus that if F(x, y) is a function of two variables, its total differential is

dF = \frac{\partial F}{\partial x}\,dx + \frac{\partial F}{\partial y}\,dy

The partial derivative \partial F/\partial x treats y as a constant and differentiates with respect to x; \partial F/\partial y treats x as a constant and differentiates with respect to y.

Now suppose someone hands you an equation

M(x, y)\,dx + N(x, y)\,dy = 0

and asks: is this dF for some F? If the answer is yes, then M = \partial F/\partial x and N = \partial F/\partial y. For that to be true, a compatibility condition must hold. Differentiate M with respect to y and N with respect to x:

\frac{\partial M}{\partial y} = \frac{\partial^2 F}{\partial y \partial x}, \quad \frac{\partial N}{\partial x} = \frac{\partial^2 F}{\partial x \partial y}

For a nice function F, the order of partial differentiation does not matter (F_{xy} = F_{yx}, called Clairaut's theorem). So

\frac{\partial M}{\partial y} = \frac{\partial N}{\partial x}

This is the necessary condition for the equation to be exact. It is also sufficient — if the condition holds on a simply-connected region (a region with no holes), then such an F exists and you can construct it.

Exact Differential Equation

The first-order equation

M(x, y)\,dx + N(x, y)\,dy = 0

is called exact if there exists a function F(x, y) such that

M = \frac{\partial F}{\partial x}, \quad N = \frac{\partial F}{\partial y}

Exactness test: the equation is exact if and only if

\frac{\partial M}{\partial y} = \frac{\partial N}{\partial x}

on the region of interest (assuming M and N have continuous partial derivatives).

When the equation is exact, its general solution is F(x, y) = C.

Checking the guess. Go back to (2xy + 3)\,dx + (x^2 - 4y)\,dy = 0. Here M = 2xy + 3 and N = x^2 - 4y.

\frac{\partial M}{\partial y} = 2x, \quad \frac{\partial N}{\partial x} = 2x

They match. The equation is exact, and the F(x, y) = x^2 y + 3x - 2y^2 you guessed earlier is indeed a valid choice.

Constructing F when the equation is exact

You cannot always guess. Here is the procedure to build F from M and N.

Step 1. Integrate M with respect to x, treating y as a constant:

F(x, y) = \int M(x, y)\,dx + g(y)

The "constant of integration" is a function of y — call it g(y) — because anything that depends only on y would disappear when you differentiate with respect to x.

Step 2. Differentiate the result with respect to y and set it equal to N:

\frac{\partial F}{\partial y} = \frac{\partial}{\partial y}\left[\int M\,dx\right] + g'(y) = N(x, y)

Solve for g'(y). The x-dependent parts should cancel (by exactness), leaving an expression in y alone.

Step 3. Integrate g'(y) to find g(y).

Step 4. Substitute back to get F(x, y), and write the solution as F(x, y) = C.

Run it on the motivating example. M = 2xy + 3, N = x^2 - 4y.

Step 1. F = \int(2xy + 3)\,dx + g(y) = x^2 y + 3x + g(y).

Step 2. \frac{\partial F}{\partial y} = x^2 + g'(y). Set this equal to N: x^2 + g'(y) = x^2 - 4y, so g'(y) = -4y.

Step 3. g(y) = -2y^2 (no new constant needed — it will combine with C).

Step 4. F(x, y) = x^2 y + 3x - 2y^2. Solution: x^2 y + 3x - 2y^2 = C.

Same answer as the guessed one. The procedure never fails when the exactness test passes.

Integrating factors for non-exact equations

Sometimes you meet an equation that is not exact. For example:

y\,dx + (x^2 y - x)\,dy = 0

Check: M = y, N = x^2 y - x. \partial M/\partial y = 1, \partial N/\partial x = 2xy - 1. These are not equal, so the equation is not exact.

But if you multiply both sides by 1/x^2:

\frac{y}{x^2}\,dx + \left(y - \frac{1}{x}\right)dy = 0

Now M = y/x^2, N = y - 1/x. Check: \partial M/\partial y = 1/x^2, \partial N/\partial x = 1/x^2. They match — the equation has become exact.

A function \mu(x, y) that you multiply by to convert a non-exact equation to an exact one is called an integrating factor. (This is the same idea you saw for linear equations, just in a more general setting.)

Finding the integrating factor. In general, this is hard — there is no universal formula, and sometimes no elementary integrating factor exists. But there are two special cases that cover most exam problems:

Case 1: \mu depends on x alone. If \dfrac{M_y - N_x}{N} is a function of x alone (call it h(x)), then

\mu(x) = e^{\int h(x)\,dx}

is an integrating factor.

Case 2: \mu depends on y alone. If \dfrac{N_x - M_y}{M} is a function of y alone (call it k(y)), then

\mu(y) = e^{\int k(y)\,dy}

is an integrating factor.

Why these formulas work. If \mu(x) multiplies the equation, the new coefficients are \tilde M = \mu M and \tilde N = \mu N. Exactness requires \tilde M_y = \tilde N_x, i.e., \mu M_y = \mu' N + \mu N_x, which rearranges to

\frac{\mu'}{\mu} = \frac{M_y - N_x}{N}

This is separable if the right side depends only on x, giving \mu = e^{\int (M_y - N_x)/N\,dx}. Case 2 is the symmetric argument.

The method at work

Solve (3x^2 + 6xy^2)\,dx + (6x^2 y + 4y^3)\,dy = 0.

Step 1. Test exactness. M = 3x^2 + 6xy^2, N = 6x^2 y + 4y^3.

\frac{\partial M}{\partial y} = 12xy, \quad \frac{\partial N}{\partial x} = 12xy

They match. The equation is exact.

Step 2. Integrate M with respect to x:

F = \int (3x^2 + 6xy^2)\,dx + g(y) = x^3 + 3x^2 y^2 + g(y)

Step 3. Differentiate with respect to y:

\frac{\partial F}{\partial y} = 6x^2 y + g'(y)

Set equal to N = 6x^2 y + 4y^3: g'(y) = 4y^3, so g(y) = y^4.

Step 4. Assemble F and write the solution:

F(x, y) = x^3 + 3x^2 y^2 + y^4
x^3 + 3x^2 y^2 + y^4 = C

This is an implicit solution — you cannot solve for y explicitly in general, but F = C describes a family of curves, one for each value of C.

Solution curves of the exact equation $(3x^2 + 6xy^2)\,dx + (6x^2 y + 4y^3)\,dy = 0$. Each curve is a level set of $F(x, y) = x^3 + 3x^2 y^2 + y^4$. The red curve is $F = 0.3$; the darker curves are $F = 1$ and $F = 2$. Larger $C$ gives larger enclosing curves.

Worked examples

Example 1: Solve (2x + y²)dx + (2xy + cos y)dy = 0

Step 1. Test for exactness.

M = 2x + y^2 and N = 2xy + \cos y.

\frac{\partial M}{\partial y} = 2y, \quad \frac{\partial N}{\partial x} = 2y

They match — the equation is exact.

Why: before attempting to construct F, always test for exactness. If the test fails, you must first find an integrating factor; otherwise the method will give nonsense.

Step 2. Integrate M with respect to x, treating y as a constant.

F = \int(2x + y^2)\,dx + g(y) = x^2 + xy^2 + g(y)

Why: \int 2x\,dx = x^2 and \int y^2\,dx = y^2 \cdot x = xy^2 because y^2 is a constant with respect to x. The unknown function g(y) captures anything that depends only on y.

Step 3. Differentiate F with respect to y and match against N.

\frac{\partial F}{\partial y} = 2xy + g'(y)

Set equal to N = 2xy + \cos y:

2xy + g'(y) = 2xy + \cos y
g'(y) = \cos y

Why: the 2xy terms cancel automatically — this is the exactness test manifesting in the computation. If they did not cancel, you would know the equation is not exact and something is wrong.

Step 4. Integrate g'(y).

g(y) = \int\cos y\,dy = \sin y

Why: no new constant needed — it will be absorbed into the final C on the right side of F = C.

Step 5. Assemble the solution.

F(x, y) = x^2 + xy^2 + \sin y
x^2 + xy^2 + \sin y = C

Why: the solution of an exact equation is always of the form "the reconstructed F equals an arbitrary constant." You do not need to — and usually cannot — solve for y explicitly.

Result: x^2 + xy^2 + \sin y = C.

Solution curves of $(2x + y^2)\,dx + (2xy + \cos y)\,dy = 0$. Each curve is a level set $F = C$ for the function $F = x^2 + xy^2 + \sin y$. The red curve is $C = 2$. The shape of each curve depends subtly on where the $\sin y$ term reinforces or cancels the polynomial part.

Example 2: A non-exact equation, fixed with an integrating factor

Solve (xy - 1)\,dx + (x^2 - xy)\,dy = 0.

Step 1. Test exactness.

M = xy - 1, N = x^2 - xy.

\frac{\partial M}{\partial y} = x, \quad \frac{\partial N}{\partial x} = 2x - y

These are not equal, so the equation is not exact. A direct reconstruction of F would fail.

Why: the exactness test is the gate. If it fails, the equation is not the differential of a function, and an integrating factor is needed.

Step 2. Try an integrating factor depending only on x.

Compute \dfrac{M_y - N_x}{N}:

\frac{M_y - N_x}{N} = \frac{x - (2x - y)}{x^2 - xy} = \frac{-x + y}{x(x - y)} = \frac{-(x - y)}{x(x - y)} = -\frac{1}{x}

This depends only on x, so an integrating factor depending only on x exists.

Why: the case-1 test produced a function of x alone, confirming that \mu(x) exists. The integrating factor formula from the theory above gives it directly.

Step 3. Compute \mu.

\mu(x) = e^{\int -1/x\,dx} = e^{-\ln|x|} = \frac{1}{x}

Why: integrating -1/x gives -\ln|x|, and e^{-\ln|x|} = 1/|x|, which we write as 1/x (the sign gets absorbed into C eventually).

Step 4. Multiply the equation by \mu.

\frac{xy - 1}{x}\,dx + \frac{x^2 - xy}{x}\,dy = 0
\left(y - \frac{1}{x}\right)dx + (x - y)\,dy = 0

New coefficients: \tilde M = y - 1/x, \tilde N = x - y.

Check exactness of the new equation:

\frac{\partial\tilde M}{\partial y} = 1, \quad \frac{\partial\tilde N}{\partial x} = 1

Yes — the new equation is exact.

Why: this is the moment the integrating factor pays off. The new equation passes the exactness test, so the standard construction procedure works.

Step 5. Construct F for the new equation.

Integrate \tilde M with respect to x:

F = \int\left(y - \frac{1}{x}\right)dx + g(y) = xy - \ln|x| + g(y)

Differentiate with respect to y:

\frac{\partial F}{\partial y} = x + g'(y)

Set equal to \tilde N = x - y:

x + g'(y) = x - y
g'(y) = -y
g(y) = -\frac{y^2}{2}

Assemble: F(x, y) = xy - \ln|x| - \frac{y^2}{2}.

Why: once the equation is exact, the algorithmic construction of F proceeds exactly as before. The logarithm comes from \int(-1/x)\,dx, which is the signature of having used a 1/x integrating factor.

Result: xy - \ln|x| - \dfrac{y^2}{2} = C.

Solution curves of the non-exact equation $(xy - 1)\,dx + (x^2 - xy)\,dy = 0$, after multiplying by the integrating factor $\mu = 1/x$. The red curve is $C = -1$. Each curve is a level set of $xy - \ln|x| - y^2/2$. The $\ln|x|$ term forces all curves to avoid the y-axis — the integrating factor introduced that singularity when you divided by $x$.

Common confusions

Going deeper

If you can apply the exactness test, construct F, and find an integrating factor in the two easy cases, you have the practical toolkit. The rest of this section connects exact equations to the bigger idea of differential forms and explains why the compatibility condition is the shadow of a much deeper theory.

Exact equations as closed differential forms

A differential 1-form on the plane is an expression M\,dx + N\,dy. The form is called closed if dM \wedge dx + dN \wedge dy = 0 where \wedge is the wedge product — and when you unpack the definitions, this condition is exactly M_y = N_x.

A 1-form is called exact if it is the differential dF of some function F. Every exact form is closed — that is the content of Clairaut's theorem, F_{xy} = F_{yx}. The converse is where things get interesting: every closed form is locally exact (on any small enough disk, you can find an F) but not necessarily globally exact.

The obstruction to global exactness is measured by a thing called cohomology, and it depends on the topology of the region you are working in. On a disk or a rectangle, cohomology is trivial and every closed form is exact. On a region with a hole (like the punctured plane \mathbb R^2 \setminus \{0\}), cohomology is nontrivial and there are closed forms that are not exact. The form \frac{-y\,dx + x\,dy}{x^2 + y^2} is the canonical example: it is closed everywhere away from the origin, but integrating it around a loop that encloses the origin gives 2\pi, not zero, so it cannot be dF for a single-valued F.

This is the starting point of de Rham cohomology, one of the pillars of modern geometry.

Why integrating factors exist

For first-order ODEs, the existence of an integrating factor is always guaranteed locally — but the factor may not be elementary. The reason: you can always view M\,dx + N\,dy = 0 as saying "the solution curves are level sets of something." Given any function F whose level sets are the solution curves, dF is proportional to M\,dx + N\,dy, and the proportionality factor is the integrating factor. So the question is not "does an integrating factor exist" but "can I find one in closed form?"

The Lie symmetry approach we mentioned for Bernoulli equations applies here too: exact equations have a symmetry group (translations along level sets of F), and general first-order equations have integrating factors exactly when they have a one-parameter symmetry group. Finding the symmetry algorithmically is hard; finding the integrating factor from the symmetry is easy once you have the symmetry.

Connection to conservation laws in physics

Exact equations are everywhere in physics because physical laws often say "this quantity is conserved along trajectories." Energy conservation in a simple mechanical system, for example, gives rise to an equation of the form dE = 0, where E(x, y) = \frac{1}{2}y^2 + V(x) is the total energy (kinetic plus potential) and y is velocity. Along any trajectory of the system, E is constant, so the trajectories are the level sets E = C.

This is a mini-example of the Hamiltonian formulation of mechanics: energy E is the function whose level sets trace out motion, and the equation of motion is dE = 0. The exact-equation machinery you have just learned is the first-order, one-dimensional version of this much more general theory.

Why the method terminates

The algorithm for constructing F — integrate M with respect to x, then match the y-derivative against N — is guaranteed to succeed when the equation is exact. The reason: the exactness condition M_y = N_x is precisely what ensures that the "g'(y) = \ldots" step at the end produces an expression with no leftover x dependence. If there were leftover x, you could not integrate it with respect to y alone, and the construction would fail. The test is not just decorative — it is the guarantee that the algorithm works.

Where this leads next

You now have four main tools for first-order ODEs: separation of variables, linear equations (integrating factor), Bernoulli substitutions, and exact equations. Together these cover almost every elementary first-order ODE you will meet in a calculus course.