---
title: "Line integrals: voltage as a path integral"
heading: Adding up a field along a path
eyebrow: A9 · Lesson 24 · Line integrals
xp: 40
---

::: hook
Carry a charge from one point to another through an electric field and the field does work on it, a little on every step: more where the field is strong and pointed along your step, less where it's weak or sideways. The total is a line integral. The voltage between two points is exactly this sum, per coulomb. Usually it doesn't matter which way you walk; when it does, something interesting is going on, and it's the reason a transformer works.

::: play
- Two paths run from A to B through the field $\mathbf{F} = (2 - s y,\ 1 + s x)$. The straight path's total work is $W_1$. The curved one is walked as far as the slider $T$ says, and $W_2$ is the work so far.
- With $s = 0$, slide $T$ from 0 to 1. Where does $W_2$ grow fastest? Compare its final value with $W_1$. Change the bulge.
- Now set $s$ to something other than zero. Do the two paths still agree?
:::
:::

```sim plot
view: flow
x: x = -2.5..2.5
y: y = -2..2
slider: s = -1..1 step 0.1 = 0
slider: h = -1.5..1.5 step 0.1 = 1
slider: T = 0..1 step 0.02 = 1
dx: 2 - s*y
dy: 1 + s*x
arrows: scaled
grid: 12
path: -1.5 + 3*u, -1 + 2*u | over: u = 0..1 | work: W1 | color: ch2
path: -1.5 + 3*u, -1 + 2*u + h*sin(pi*u) | over: u = 0..T | work: W2 | color: ch1
dot: -1.5, -1 | label: A
dot: 1.5, 1 | label: B
readout: W₁ (straight) = W1
readout: W₂ (curved, so far) = W2
```

::: predict
## With $s = 0$ the field is the same everywhere, $(2, 1)$. How does the curved path's total work compare with the straight path's?

- [ ] It's larger, because the path is longer
- [ ] It's smaller, because part of it runs against the field
- [x] It's the same
- [ ] It depends on how much it bulges

::: reveal
It's the same, 8 in both cases. Wherever the curved path climbs against the field it gives back what it gained elsewhere. When the total depends only on the endpoints, the field is called **conservative**, and that's exactly when a voltage can be defined. With $s \ne 0$ the field has a swirl, and then the paths disagree: going around a loop gives you net work for free.
:::
:::

::: nameit
## The line integral

Break the path into small steps $d\mathbf{r}$. On each, the field does work $\mathbf{F} \cdot d\mathbf{r}$: the step's length times the part of the field along it. Adding them up:

$$W = \int_C \mathbf{F} \cdot d\mathbf{r}$$

**Computing it.** Describe the path by a parameter, $\mathbf{r}(u) = \big(x(u), y(u)\big)$ for $u$ from $a$ to $b$. Then $d\mathbf{r} = \mathbf{r}'(u)\,du$ and the line integral becomes an ordinary one:

$$\int_C \mathbf{F} \cdot d\mathbf{r} = \int_a^b \left(F_x\frac{dx}{du} + F_y\frac{dy}{du}\right) du$$

For example, $\mathbf{F} = (y, x)$ along $\mathbf{r}(u) = (u, u^2)$ from $u = 0$ to 1: $\int_0^1 (u^2 \cdot 1 + u \cdot 2u)\,du = \int_0^1 3u^2\,du = 1$.

**Voltage.** The work done on a charge per coulomb, by the field, is the drop in voltage:

$$V_B - V_A = -\int_A^B \mathbf{E} \cdot d\mathbf{l}$$

In a uniform field $E$ pointing along $x$, walking a distance $d$ along the field drops the voltage by $Ed$.

**Conservative fields.** These statements are all equivalent:

1. The line integral between any two points is the same for every path.
2. Around every closed loop, $\oint \mathbf{F} \cdot d\mathbf{r} = 0$.
3. $\mathbf{F}$ is a gradient, $\mathbf{F} = \nabla f$ (or $-\nabla V$), and then $\int_A^B \nabla f \cdot d\mathbf{r} = f(B) - f(A)$.

The electric field of static charges is conservative. That's what makes voltage well defined, and it's Kirchhoff's voltage law: around any loop of a circuit the voltages add to zero. A magnetic field that changes in time breaks it. It makes an electric field that circles around, like the $s$ part of the sim, and then the loop integral, the **EMF**, isn't zero. That's induction (course B6).
:::

::: example
## A constant force $\mathbf{F} = (2, 1)$ N moves an object from $(0, 0)$ to $(3, 1)$ m. How much work does it do?

