---
title: The gradient
heading: Which way is uphill, and how the electric field comes from voltage
eyebrow: A9 · Lesson 9 · The gradient
xp: 40
---

::: hook
Stand anywhere on a hillside and there's one direction that climbs fastest. That direction, together with how steep it is, is a vector: the gradient. Voltage in space is a landscape too, and the electric field is simply its gradient turned around: it points the way voltage falls fastest, and its strength is how fast it falls. That one fact connects circuits, where we talk about volts, to fields, where we talk about volts per meter.

::: play
- The map shows the voltage around two point charges in a plane: 1 nC on the left, and a charge you set on the right. Contour lines are equipotentials, joining points at the same voltage. The arrows show the electric field's direction.
- Move the probe. The arrow there points along the field. How does it sit relative to the contour line through the probe?
- Where are the contours crowded? Compare the field strength there with where they're sparse.
:::
:::

```sim plot
view: flow
x: x = -3..3 m
y: y = -2..2 m
slider: q2 = -2..2 step 0.25 = -1 nC
slider: x0 = -2.8..2.8 step 0.1 = 0 m
slider: y0 = -1.8..1.8 step 0.1 = 1 m
shade: 8.99*(1/sqrt((x + 1)^2 + y^2) + q2/sqrt((x - 1)^2 + y^2)) | contours: 16 | scale: 15
dx: (x + 1)/((x + 1)^2 + y^2)^1.5 + q2*(x - 1)/((x - 1)^2 + y^2)^1.5
dy: y/((x + 1)^2 + y^2)^1.5 + q2*y/((x - 1)^2 + y^2)^1.5
heads: on
dot: -1, 0 | label: +1 nC
dot: 1, 0 | label: q₂ | color: ch2
vec: x0, y0, 0.7*((x0 + 1)/((x0 + 1)^2 + y0^2)^1.5 + q2*(x0 - 1)/((x0 - 1)^2 + y0^2)^1.5)/sqrt(((x0 + 1)/((x0 + 1)^2 + y0^2)^1.5 + q2*(x0 - 1)/((x0 - 1)^2 + y0^2)^1.5)^2 + (y0/((x0 + 1)^2 + y0^2)^1.5 + q2*y0/((x0 - 1)^2 + y0^2)^1.5)^2), 0.7*(y0/((x0 + 1)^2 + y0^2)^1.5 + q2*y0/((x0 - 1)^2 + y0^2)^1.5)/sqrt(((x0 + 1)/((x0 + 1)^2 + y0^2)^1.5 + q2*(x0 - 1)/((x0 - 1)^2 + y0^2)^1.5)^2 + (y0/((x0 + 1)^2 + y0^2)^1.5 + q2*y0/((x0 - 1)^2 + y0^2)^1.5)^2) | label: E
readout: V at probe = 8.99*(1/sqrt((x0 + 1)^2 + y0^2) + q2/sqrt((x0 - 1)^2 + y0^2)) V
readout: |E| in V/m = 8.99*sqrt(((x0 + 1)/((x0 + 1)^2 + y0^2)^1.5 + q2*(x0 - 1)/((x0 - 1)^2 + y0^2)^1.5)^2 + (y0/((x0 + 1)^2 + y0^2)^1.5 + q2*y0/((x0 - 1)^2 + y0^2)^1.5)^2)
```

::: predict
## At any point, how does the electric field's direction sit relative to the equipotential line through that point?

- [ ] Along the line
- [x] Square to the line, toward lower voltage
- [ ] Square to the line, toward higher voltage
- [ ] At 45° to it

::: reveal
Square to it, pointing toward lower voltage. Along an equipotential the voltage doesn't change at all, so the field has no part along it. The fastest change is straight across, and the field points downhill: a positive charge released there would roll toward lower voltage.
:::
:::

::: nameit
## The gradient

The **gradient** of $f(x, y, z)$ collects its partial derivatives into a vector:

$$\nabla f = \left(\frac{\partial f}{\partial x},\ \frac{\partial f}{\partial y},\ \frac{\partial f}{\partial z}\right)$$

The symbol $\nabla$ is read "del" or "grad". Three facts make it useful:

1. **It points uphill**, in the direction where $f$ increases fastest.
2. **Its length is the steepest slope**: how much $f$ changes per meter in that best direction.
3. **It's perpendicular to the contour lines** (or, in 3D, the level surfaces), since along a contour $f$ doesn't change.

**The slope in any direction** comes from a dot product. For a unit vector $\hat u$, the **directional derivative** is

$$D_{\hat u}f = \nabla f \cdot \hat u = |\nabla f|\cos\theta$$

where θ is the angle between $\hat u$ and the gradient. Facing along the gradient gives the full slope; facing along a contour ($\theta = 90°$) gives zero.

**Electric field from voltage.** The electric field is the downhill gradient of the potential:

$$\mathbf{E} = -\nabla V$$

