---
title: Conservative fields and potentials
heading: When the path doesn't matter
eyebrow: A9 · Lesson 25 · Conservative fields
xp: 40
---

::: hook
Kirchhoff's voltage law says the voltages around any loop of a circuit add to zero. It works because the electrostatic field is **conservative**: the work it does on a charge moving from A to B doesn't depend on the route, so going around a loop and back to the start always totals zero, and a potential (a voltage) exists at every point. Magnetic fields aren't like that: carry a compass needle once around a wire and the field has pushed it the whole way. Telling the two kinds apart, and finding the potential when it exists, is the subject of this lesson.
:::

::: play
- The field is $\mathbf{F} = \nabla(xy) + m(-y, x)$: a conservative part plus $m$ times a swirl.
- The circle is a closed path, and the readout is the work around it, $\oint\mathbf{F}\cdot d\mathbf{l}$.
- With $m = 0$ the field has a potential. What does the loop integral give? Turn on the swirl and watch it change.
:::
:::

```sim plot
view: flow
x: x = -2.5..2.5
y: y = -2..2
slider: m = -1..1 step 0.1 = 0
slider: R = 0.5..1.8 step 0.1 = 1.2
dx: y - m*y
dy: x + m*x
arrows: scaled
grid: 12
path: R*cos(2*pi*u), R*sin(2*pi*u) | over: u = 0..1 | work: W | color: ch2
readout: work around the loop = W
readout: 2πR²m = 2*pi*R^2*m
```

::: predict
## A field's work from A to B is the same along every path. What is its work around a closed loop?

- [x] Zero
- [ ] Twice the A-to-B work
- [ ] It depends on the loop's size
- [ ] It can't be known

::: reveal
Zero. Split the loop into a trip from A to B and a trip back along another path. Path independence makes the two trips cancel exactly. The two statements, "path doesn't matter" and "every closed loop gives zero", say the same thing.
:::
:::

::: nameit
## Four equivalent statements

For a field $\mathbf{F}$ on a region with no holes, these all say the same thing:

1. $\mathbf{F} = \nabla\varphi$ for some scalar **potential** $\varphi$.
2. $\int_A^B\mathbf{F}\cdot d\mathbf{l}$ depends only on the endpoints: it equals $\varphi(B) - \varphi(A)$.
3. $\oint\mathbf{F}\cdot d\mathbf{l} = 0$ around every closed loop.
4. $\nabla \times \mathbf{F} = \mathbf{0}$: in 2D, $\frac{\partial F_y}{\partial x} = \frac{\partial F_x}{\partial y}$.

Statement 4 is the quick test; statement 1 is the payoff.

## Finding a potential

Integrate one component and fix the leftover with the other. For $\mathbf{F} = (2xy + 1, x^2 + 3y^2)$: $\varphi = \int(2xy + 1)\,dx = x^2y + x + g(y)$; then $\varphi_y = x^2 + g'(y)$ must equal $x^2 + 3y^2$, so $g = y^3$ and $\varphi = x^2y + x + y^3$.

## Electrostatics and KVL

The electrostatic field is $\mathbf{E} = -\nabla V$, so the voltage between two points is $V(A) - V(B) = \int_A^B\mathbf{E}\cdot d\mathbf{l}$ along any path, and around any closed loop the voltages sum to zero: Kirchhoff's voltage law. (When magnetic fields change, the electric field picks up a non-conservative part; B6's induction is exactly that.)

## Holes matter

The field of a long wire, $\mathbf{B} \propto \left(\frac{-y}{x^2 + y^2}, \frac{x}{x^2 + y^2}\right)$, has zero curl everywhere except on the wire itself, yet any loop around the wire gives $2\pi$ (times a constant), not zero. The test in statement 4 needs a region without holes, and the wire is a hole.
:::

::: example
## Is $\mathbf{F} = (2xy + 1, x^2 + 3y^2)$ conservative? If so, find the work from $(0, 0)$ to $(1, 2)$.

::: solution
1. **Test the cross partials.**
   $$\begin{aligned} \frac{\partial F_y}{\partial x} &= 2x \\ \frac{\partial F_x}{\partial y} &= 2x \end{aligned}$$
   so yes, it's conservative.
