Finding Potential Functions
Kaplan §3.6 / §5.6 - the three-integration recipe for recovering $f$ from $\nabla f = \mathbf{u}$.
Prereq: §3.5 The Curl · §5.6 Path Independence · §5.13 Path Independence in 3D
Two fields. One has a hidden hill behind it.
Here are two plane vector fields. They look roughly the same - swirly arrows, no obvious peak. But one of them is secretly the gradient of some scalar function $f$, and the other isn't. If we could recover that $f$, we'd know the work along any curve just from the endpoints. So: which is which, and how do we tell?
Field A
Field B
Given a vector field, can we always recover a scalar function it came from? And if we can, how do we actually find it?
This is exactly what physicists do every time they recover a gravitational potential from a force field, or an electric potential from $\mathbf{E}$. The recipe is general; the physics is just the most-used special case.
Step 0 - the two-step diagnostic
Before we integrate anything, we should ask whether a potential is even possible. There's a quick local test, and a global one. Both have to pass.
Step 0a - check the curl
We met the curl test back in §3.5; here's why we re-run it before integrating anything. A potential exists only if $\nabla \times \mathbf{u} = \mathbf{0}$, and if the test fails the integration we're about to set up is doomed before it starts.
In 2D we had one equation: $P_y = Q_x$. How many should we expect in 3D, and why? Roughly speaking, we need every pair of mixed partials to agree, and there are three pairs in three dimensions: $(L, M)$, $(L, N)$, $(M, N)$. So three equations.
If any cross-partial fails, stop. There is no $f$ - the integration we're about to set up is doomed, and forging ahead just produces inconsistent equations.
Step 0b - check the domain
Curl-zero is necessary but not quite sufficient. The four theorems of §5.6 tell us what's actually needed: a curl-zero field on a simply connected domain has a global potential. On a domain with holes, we may only get a local one.
- If $D$ is simply connected (no holes) and curl is zero, you'll find a single $f$ that works everywhere on $D$.
- If $D$ has a hole - the punctured plane, the $z$-axis removed from $\mathbb{R}^3$, the slit annulus - curl-zero gives only a local potential. The global integral may be multi-valued. See §5.7 for how to handle that systematically.
For the rest of this page we'll assume Step 0 has passed: curl is zero, domain is simply connected. Now we go hunting for $f$.
Step 1 Integrate $P$ in $x$
We want $\nabla f = \mathbf{u}$, which means $f_x = P$, $f_y = Q$, $f_z = R$ all simultaneously. Pick the $x$-equation first and integrate it, treating $y$ and $z$ as parameters.
The "$+\,g$" is the constant of integration with respect to $x$ - but it turns out that "constant" is a slippery word here.
So at the end of Step 1 we have a candidate $f$ that's correct in $x$ by construction, but with an unknown function $g(y, z)$ riding along. The remaining equations $f_y = Q$ and $f_z = R$ will pin $g$ down.
Step 2 Match $Q$ to determine $g_y$
Differentiate the candidate $f$ from Step 1 with respect to $y$:
We need $f_y = Q$. Set the two expressions equal and solve for $g_y$:
Sanity check. Look at the right-hand side. It seems to depend on $x$. But $g_y$ should be a function of $y$ and $z$ only - $x$ has no business being there. So every $x$ on the right must cancel.
Why does it cancel? Because the cross-partial condition $\partial L/\partial y = \partial M/\partial x$ from Step 0 guarantees it. It turns out that's exactly what the curl-zero test is doing for us here - paying off in the algebra. If you do the algebra and $x$ doesn't cancel, two things are possible: an arithmetic slip somewhere, or the field wasn't conservative to begin with (Step 0 was botched). Either way, stop and recheck.
Quick sanity check on $P = 2xy$, $Q = x^2$. After integrating $P$ in $x$, we get $f = x^2 y + g(y)$. Then $f_y = x^2 + g'(y)$. Set equal to $Q = x^2$. The $x^2$ cancels - leaving $g'(y) = 0$ - and the field is conservative. ✓ If the $x^2$ hadn't cancelled, we'd have hit a contradiction and known to abort.
Once $g_y$ is in hand, integrate in $y$:
Same trap as before: the new integration "constant" $h$ is a function of the one variable we still haven't pinned down, namely $z$. In 2D the recipe ends here ($h$ collapses to a literal constant $C$). In 3D we have one more equation to use.
Step 3 Match $R$ to determine $h'(z)$ (3D only)
We now have a candidate $f(x, y, z)$ that's correct in $x$ and $y$, with one loose end: an unknown $h(z)$. Differentiate in $z$ and demand $f_z = R$:
Same sanity check as Step 2, basically. The right-hand side looks like it could depend on $x$ and $y$, but it can't - $h$ is a function of $z$ alone. The other two curl-zero conditions, $\partial N/\partial x = \partial L/\partial z$ and $\partial M/\partial z = \partial N/\partial y$, are exactly what guarantees the $x$ and $y$ dependence cancels. If they don't cancel, the field isn't conservative or the algebra is off.
Integrate to get $h(z) + C$, where now $C$ is a genuine constant. Plug everything back in to assemble the final $f$.
Step 4 - always recompute $\nabla f$
The recipe has three integrations and three differentiations woven together. There are a lot of places to drop a sign or miscarry a $2$. Every time we finish, we go back and verify - not by re-reading the work, but by computing $\nabla f$ from scratch and comparing with $\mathbf{u}$.
This is cheap (three differentiations, no integration) and catches just about every mistake the recipe is prone to: dropped terms, sign errors, forgotten coefficients.
Always verify. It catches sign errors and dropped terms in seconds. Skipping costs you points. We'll do it on the worked example next.
Recipe at a glance
- Step 0. Check curl is zero and the domain is simply connected.
- Step 1. $f = \int P\,dx + g(y, z)$.
- Step 2. Set $f_y = Q$, solve for $g_y$, integrate to get $g(y, z) = \int g_y\,dy + h(z)$.
- Step 3 (3D). Set $f_z = R$, solve for $h'(z)$, integrate to get $h(z) + C$.
- Step 4. Verify $\nabla f = \mathbf{u}$ component-by-component.
Worked example - a 3D field
Let's run the whole recipe on a clean 3D example. Take
So $L = 2xy - z^2$, $M = x^2 + 2z$, $N = 2y - 2xz$. We're hunting for $f$ with $\nabla f = \mathbf{u}$.
Step 0 Curl check
Compute the three cross-partials.
All three match. Curl is zero on $\mathbb{R}^3$, which is simply connected, so a global potential exists.
Step 1 Integrate $L$ in $x$
Step 2 Match $M$, find $g_y$
Differentiate in $y$:
We need $f_y = M = x^2 + 2z$. So
Sanity check: $g_y$ has no $x$ in it. Good. Integrate in $y$:
So our updated candidate is
Step 3 Match $N$, find $h'(z)$
Differentiate in $z$:
We need $f_z = N = 2y - 2xz$. So
Sanity check: $h'(z)$ has no $x$ or $y$ - in fact it's identically zero, which is allowed. Integrating gives $h(z) = C$, a genuine constant.
Final answer
Step 4 Verify $\nabla f = \mathbf{u}$
Compute each partial from scratch and compare to the original components $L, M, N$.
All three components match. The potential is correct.
Edge case - curl zero, but no global potential
The recipe assumes Step 0b passes: the domain is simply connected. What if it isn't? The classic example is the planar vortex
A direct computation gives $Q_x - P_y = 0$ everywhere $\mathbf{u}$ is defined - so locally the recipe should work. What do you think $\oint \mathbf{u} \cdot d\mathbf{r}$ around the unit circle gives? Zero - since the curl is zero? Let's compute, and you'll see why we keep flagging the simply-connected hypothesis. But $D$ has a hole at the origin; it isn't simply connected. And indeed: the line integral of $\mathbf{u}$ around the unit circle gives $2\pi$, not zero. So no single-valued $f$ exists on all of $D$.
This same multi-valued behaviour is the reason magnetic potentials around a current-carrying wire are not single-valued - and why Ampère's law is genuinely about integrating around the wire, not about a global potential.
What still works: pick any simply connected sub-region of $D$ (a slit plane $\{x > 0\}$, or any open disc not containing the origin), and run the recipe there. You'll recover $f = \arctan(y/x) + C$ on the slit plane, $f = \theta$ in polar terms - exactly the angle function. Globally on $D$, $\theta$ is multi-valued: it jumps by $2\pi$ each time you loop the origin.
Multi-valued potentials are a real, useful object - not a failure mode. See §5.7 for how to use them: pick a system of "fundamental periods" (one per hole), and any line integral on $D$ becomes (single-valued part of $f$) + (integer combination of periods).