Exact differential equations

Some first-order ODEs are secretly a total differential of a single function in disguise. Write the equation as M(x,y) dx+N(x,y) dy=0M(x,y)\,dx + N(x,y)\,dy = 0 and ask whether the left side is exactly dudu for some potential function u(x,y)u(x,y) — if so, the level curves u(x,y)=Cu(x,y) = C are the solution, with no separation of variables and no integrating trick needed beyond one test. Within the MA10001 Ordinary Differential Equations unit, exact equations sit right after separable equations as the second core technique: many first-order, first-degree ODEs are not separable but are exact, and a huge further class becomes exact once multiplied by the right integrating factor. This article builds the exactness test, the two-step construction of u(x,y)u(x,y), and the standard integrating-factor shortcuts, then drills both on fully worked examples.

The core insight

An equation M dx+N dy=0M\,dx + N\,dy = 0 is exact exactly when My=NxM_y = N_x, and then its solution is the potential function u(x,y)=Cu(x,y) = C built by partially integrating MM or NN and matching the leftover unknown function to the other side.

The core idea

Differential form. Any first-order, first-degree ODE can be rearranged into

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

where: MM and NN are functions of xx and yy with continuous first partial derivatives on the region of interest. This is the standard form every exactness discussion starts from — even an equation given as dy/dx=f(x,y)dy/dx = f(x,y) must first be moved to this shape by careful regrouping.

What "exact" means. The equation is exact if some potential function u(x,y)u(x,y) has MM and NN as its own partial derivatives:

ux=M,uy=N,u_x = M, \qquad u_y = N,

where: uxu_x and uyu_y denote ∂u/∂x\partial u/\partial x and ∂u/∂y\partial u/\partial y. When this holds, the total differential du=ux dx+uy dydu = u_x\,dx + u_y\,dy is literally M dx+N dyM\,dx + N\,dy, so the original ODE reads du=0du = 0, and integrating once gives the implicit solution u(x,y)=Cu(x,y) = C.

The exactness test. Because mixed partial derivatives of a well-behaved function agree, uxy=uyxu_{xy} = u_{yx}, exactness is equivalent to a single checkable condition:

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

where: both sides are ordinary partial derivatives of the given MM and NN — no potential function needs to be known in advance to run this test. It is a necessary and sufficient condition (given continuity of the first partials), so a single computation settles the question before any integration is attempted.

Geometric picture. The solution curves u(x,y)=Cu(x,y) = C are the level curves (contours) of the potential uu. Moving along one of these curves keeps uu constant, so du=0du = 0 there — which is precisely the differential equation. Exactness is the statement that the ODE is the "contour equation" of some hidden surface z=u(x,y)z = u(x,y).

Figure
Level curves of a potential function u equal to C shown as nested contour rings, each labeled with an increasing constant, with the exact equation M dx plus N dy equals zero holding along every contour
Solution curves are level curves of the potential u(x,y) u = C1 u = C2 u = C3 u = C4 Along any single curve, du = M dx + N dy = 0 — that is the differential equation itself Different curves correspond to different values of the constant C

Sometimes it isn't exact — yet. If My≠NxM_y \neq N_x, multiplying every term by a suitable integrating factor μ(x,y)\mu(x,y) can restore exactness: the modified equation μM dx+μN dy=0\mu M\,dx + \mu N\,dy = 0 passes the test even though the original did not. Finding a general μ\mu is hard, but two special cases are routine to check: if (My−Nx)/N(M_y - N_x)/N depends on xx only, then μ(x)=e∫(My−Nx)/N dx\mu(x) = e^{\int (M_y-N_x)/N\,dx}; if (Nx−My)/M(N_x - M_y)/M depends on yy only, then μ(y)=e∫(Nx−My)/M dy\mu(y) = e^{\int (N_x-M_y)/M\,dy}.

Derivation AConstructing the solution u(x,y) from an exact equation