2. **Find a potential.**
   $$\varphi = x^2y + x + y^3$$
3. **Work from the potential.** Along any path:
   $$\begin{aligned} W &= \varphi(1, 2) - \varphi(0, 0) \\ &= 2 + 1 + 8 \\ &= 11 \end{aligned}$$

**Answer:** yes, it's conservative, and the work is 11 along any path.
:::
:::

::: example
## Compute $\oint\mathbf{F}\cdot d\mathbf{l}$ for $\mathbf{F} = (-y, x)$ around the circle of radius $R$.

::: solution
1. **Field along the path.** On the circle, $\mathbf{F}$ points along the path with size $R$, so
   $$\mathbf{F}\cdot d\mathbf{l} = R\,dl$$
2. **Go around once.**
   $$\begin{aligned} \oint\mathbf{F}\cdot d\mathbf{l} &= R \times 2\pi R \\ &= 2\pi R^2 \end{aligned}$$
3. **Conclude.** Not zero, so this swirl field is not conservative; indeed
   $$\frac{\partial F_y}{\partial x} - \frac{\partial F_x}{\partial y} = 2$$

**Answer:** the circulation is $2\pi R^2$, not zero, so the field isn't conservative.
:::
:::

::: example
## Find the work done by $\mathbf{F} = (y\cos x, \sin x)$ from $(0, 0)$ to $(\pi/2, 3)$.

::: solution
1. **Check that it's conservative.**
   $$\begin{aligned} \frac{\partial}{\partial y}(y\cos x) &= \cos x \\ \frac{\partial}{\partial x}\sin x &= \cos x \end{aligned}$$
   so it's conservative.
2. **Find a potential.** A potential is $\phi = y\sin x$, since $\phi_x = y\cos x$ and $\phi_y = \sin x$.
3. **Work from the potential.**
   $$\begin{aligned} W &= \phi\left(\tfrac\pi2, 3\right) - \phi(0, 0) \\ &= 3 - 0 \\ &= 3 \end{aligned}$$
   along any path at all, straight or wiggly.

**Answer:** the work is 3.
:::
:::

::: check
given: a = 2 | 3; b = 1 | 4; x1 = 1 | 2; y1 = 2 | 3
answer: a*x1^2*y1 + b*y1

## $\mathbf{F} = (2\given{a}xy, \given{a}x^2 + \given{b})$ is conservative. What work does it do from $(0, 0)$ to $(\given{x1}, \given{y1})$?

::: right
Right. $\varphi = ax^2y + by$, so the work is $\varphi(x_1, y_1) - \varphi(0, 0)$ = {answer}.
:::

::: misses
- [a*x1^2*y1] Include $by$ from the second component.
- [any] Not yet. Find $\varphi$ with $\nabla\varphi = \mathbf{F}$.
:::
:::

::: check
given: R = 2 | 3 | 4; m = 0.5 | 2
answer: 2*pi*m*R^2
tolerance: 0.5%

## What is $\oint\mathbf{F}\cdot d\mathbf{l}$ for $\mathbf{F} = \given{m}(-y, x)$ around the circle of radius {R}?

::: right
Right. $m \times 2\pi R^2$ = {answer}.
:::

::: misses
- [2*pi*m*R] On the circle the field's size is $mR$, and the circle's length is $2\pi R$.
- [0] This swirl field isn't conservative.
- [any] Not yet. $\mathbf{F}$ is tangent to the circle with size $mR$.
:::
:::

::: check
given: p = 2 | 3; q = 4 | 5
answer: p

## For which $k$ is $\mathbf{F} = (\given{p}y + 1, kx + y^{\given{q}})$ conservative?

::: right
Right. $\frac{\partial F_y}{\partial x} = k$ must equal $\frac{\partial F_x}{\partial y} = p$: $k$ = {answer}.
:::

::: misses
- [q] The $y^q$ term doesn't depend on $x$.
- [any] Not yet. Compare the cross partial derivatives.
:::
:::

::: check
given: VA = 12 | 5; VB = 3 | -2
answer: VA - VB
unit: V

## The potential is {VA} V at A and {VB} V at B. What is $\int_A^B\mathbf{E}\cdot d\mathbf{l}$, along any path?