so its units are volts per meter. Between two parallel plates the voltage falls steadily across the gap, so $E = V/d$: 12 V across 2 mm is 6000 V/m. Around a point charge, $V = kq/r$ with $k = 8.99 \times 10^9$ N·m²/C², and the gradient gives $E = kq/r^2$, pointing straight out. Chip designers worry about exactly this: a few volts across a gate oxide a few nanometers thick is a field of hundreds of megavolts per meter.
:::

::: example
## A potential is $V = 5x^2 - 3y$ volts. Find $\mathbf{E}$ at $(1, 2)$.

::: solution
1. **Gradient.**
   $$\nabla V = (10x, -3)$$
2. **Field.**
   $$\begin{aligned} \mathbf{E} &= -\nabla V \\ &= (-10x, 3) \end{aligned}$$
3. **Evaluate at $(1, 2)$.**
   $$\mathbf{E} = (-10, 3)\ \text{V/m}$$
4. **Strength.**
   $$\begin{aligned} |\mathbf{E}| &= \sqrt{109} \\ &= 10.4\ \text{V/m} \end{aligned}$$

**Answer:** $\mathbf{E} = (-10, 3)$ V/m at $(1, 2)$, with strength 10.4 V/m.
:::
:::

::: example
## In which direction does $T = x^2 + y^2$ increase fastest at $(3, 4)$, and how fast?

::: solution
1. **Gradient.**
   $$\begin{aligned} \nabla T &= (2x, 2y) \\ &= (6, 8) \end{aligned}$$
2. **Direction.** The unit vector along it is $(0.6, 0.8)$, straight away from the origin.
3. **Rate.** The rate is the gradient's length,
   $$|\nabla T| = 10$$
   per unit distance.

**Answer:** $T$ increases fastest in the direction $(0.6, 0.8)$, straight away from the origin, at 10 per unit distance.
:::
:::

::: example
## How fast does $f = x^2y$ change at $(1, 2)$ moving in the direction $(3, 4)$?

::: solution
1. **Gradient at $(1, 2)$.**
   $$\begin{aligned} \nabla f &= (2xy, x^2) \\ &= (4, 1) \end{aligned}$$
2. **Unit vector.** The unit vector in the direction $(3, 4)$ is $\mathbf{u} = (0.6, 0.8)$.
3. **Directional derivative.**
   $$\begin{aligned} \nabla f\cdot\mathbf{u} &= 4 \times 0.6 + 1 \times 0.8 \\ &= 3.2 \end{aligned}$$
4. **Check against the fastest rate.** The fastest possible rate, along $\nabla f$ itself, is
   $$\begin{aligned} |\nabla f| &= \sqrt{17} \\ &= 4.12 \end{aligned}$$
   This direction is 39° off it, so it gets $4.12\cos 39° = 3.2$.

**Answer:** $f$ changes at 3.2 per unit distance in that direction.
:::
:::

::: check
kind: parts
given: a = 2..5 int; b = 1 | 3 | 5 | 7 | 9; x0 = 1 | 3; y0 = 2 | 4

## Find the gradient of $f(x, y) = \given{a}x^2 + \given{b}y$ at $(\given{x0}, \given{y0})$.

::: part
answer: 2*a*x0
tolerance: 0.5%

### What is its $x$ part?

::: misses
- [a*x0^2] That's part of the value. Differentiate with respect to x.
- [b] That's the y part.
- [any] $\partial f/\partial x = 2\given{a}x$.
:::
:::

::: part
answer: b
tolerance: 0.5%

### Its $y$ part?

::: misses
- [2*a*x0] That's the x part.
- [b*y0] Differentiate: $\partial(\given{b}y)/\partial y = \given{b}$.
- [any] $\partial f/\partial y$.
:::
:::

::: part
answer: sqrt((2*a*x0)^2 + b^2)
tolerance: 0.5%

### How steep is the steepest climb there?

::: misses
- [2*a*x0 + b] Combine the parts like the sides of a right triangle.
- [any] The length of the gradient: $\sqrt{(\partial_x f)^2 + (\partial_y f)^2}$.
:::
:::

::: right
Right. The gradient points uphill, and its length is the steepest slope.
:::
:::

::: check
given: gx = 2 | 4 | 6; gy = 1 | 3 | 5; th = 110 | 135 | 160 | 200
answer: gx*cos(th*pi/180) + gy*sin(th*pi/180)
tolerance: 0.5%

## At a point, $\nabla f = (\given{gx}, \given{gy})$. What is the slope of $f$ if you walk at {th}° from the $x$ axis?

::: right
Right. $\nabla f \cdot \hat u = \given{gx}\cos\given{th}° + \given{gy}\sin\given{th}°$ = {answer}.
:::

