Exact Equations

Some differential equations are wolves in sheep's clothing. Look at (2xy+3)\,dx + (x^2-1)\,dy = 0 and it looks like a tangle of two intertwined variables that fight back against ordinary integration. But watch: it is nothing but the total differential of the single function F(x,y) = x^2y + 3x - y, wearing a disguise. Once you notice that, the whole equation collapses to "F is constant" — no clever substitution, no integrating-factor hunt, just algebra. Spotting equations wearing this disguise, and unmasking the hidden F, is the whole game of this page.

Write a first-order ODE in differential form, treating x and y on equal footing:

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

The dream is that the whole left side is secretly the total differential of some single function F(x, y). If so, the equation reads dF = 0, and a quantity whose differential is zero is constant — so the solution is simply the level curves

F(x, y) = C.

When this happens the equation is called exact. The questions are: how do we recognise exactness, and how do we reconstruct the hidden potential F? Both answers come from the partial derivatives of F.

The exactness test, and where it comes from

Recall the total differential: if F(x,y) has partials F_x and F_y, then

dF = F_x\,dx + F_y\,dy.

Matching this against M\,dx + N\,dy, the equation is exact precisely when there is an F with

F_x = M \qquad\text{and}\qquad F_y = N.

The test. Suppose such an F exists and is smooth. Then by Clairaut's theorem the mixed second partials agree, F_{xy} = F_{yx}. Differentiating F_x = M by y and F_y = N by x:

\frac{\partial M}{\partial y} = F_{xy} = F_{yx} = \frac{\partial N}{\partial x}.

So a necessary condition is M_y = N_x. On a simply-connected region it is also sufficient — the equality guarantees a potential exists. That single equality is the whole exactness test.

The centrepiece: test, then reconstruct F

Solve

\underbrace{(2xy + 3x^2)}_{M}\,dx + \underbrace{(x^2 + \cos y)}_{N}\,dy = 0.

Step 1 — identify M and N. M = 2xy + 3x^2, N = x^2 + \cos y.

Step 2 — run the exactness test. Differentiate M by y and N by x:

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

They are equal, so the equation is exact — a potential F exists.

Step 3 — integrate M in x to recover the bulk of F. Since F_x = M, integrate M holding y fixed — but the "constant" of integration may depend on y, so call it g(y):

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

Step 4 — differentiate that F by y and match it to N to pin down the missing g(y):

F_y = x^2 + g'(y) \;\overset{!}{=}\; N = x^2 + \cos y.

Step 5 — solve for g. The x^2 terms cancel, leaving g'(y) = \cos y, so g(y) = \sin y (any constant is folded into the final C).

Step 6 — assemble F and write the solution. The implicit general solution is the level set F = C:

\boxed{\,x^2 y + x^3 + \sin y = C.\,}

We cannot in general solve such a relation for y explicitly — and we do not need to. The family of level curves is the solution, and an initial condition y(x_0) = y_0 simply selects the one value of C whose curve passes through that point.

Consider M(x,y)\,dx + N(x,y)\,dy = 0 on a simply-connected region where M, N have continuous first partials.

What if the test fails, M_y \ne N_x? Often we can multiply the whole equation by an integrating factor \mu(x, y) that makes it exact — the same idea that powered the first-order linear method, now in two-variable dress. We need (\mu M)_y = (\mu N)_x, which in general is a PDE for \mu — hard. But in two lucky cases it collapses to an ODE:

A clean example. Take (3xy + y^2)\,dx + (x^2 + xy)\,dy = 0. Testing: M_y = 3x + 2y but N_x = 2x + y — not exact. Compute

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

which depends on x alone, so \mu(x) = e^{\int (1/x)\,dx} = x. Multiplying the whole equation by x gives

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

now exact, since M_y = N_x = 3x^2 + 2xy. Reconstructing as before gives the potential F = x^3y + \tfrac12 x^2y^2, so the original equation's solution is x^3y + \tfrac12 x^2y^2 = C. One multiplication turned an unsolvable-looking equation into an exact one.

Indeed the integrating factor \mu = e^{\int P\,dx} of a linear ODE is exactly this construction applied to (P y - Q)\,dx + dy = 0 — the two methods are one. And a separable equation is just an exact one in disguise, with F the sum of the two single-variable integrals.

A second worked example, start to finish

Return to the equation that opened the page and solve it completely.

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

Step 1 — name M and N. M = 2xy + 3, N = x^2 - 1.

Step 2 — test for exactness.

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

Equal — the equation is exact, so a potential F exists.

Step 3 — integrate M in x, holding y fixed, remembering the leftover piece is a function of y, not a plain number:

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

Step 4 — differentiate by y and match against N:

F_y = x^2 + g'(y) \;\overset{!}{=}\; N = x^2 - 1 \;\;\Longrightarrow\;\; g'(y) = -1 \;\;\Longrightarrow\;\; g(y) = -y.

Step 5 — assemble the solution.

\boxed{\,x^2y + 3x - y = C.\,}

Exactly the hidden function from the opening hook — only now you have derived it rather than simply spotted it. Every level curve of this F is a solution curve of the ODE, and the particular curve through any starting point (x_0, y_0) is fixed by plugging in and solving for C.

Two classic slips wreck this method:

Yes — under different clothes. A little later you may meet vector fields: assignments of an arrow \mathbf{F} = (P, Q) to every point of the plane. A field is called conservative when it is the gradient of some potential f, and the very same mixed-partials check, P_y = Q_x, decides it. Read M and N as the components of a vector field, and "exact" and "conservative" turn out to be the same idea wearing two different names — one from the world of differentials, the other from the world of arrows and flows.

The solution is a contour map

Because the general solution is F(x, y) = C, the solution curves are the level curves (contours) of the potential F — exactly like the contour lines on a topographic map, each tracing one height C. Below are several contours of F(x, y) = x^2 y + x^3 + \sin y from the worked example. Step through to draw them one value of C at a time; each curve is one particular solution of the exact ODE, and an initial condition just chooses which level you ride. The second worked example's potential, x^2y + 3x - y, has exactly the same character — pick any C and you get one more thread in the same family of curves.

See it explained