The goal is to turn the bare exactness condition My=NxM_y = N_x into an explicit, mechanical recipe that produces the potential function u(x,y)u(x,y) and hence the implicit general solution u(x,y)=Cu(x,y) = C, using nothing beyond partial integration and matching one unknown function of a single variable.

Step 1. Start from the exactness condition ux=Mu_x = M. Treat yy as a fixed constant and integrate both sides with respect to xx. Because the "constant" of integration with respect to xx can still depend on yy, write

u=∫M dx+ϕ(y),u = \int M\,dx + \phi(y),

where ϕ(y)\phi(y) is an unknown function of yy alone, not yet determined. This is the one place students most often go wrong: dropping ϕ(y)\phi(y) and replacing it by a plain numeric constant throws away part of the solution, because any function of yy alone differentiates to zero with respect to xx and is therefore invisible to the integration in this step.

Step 2. Use the second condition, uy=Nu_y = N, to pin down ϕ(y)\phi(y). Differentiate the expression for uu from Step 1 with respect to yy:

uy=∂∂y(∫M dx)+ϕ′(y).u_y = \frac{\partial}{\partial y}\left(\int M\,dx\right) + \phi'(y).

Set this equal to NN and solve for ϕ′(y)\phi'(y). Because My=NxM_y = N_x was already guaranteed by the exactness test, every xx-dependent term is guaranteed to cancel out in this equation, leaving ϕ′(y)\phi'(y) as a function of yy only — if an xx-term survives, an arithmetic slip has occurred somewhere upstream, since consistency is not optional here.

Step 3. Integrate ϕ′(y)\phi'(y) with respect to yy to recover ϕ(y)\phi(y) itself (the numeric constant of this last integration is absorbed into the overall constant CC later, so it can be dropped). Substitute ϕ(y)\phi(y) back into the expression from Step 1 to obtain the complete potential function u(x,y)u(x,y).

Step 4. State the implicit general solution as u(x,y)=Cu(x,y) = C, where CC is an arbitrary constant fixed later by any given initial condition. As a check, differentiate the found uu partially with respect to xx and yy and confirm the results reproduce the original MM and NN exactly — this catches nearly every algebra slip made in Steps 1 through 3. The mirror-image route — integrating NN with respect to yy first and matching against MM — works identically and is preferable whenever NN is easier to integrate than MM.

Worked example

Solve (2xy+3) dx+(x2−1) dy=0(2xy + 3)\,dx + (x^2 - 1)\,dy = 0, and find the particular solution satisfying y(0)=2y(0) = 2.

Step 1. Identify MM and NN in the standard differential form: M=2xy+3M = 2xy + 3 and N=x2−1N = x^2 - 1.

Step 2. Test exactness. My=2xM_y = 2x and Nx=2xN_x = 2x. Since My=NxM_y = N_x, the equation is exact, so the potential-function method applies directly.

Step 3. Integrate MM with respect to xx, holding yy fixed:

u=∫(2xy+3) dx=x2y+3x+ϕ(y).u = \int (2xy + 3)\,dx = x^2 y + 3x + \phi(y).

Step 4. Differentiate with respect to yy and match to NN: uy=x2+ϕ′(y)u_y = x^2 + \phi'(y), and this must equal N=x2−1N = x^2 - 1, so ϕ′(y)=−1\phi'(y) = -1, giving ϕ(y)=−y\phi(y) = -y.

Step 5. Assemble the general solution: u=x2y+3x−y=Cu = x^2y + 3x - y = C. Check: ux=2xy+3=Mu_x = 2xy + 3 = M and uy=x2−1=Nu_y = x^2 - 1 = N, as required.

Step 6. Apply the initial condition x=0,y=2x = 0, y = 2: (0)2(2)+3(0)−2=C(0)^2(2) + 3(0) - 2 = C, so C=−2C = -2.

Final answer: the particular solution is x2y+3x−y=−2x^2y + 3x - y = -2.

Competitive stretch

