---
title: Laplace's equation in a rectangle
heading: The potential inside a box, one side at a time
eyebrow: A12 · Lesson 33 · Laplace's equation in a rectangle
xp: 40
---

::: hook
A rectangular metal box with its lid at one voltage and its other walls grounded: what's the potential inside? It's Laplace's equation with boundary values on all four sides, and separation of variables solves it with a twist on the heat equation's method. Across the box the solution is made of sines, fitting the grounded side walls; up and down it's made of hyperbolic sines, growing toward the lid. Each sine mode reaches only a short way into the box before dying out, which is why fields from a slot or a seam leak so little into a shielded enclosure (C10).
:::

::: play
- A box of width a and height b: the top at $V_0$ (here 1), the other three sides at 0. The shading and contours are the potential, summed from the first four modes.
- Near the top, the contours bunch up into the corners, where the boundary value jumps from 1 to 0. Deeper in, they flatten into smooth arcs: the fine modes have died away.
- Make the box square: the readout shows the center at almost exactly 0.25. Make it tall and narrow: the center potential falls off fast, because the lid's influence decays over about a width.
:::
:::

```sim plot
view: flow
x: x = 0..1
y: y = 0..2
slider: b = 0.3..2 step 0.05 = 1
shade: 4/pi*(sin(pi*x)*sinh(pi*y)/sinh(pi*b) + sin(3*pi*x)*sinh(3*pi*y)/(3*sinh(3*pi*b)) + sin(5*pi*x)*sinh(5*pi*y)/(5*sinh(5*pi*b)) + sin(7*pi*x)*sinh(7*pi*y)/(7*sinh(7*pi*b)))*step(b - y) | contours: 12 | scale: 1
path: u, b | over: u = 0..1
readout: potential at the center (0.5, b/2) = 4/pi*(sinh(pi*b/2)/sinh(pi*b) - sinh(3*pi*b/2)/(3*sinh(3*pi*b)) + sinh(5*pi*b/2)/(5*sinh(5*pi*b)) - sinh(7*pi*b/2)/(7*sinh(7*pi*b)))
```

::: predict
## A square box has its top at $V_0$ and the other three sides at 0. What's the potential at its center?

- [ ] $V_0/2$
- [x] $V_0/4$
- [ ] $V_0/\pi$
- [ ] 0

::: reveal
Exactly $V_0/4$, without any series: rotate the problem four ways, so each side in turn is at $V_0$. Adding the four solutions gives a box with every side at $V_0$, whose potential is $V_0$ everywhere. By symmetry each of the four contributes the same at the center, so each gives $V_0/4$.
:::
:::

::: nameit
## Separation in a rectangle

For $\varphi_{xx} + \varphi_{yy} = 0$ on $0 < x < a$, $0 < y < b$, with $\varphi = 0$ on the sides x = 0, x = a and y = 0, and $\varphi = f(x)$ on y = b, try $\varphi = X(x)Y(y)$:

- $X'' + k^2X = 0$ with zero ends: $X_n = \sin(n\pi x/a)$, $k_n = n\pi/a$;
- $Y'' - k^2Y = 0$ with $Y(0) = 0$: $Y_n = \sinh(n\pi y/a)$.

$$\varphi = \sum_{n=1}^{\infty} c_n\sin\frac{n\pi x}{a}\,\frac{\sinh(n\pi y/a)}{\sinh(n\pi b/a)}$$

with $c_n$ the sine coefficients of f. For a constant lid at $V_0$, $c_n = 4V_0/(n\pi)$ for odd n.

## Several sides

With nonzero values on more than one side, solve one side at a time (the others at zero) and add: superposition.

## How far a mode reaches

Away from the lid, mode n falls off roughly as $e^{-n\pi d/a}$ at a depth d: by a factor $e^{-\pi} \approx 0.043$ per width a for the first mode. A slot of width a in a shield lets a field into the box only about a slot-width deep.
:::

::: example
## A square box has its four sides at 10, 20, 30 and 40 V. What's the potential at the center?

::: solution
1. **Each side's share.** Each side contributes a quarter of its voltage at the center.
2. **Add them.**
   $$\begin{aligned} \varphi &= \frac{10 + 20 + 30 + 40}{4}\ \text{V} \\ &= 25\ \text{V} \end{aligned}$$
   the average of the four.