::: right
Right. With $\mathbf{E} = -\nabla V$, $\int_A^B\mathbf{E}\cdot d\mathbf{l} = V(A) - V(B)$ = {answer}.
:::

::: misses
- [VB - VA] $\mathbf{E}$ points downhill in voltage: the minus sign flips the order.
- [any] Not yet. $\int_A^B\mathbf{E}\cdot d\mathbf{l} = -(V(B) - V(A))$.
:::
:::

::: check
given: v1 = 3 | 5; v2 = 4 | 2; v3 = -6 | -1
answer: -(v1 + v2 + v3)
unit: V

## Going around a loop, three branches have voltage rises of {v1}, {v2} and {v3} V. What is the fourth branch's rise?

::: right
Right. KVL: they total zero, so the fourth is {answer}.
:::

::: misses
- [v1 + v2 + v3] The four must sum to zero.
- [any] Not yet. $\oint\mathbf{E}\cdot d\mathbf{l} = 0$.
:::
:::

::: check
kind: choice

## $\mathbf{F} = \left(\frac{-y}{x^2 + y^2}, \frac{x}{x^2 + y^2}\right)$ has zero curl away from the origin. Is it conservative on the plane with the origin removed?

- [ ] Yes: zero curl means conservative
- [x] No: a loop around the origin gives $2\pi$
- [ ] Yes, but only far from the origin
- [ ] It isn't defined anywhere

::: right
Right. The region has a hole, so zero curl isn't enough. This is the magnetic field around a wire, and Ampère's law (lesson 42) is exactly that $2\pi$.
:::

::: misses
- [1] The curl test needs a region without holes.
- [3] Any loop that goes around the origin gives $2\pi$, however large.
- [any] Integrate around the unit circle.
:::
:::

::: check
kind: parts
given: a = 1 | 2; b = 2 | 3

## $\mathbf{F} = (2xy + 1, x^2 + 3y^2)$.

::: part
answer: a^2*b + a + b^3
tolerance: 0.5%

### What work does it do from $(0, 0)$ to $(\given{a}, \given{b})$?

::: misses
- [any] The potential is $\phi = x^2y + x + y^3$.
:::
:::
:::

::: check
kind: derivation
vars: x = -2..2, y = -2..2

## Find a potential for $\mathbf{F} = (y\cos x, \sin x)$.

::: step
answer: y*sin(x)

### What $\phi$ has $\phi_x = y\cos x$ and $\phi_y = \sin x$?
:::

::: step
answer: cos(x)

### Check: what is $\frac{\partial F_1}{\partial y}$ (which must equal $\frac{\partial F_2}{\partial x}$)?
:::

::: right
Right. $\phi = y\sin x$, and the cross-derivatives match.
:::
:::

::: explain
## Why does Kirchhoff's voltage law hold, in terms of fields?

::: model
In a circuit with no changing magnetic fields, the electric field is electrostatic, and such a field is the gradient of a potential, $\mathbf{E} = -\nabla V$. The voltage across each element is a difference of potentials, so going around a loop and adding the voltages is like walking around a hill and adding up every rise and fall: you end where you started, at the same height, so the total is zero. If a changing magnetic field threads the loop, $\mathbf{E}$ is no longer purely a gradient and the loop sum is the induced EMF instead.
:::
:::

::: practice

::: check
given: a = 1 | 3; b = 2 | 5
answer: a + b

## $\mathbf{F} = \nabla(\given{a}x + \given{b}y)$. What work does it do from $(0, 0)$ to $(1, 1)$?

::: misses
- [any] $\varphi(1, 1) - \varphi(0, 0)$.
:::
:::

::: check
given: R = 1..10 int
answer: 0

## What is $\oint\nabla(x^2y)\cdot d\mathbf{l}$ around the circle of radius {R}?

::: misses
- [any] A gradient field does no work around a closed loop.
:::
:::

::: check
given: a = 1..9 int
answer: 2*a

## What is $\frac{\partial F_y}{\partial x} - \frac{\partial F_x}{\partial y}$ for $\mathbf{F} = \given{a}(-y, x)$?

::: misses
- [a] Both terms contribute $a$.
- [any] $a - (-a)$.
:::
:::
:::