::: solution
1. **Work of a constant force.** For a constant force the work is the dot product with the displacement, along any path:
   $$\begin{aligned} W &= \mathbf{F}\cdot\Delta\mathbf{r} \\ &= 2 \times 3 + 1 \times 1 \\ &= 7\ \text{J} \end{aligned}$$

**Answer:** the force does 7 J of work.
:::
:::

::: example
## Evaluate $\int\mathbf{F}\cdot d\mathbf{l}$ for $\mathbf{F} = (y, x)$ along $y = x^2$ from $(0, 0)$ to $(1, 1)$.

::: solution
1. **Find a potential.** $(y, x) = \nabla(xy)$, so the integral is $xy$ at the end minus at the start:
   $$1 - 0 = 1$$
2. **Check the long way.** With $x = t$, $y = t^2$:
   $$\begin{aligned} &\int_0^1(t^2 + t \cdot 2t)\,dt \\ &= \int_0^1 3t^2dt \\ &= 1 \end{aligned}$$

**Answer:** the integral is 1.
:::
:::

::: example
## Evaluate $\int\mathbf{F}\cdot d\mathbf{l}$ for $\mathbf{F} = (x^2, xy)$ along the straight line from $(0, 0)$ to $(1, 2)$.

::: solution
1. **Parametrize.** With $\mathbf{r} = (t, 2t)$, $0 \le t \le 1$:
   $$d\mathbf{l} = (1, 2)\,dt, \quad \mathbf{F} = (t^2, 2t^2)$$
2. **Integrate.**
   $$\begin{aligned} &\int_0^1(t^2 \cdot 1 + 2t^2 \cdot 2)\,dt \\ &= \int_0^15t^2\,dt \\ &= \tfrac53 \\ &= 1.67 \end{aligned}$$
3. **Note the path matters.** This field isn't conservative ($\partial(xy)/\partial x = y$ differs from $\partial(x^2)/\partial y = 0$), so another path between the same points would give a different answer.

**Answer:** the integral along the straight line is $\frac53 = 1.67$.
:::
:::

::: check
given: E = 100 | 200 | 500 | 1000; xa = 1 | 2; xb = 4 | 5 | 7
answer: -E*(xb - xa)/100
unit: V
tolerance: 0.5%

## A uniform field of {E} V/m points along $+x$. What is $V_B - V_A$ from $x$ = {xa} cm to $x$ = {xb} cm?

::: right
Right. $-\int \mathbf{E} \cdot d\mathbf{l} = -\given{E} \times (\given{xb} - \given{xa})$ cm = {answer}: walking along the field, the voltage drops.
:::

::: misses
- [E*(xb - xa)/100] Walking along the field, voltage falls: there's a minus sign.
- [-E*(xb - xa)] Convert centimeters to meters.
- [any] Not yet. $V_B - V_A = -E\,\Delta x$, with Δx in meters.
:::
:::

::: check
given: Fx = 2 | 4 | 6; Fy = -3 | -1; dx = 3 | 5; dy = 2 | 4
answer: Fx*dx + Fy*dy
unit: J
tolerance: 0.5%

## A constant field $\mathbf{F} = (\given{Fx}, \given{Fy})$ N acts on an object that moves in a straight line by $(\given{dx}, \given{dy})$ m. How much work does the field do, in joules?

::: right
Right. $\mathbf{F} \cdot \Delta\mathbf{r} = \given{Fx}\cdot\given{dx} + (\given{Fy})(\given{dy})$ = {answer}.
:::

::: misses
- [sqrt(Fx^2 + Fy^2)*sqrt(dx^2 + dy^2)] That's only right if the force points along the motion. Use the dot product.
- [Fx*dy + Fy*dx] Pair x with x and y with y.
- [any] Not yet. Work is $\mathbf{F} \cdot \Delta\mathbf{r}$.
:::
:::

::: check
given: a = 2..5 int; p = 1 | 2 | 3; q = 2 | 4
answer: a*p*q
tolerance: 0.5%

## Find $\int_C \mathbf{F} \cdot d\mathbf{r}$ for $\mathbf{F} = (\given{a}y,\ \given{a}x)$ along $\mathbf{r}(u) = (\given{p}u,\ \given{q}u^2)$, $u$ from 0 to 1.

::: right
Right. {answer}. Faster: $\mathbf{F} = \nabla(\given{a}xy)$, so the integral is $\given{a}xy$ at the end minus at the start, whatever the path.
:::

::: misses
- [a*p*q/2] Check the integral: $F_x x' + F_y y' = \given{a}(\given{q}u^2)(\given{p}) + \given{a}(\given{p}u)(2\given{q}u) = 3\given{a}\given{p}\given{q}u^2$.
- [3*a*p*q] Integrate $3u^2$ from 0 to 1: that gives 1, not 3.
- [any] Not yet. Substitute $x = \given{p}u$, $y = \given{q}u^2$ and $dx$, $dy$, then integrate over u.
:::
:::