::: misses
- [sqrt(gx^2 + gy^2)] That's the steepest slope, along the gradient. This direction is different.
- [gx*sin(th*pi/180) + gy*cos(th*pi/180)] The x part pairs with cos θ and the y part with sin θ.
- [any] Not yet. Dot the gradient with $(\cos\theta, \sin\theta)$.
:::
:::

::: check
given: V = 3..24 int; d = 1 | 2 | 5 | 10
answer: V/(d/1000)
unit: V/m
tolerance: 0.5%

## Two parallel plates {d} mm apart have {V} V between them. What is the electric field between them?

::: right
Right. The voltage falls steadily across the gap, so $E = V/d$ = {answer}.
:::

::: misses
- [V*d/1000] Divide by the gap: the field is volts per meter.
- [V/d] Convert {d} mm to meters first.
- [any] Not yet. $E = V/d$ with d in meters.
:::
:::

::: check
given: a = 2..9 int; x0 = 1 | 3 | 4
answer: -2*a*x0
unit: V/m
tolerance: 0.5%

## Along a line, the voltage is $V(x) = \given{a}x^2$ volts (x in meters). What is $E_x$ at $x$ = {x0} m?

::: right
Right. $E_x = -dV/dx = -2\cdot\given{a}x$ = {answer}: the field points back toward lower voltage.
:::

::: misses
- [2*a*x0] The field is minus the gradient: it points downhill.
- [-a*x0^2] That's minus the voltage. Differentiate.
- [any] Not yet. $E_x = -\partial V/\partial x$.
:::
:::

::: check
kind: choice

## You walk along an equipotential line. How much work does the electric field do on a charge you carry?

- [x] None
- [ ] It depends on how fast you walk
- [ ] $qV$
- [ ] It depends on the path's length

::: right
Right. The voltage doesn't change along the line, so no energy changes hands: the field is square to your path the whole way.
:::

::: misses
- [2] Work by a static field depends only on the start and end voltages, which are equal here.
- [3] That's the work for a change of V. Along an equipotential, nothing changes.
- [4] The field is perpendicular to your steps, so each step does zero work.
:::
:::

::: check
kind: parts
given: a = 2 | 5; x = 1 | 2; y = 1 | 3

## A potential is $V = \given{a}x^2y$ volts ($x$, $y$ in meters).

::: part
answer: -2*a*x*y
unit: V/m
tolerance: 0.5%

### What is $E_x$ at $(\given{x}, \given{y})$?

::: misses
- [2*a*x*y] $\mathbf{E} = -\nabla V$.
- [any] $E_x = -\frac{\partial V}{\partial x}$.
:::
:::

::: part
answer: sqrt((2*a*x*y)^2 + (a*x^2)^2)
unit: V/m
tolerance: 0.5%

### What is $|\mathbf{E}|$ there?

::: misses
- [any] $|\nabla V|$.
:::
:::
:::

::: check
kind: derivation
vars: x = 0.5..3, y = 0.5..3

## Take $T = x^2 + y^2$.

::: step
answer: 2*sqrt(x^2 + y^2)

### What is $|\nabla T|$, the steepest rate of increase?
:::

::: step
answer: 2*x

### What is the directional derivative along $(1, 0)$?
:::

::: right
Right. Along the axis it's $2x$; along $\nabla T$ it's the full $|\nabla T|$.
:::
:::

::: explain
## Why is the electric field always perpendicular to equipotential surfaces?

::: model
An equipotential is a surface where V is the same everywhere, so moving along it changes V by zero. The change in V for a small step is the field dotted with the step, with a minus sign, so a zero change means the field has no part along any step within the surface. The only direction left is straight across it, and the field points the way V decreases.
:::
:::

::: practice

::: check
given: a = 1..9 int; b = 1..9 int
answer: sqrt(a^2 + b^2)
tolerance: 0.5%

## How steep is the steepest slope of $f = \given{a}x + \given{b}y$?

::: misses
- [a + b] The parts combine like the sides of a right triangle.
- [any] $|\nabla f| = \sqrt{a^2 + b^2}$.
:::
:::

::: check
given: q = 1..9 int; r = 0.1 | 0.2 | 0.5 | 2
answer: 8.99e9*q*1e-9/r^2
unit: V/m
tolerance: 1%

## How strong is the field {r} m from a {q} nC point charge?

::: misses
- [8.99e9*q*1e-9/r] That's the voltage, $kq/r$. The field is $kq/r^2$.
- [any] $E = kq/r^2$ with $k = 8.99 \times 10^9$.
:::
:::

::: check
given: a = 2..9 int; b = 2..9 int
answer: arg(-a - j*b)*180/pi
unit: °
tolerance: 0.5%

## On the plane $f = \given{a}x + \given{b}y$, in what direction (angle from the $x$ axis) does $f$ fall fastest?

::: misses
- [arg(a + j*b)*180/pi] That's uphill. Downhill is the opposite way.
- [any] Downhill is $-\nabla f = (-\given{a}, -\given{b})$.
:::
:::
:::