**Answer:** the center is at 25 V.
:::
:::

::: example
## Using only the first term, estimate the center of a square box with its lid at 1 V.

::: solution
1. **The first term at the center.**
   $$\begin{aligned} \varphi &\approx \frac{4}{\pi}\sin\frac{\pi}{2}\frac{\sinh(\pi/2)}{\sinh\pi} \\ &= 1.273 \times \frac{2.301}{11.549} \\ &= 0.254\ \text{V} \end{aligned}$$
2. **Compare with the exact value.** That's within 2% of the exact 0.25 V; the higher terms alternate and nearly cancel.

**Answer:** about 0.254 V, within 2% of the exact 0.25 V.
:::
:::

::: example
## A box is twice as tall as it is wide. Its lid is at $V_0$ and the other three sides are grounded. What's the potential at its center?

::: solution
1. **Set up.** Take width a and height $b = 2a$, with the lid at $y = b$. The solution is
   $$\begin{aligned} \varphi = \sum_{n\text{ odd}}&\frac{4V_0}{n\pi}\sin\frac{n\pi x}{a} \\ &\times \frac{\sinh(n\pi y/a)}{\sinh(n\pi b/a)} \end{aligned}$$
   and the center is at $x = a/2$, $y = a$.
2. **The first term.**
   $$\begin{aligned} \varphi_1 &= \frac{4V_0}{\pi}\cdot\frac{\sinh\pi}{\sinh 2\pi} \\ &= 1.273 \times 0.04313\,V_0 \\ &= 0.0549\,V_0 \end{aligned}$$
3. **The third term.**
   $$\begin{aligned} \varphi_3 &= \frac{4V_0}{3\pi}(-1)\frac{\sinh 3\pi}{\sinh 6\pi} \\ &= -3.4 \times 10^{-5}V_0 \end{aligned}$$
   so the center sits at $0.0549\,V_0$.
4. **Why one term is enough.** Each extra width of depth divides a mode by about $e^{n\pi}$, so far from the lid only the first mode survives.

**Answer:** the center sits at $0.0549\,V_0$.
:::
:::

::: check
given: V1 = 0 | 10 | 5; V2 = 20 | 0; V3 = 30 | 12; V4 = 40 | 8
answer: (V1 + V2 + V3 + V4)/4
unit: V
tolerance: 0.5%

## A square box's four sides are at {V1}, {V2}, {V3} and {V4} V. What's the potential at its center?

::: right
Right. The average: {answer} V.
:::

::: misses
- [any] Not yet. Each side contributes a quarter of its value at the center.
:::
:::

::: check
given: V = 1 | 5 | 12; n = 1 | 3 | 5
answer: 4*V/(n*pi)
unit: V
tolerance: 0.5%

## A box's lid is at {V} V and its other sides at 0. What's the coefficient $c_n$ of mode n = {n}?

::: right
Right. $4V_0/(n\pi)$ = {answer} V.
:::

::: misses
- [any] Not yet. The sine coefficients of a constant: $4V_0/(n\pi)$, odd n.
:::
:::

::: check
given: n = 2 | 3 | 4; d = 0.5 | 1
answer: exp(-n*pi*d)
tolerance: 1%

## Roughly how much of mode n = {n} remains at a depth of {d} box-widths below the lid? (Use $e^{-n\pi d/a}$.)

::: right
Right. {answer}.
:::

::: misses
- [exp(-pi*d)] Higher modes die faster: include n.
- [any] Not yet. $e^{-n\pi d/a}$.
:::
:::

::: check
given: a = 1 | 2 | 5; f = 0.01 | 0.001
answer: a*ln(1/f)/pi
unit: mm
tolerance: 0.5%

## A slot {a} mm wide in a shield: how deep must a sensor sit for the slot's first mode to fall to {f} of its strength?

::: right
Right. $\frac{a}{\pi}\ln\frac{1}{f}$ = {answer} mm.
:::

::: misses
- [a*log(1/f)/pi] Natural log.
- [any] Not yet. Solve $e^{-\pi d/a} = f$.
:::
:::