The same family (3x2+6xy2) dx+(6x2y+4y3) dy=0(3x^2 + 6xy^2)\,dx + (6x^2y + 4y^3)\,dy = 0 with y(1)=1y(1) = 1 is worth knowing by heart: here it is faster to integrate NN with respect to yy first, giving u=3x2y2+y4+ψ(x)u = 3x^2y^2 + y^4 + \psi(x), then matching ux=6xy2+ψ′(x)u_x = 6xy^2 + \psi'(x) to M=3x2+6xy2M = 3x^2 + 6xy^2 gives ψ′(x)=3x2\psi'(x) = 3x^2, so ψ(x)=x3\psi(x) = x^3. The general solution is x3+3x2y2+y4=Cx^3 + 3x^2y^2 + y^4 = C, and the initial condition forces C=1+3+1=5C = 1 + 3 + 1 = 5, so the particular solution is x3+3x2y2+y4=5x^3 + 3x^2y^2 + y^4 = 5. Recognising which side, MM or NN, is quicker to integrate first is a genuine time-saver under exam pressure.

Common traps

  • Skipping the exactness test. Running the potential-function procedure on a non-exact equation produces an inconsistent or meaningless result — always confirm My=NxM_y = N_x before integrating anything.
  • Treating ϕ(y)\phi(y) as a numeric constant. It is an unknown function of the other variable; dropping it at the first integration step silently discards part of the solution.
  • Getting an xx-term when solving for ϕ′(y)\phi'(y). If matching uyu_y to NN leaves an xx-dependent piece, that signals an earlier arithmetic error, since My=NxM_y = N_x already guarantees clean cancellation.
  • Sign or regrouping errors converting dy/dx=f(x,y)dy/dx = f(x,y) into M dx+N dy=0M\,dx + N\,dy = 0. Move every term to one side deliberately before reading off MM and NN; a stray sign flips the whole exactness test.

Ask the tutor: if the two-step construction of u(x,y)u(x,y) feels shaky, or you want more drill on spotting exact equations and integrating factors quickly, ask the AI tutor to walk through the reasoning step by step.

Why does M sub y equal N sub x guarantee exactness instead of just being a convenient coincidence?

It follows from a genuine theorem, not a lucky pattern. If ux=Mu_x = M and uy=Nu_y = N for some smooth potential uu, then differentiating the first equation with respect to yy and the second with respect to xx gives uxy=Myu_{xy} = M_y and uyx=Nxu_{yx} = N_x. Since mixed partial derivatives of a function with continuous derivatives are always equal, uxy=uyxu_{xy} = u_{yx}, it must be that My=NxM_y = N_x. The converse — that My=NxM_y = N_x is enough to guarantee such a uu exists — is a standard result proved by actually constructing uu via the two-step integration, which is exactly the procedure used in the worked examples.

What do I do if M sub y does not equal N sub x?

The equation is not exact as written, but it may become exact after multiplying through by an integrating factor μ\mu. First check whether (My−Nx)/N(M_y - N_x)/N depends on xx alone; if so, μ(x)=e∫(My−Nx)/N dx\mu(x) = e^{\int (M_y-N_x)/N\,dx} works. If instead (Nx−My)/M(N_x - M_y)/M depends on yy alone, use μ(y)=e∫(Nx−My)/M dy\mu(y) = e^{\int (N_x-M_y)/M\,dy}. Multiply the whole equation by whichever μ\mu applies, recheck exactness (it will now hold), and then solve exactly as usual. If neither special case applies, finding μ\mu in general is a harder problem outside this unit's standard toolkit.

Is checking u by differentiating back really necessary, or is it just extra work?

It is worth the thirty seconds. The construction in Steps 1 to 3 involves two separate integrations and one differentiation, any of which can carry a sign or algebra slip that would otherwise go unnoticed until marks are lost. Differentiating the final uu partially with respect to xx and yy and comparing against the original MM and NN catches essentially every such error immediately, because the check must reproduce the two given functions exactly — any mismatch points straight back to where the mistake happened.

Before this

Where this leads