::: check
given: k = 1..5 int; r = 2 | 3 | 4
answer: 2*pi*k*r^2
tolerance: 0.5%

## What is the circulation $\oint \mathbf{F} \cdot d\mathbf{r}$ of $\mathbf{F} = \given{k}(-y, x)$ counterclockwise around a circle of radius {r} centered at the origin?

::: right
Right. The field runs along the circle with strength $\given{k}r$, and the circle is $2\pi r$ long: $2\pi\given{k}r^2$ = {answer}.
:::

::: misses
- [2*pi*k*r] The field's strength on the circle is $\given{k}r$, and the length is $2\pi r$: multiply both.
- [0] Zero is the answer for a conservative field. This one swirls.
- [pi*k*r^2] The length of the circle is $2\pi r$.
- [any] Not yet. On the circle the field is tangent with strength $\given{k}r$.
:::
:::

::: check
kind: choice

## Why does Kirchhoff's voltage law hold in an ordinary circuit?

- [x] The electric field of static charges is conservative, so the voltage around any closed loop adds to zero
- [ ] Current is the same everywhere in a loop
- [ ] Every component has a voltage of zero on average
- [ ] Energy is stored in the components

::: right
Right. A conservative field has zero line integral around every loop, and the sum of voltages around a loop is that integral.
:::

::: misses
- [2] That's about current, Kirchhoff's other law in a single loop. KVL is about the field.
- [3] Individual voltages aren't zero; their sum around a loop is.
- [4] Storage doesn't explain it. The field being a gradient does.
:::
:::

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

## Evaluate $\int\mathbf{F}\cdot d\mathbf{l}$ for $\mathbf{F} = (x^2, xy)$ along the straight line from $(0, 0)$ to $(\given{a}, \given{b})$.

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

### What is it?

::: misses
- [any] With $\mathbf{r} = (at, bt)$: $\int_0^1(a^3t^2 + ab^2t^2)\,dt$.
:::
:::
:::

::: check
kind: derivation
vars: F1 = -5..5, F2 = -5..5, a = 0..4, b = 0..4

## A constant force $(F_1, F_2)$ moves an object from the origin to $(a, b)$.

::: step
answer: F1*a + F2*b

### What work does it do?
:::

::: right
Right. For a constant force the work is the dot product with the displacement, whatever the path.
:::
:::

::: explain
## A field has $\oint \mathbf{F} \cdot d\mathbf{r} \ne 0$ around some loop. Why can't it be written as the gradient of any potential?

::: model
If $\mathbf{F} = \nabla f$, then the line integral along any path is just $f$ at the end minus $f$ at the start. Around a closed loop the end is the start, so the integral would have to be zero. A nonzero loop integral means walking around and returning to the same point changes the supposed potential, so no single-valued $f$ can exist. Physically, it's a field that can do net work on a charge carried around a loop, like the electric field induced by a changing magnetic field.
:::
:::

::: practice

::: check
given: F = 2..9 int; d = 2..9 int; th = 30 | 60 | 120 | 150
answer: F*d*cos(th*pi/180)
unit: J
tolerance: 0.5%

## A constant {F} N force acts on an object moving {d} m in a straight line, at {th}° to the force. How much work does the force do?

::: misses
- [F*d] Only the part of the force along the motion does work: multiply by $\cos\theta$.
- [F*d*sin(th*pi/180)] It's the cosine of the angle between them.
- [any] $W = Fd\cos\theta$.
:::
:::

::: check
given: k = 2..9 int; r1 = 1 | 2; r2 = 3 | 4 | 5
answer: k/r1 - k/r2
unit: V
tolerance: 0.5%

## The voltage around a charge is $V = \given{k}/r$ volts (r in m). How much work does the field do per coulomb carrying a charge from {r1} m out to {r2} m?

::: misses
- [k/r2 - k/r1] The field does positive work as the charge moves to lower voltage: $V_A - V_B$.
- [k*(r2 - r1)] Use the potential at each end: $V(r) = \given{k}/r$.
- [any] Work per coulomb is $V_A - V_B$.
:::
:::

::: check
given: Ex = 1..9 int; Ey = 1..9 int; L = 1..5 int
answer: 0
tolerance: 0.001

## In a uniform field $(\given{Ex}, \given{Ey})$ V/m, you carry a charge around a square of side {L} m back to where you started. What is $\oint \mathbf{E} \cdot d\mathbf{l}$?

::: misses
- [4*L*sqrt(Ex^2 + Ey^2)] Opposite sides cancel: what you lose going one way you gain coming back.
- [any] A uniform field is conservative.
:::
:::
:::