::: check
given: V = 1..12 int
answer: 4*V/pi*sinh(pi/2)/sinh(pi)
unit: V
tolerance: 0.5%

## Using only the first mode, estimate the center of a square box whose lid is at {V} V.

::: right
Right. {answer} V, close to the exact {V}/4.
:::

::: misses
- [any] Not yet. $\frac{4V_0}{\pi}\frac{\sinh(\pi/2)}{\sinh\pi}$.
:::
:::

::: check
kind: choice

## Why does the solution use sines in x but hyperbolic sines in y?

- [ ] Because the box is wider than it is tall
- [x] Laplace's equation needs $X''/X = -Y''/Y$; oscillating in x (to vanish on both side walls) forces exponential growth or decay in y
- [ ] Hyperbolic sines are easier to differentiate
- [ ] Because the lid is at the top

::: misses
- [1] The shape doesn't decide it; the zero side walls do.
- [3] Ease has nothing to do with it.
- [4] If the lid were on a side wall, the roles of x and y would swap; the reason is still the sign in Laplace's equation.
:::
:::

::: check
kind: parts
given: V = 10 | 100; r = 1.5 | 2 | 3

## A box of width a and height {r}a has its lid at {V} V and its other sides grounded. Use the first mode only.

::: part
answer: 4*V/pi*sinh(pi*r/2)/sinh(pi*r)
unit: V
tolerance: 0.5%

### What is the potential at the center?

::: misses
- [4*V/pi*sinh(pi/2)/sinh(pi)] That's for a square box.
- [any] $\frac{4V}{\pi}\cdot\frac{\sinh(\pi y/a)}{\sinh(\pi b/a)}$ at $y = b/2$.
:::
:::

::: part
answer: 4*V/pi*sinh(3*pi*r/4)/sinh(pi*r)
unit: V
tolerance: 0.5%

### What is it on the centerline three quarters of the way up?

::: misses
- [any] Put $y = \frac34b$ in the first term.
:::
:::
:::

::: check
kind: derivation
vars: V = 1..10, a = 1..2, b = 1..3

## A box of width a and height b has $V\sin(\pi x/a)$ on its lid and 0 on its other sides, so $\varphi = V\sin\frac{\pi x}{a}\cdot\frac{\sinh(\pi y/a)}{\sinh(\pi b/a)}$.

::: step
answer: V*sinh(pi*b/(2*a))/sinh(pi*b/a)

### What is φ at the center?
:::

::: step
answer: V*pi/(a*sinh(pi*b/a))

### What is $\partial\varphi/\partial y$ at the middle of the bottom?
:::

::: right
Right. The field reaching the floor falls as $1/\sinh(\pi b/a)$, roughly $e^{-\pi b/a}$ for a deep box.
:::
:::

::: explain
## Why is the center of a square box with one side at $V_0$ exactly at $V_0/4$?

::: model
Laplace's equation is linear, so solutions add. Take the problem with the top at $V_0$ and three sides grounded, and its three rotations with each other side at $V_0$ in turn. Their sum has all four sides at $V_0$, and the potential in a box with every wall at $V_0$ is $V_0$ everywhere. At the center, rotating the square doesn't move the point, so the four problems all give the same value there; four equal values adding to $V_0$ must each be $V_0/4$.
:::
:::

::: practice

::: check
given: V1 = 8 | 2; V2 = 4 | 16; V3 = 0 | 6; V4 = 12 | 1
answer: (V1 + V2 + V3 + V4)/4
unit: V
tolerance: 0.5%

## Center of a square with sides {V1}, {V2}, {V3}, {V4} V?

::: misses
- [any] The average.
:::
:::

::: check
given: V = 2 | 9; n = 7 | 9
answer: 4*V/(n*pi)
unit: V
tolerance: 0.5%

## $c_n$ for a lid at {V} V, n = {n}?

::: misses
- [any] $4V_0/(n\pi)$.
:::
:::

::: check
given: n = 1 | 4; d = 0.3 | 2
answer: exp(-n*pi*d)
tolerance: 1%

## Fraction of mode {n} left at {d} widths deep?

::: misses
- [any] $e^{-n\pi d}$.
:::
:::
:::
