---
title: Gauss's law
heading: Count the charge inside by counting field lines through the boundary
eyebrow: B2 · Lesson 10 · Gauss's law
xp: 40
---

::: hook
Draw any closed surface you like around some charges. The total electric flux out through it, the number of field lines crossing outward minus those crossing in, depends on only one thing: how much charge is inside. Not where it is, not what shape the surface has, not what charges are outside. A9.41 proved it with vector calculus; here you can test it on a field you control.

::: play
- Two long charged wires are seen end-on, carrying λ₁ and λ₂ nC per meter. The circle is a closed loop, and the readouts compare the flux out of it with the charge inside divided by $\varepsilon_0$.
- Move and resize the loop. Enclose one wire, then both, then neither. When does the flux change?
- Give the wires opposite charges and enclose both. What is the flux?
:::
:::

```sim plot
view: flow
x: x = -3..3 m
y: y = -2..2 m
slider: l1 = -2..2 step 0.25 = 1 nC/m
slider: l2 = -2..2 step 0.25 = -0.5 nC/m
slider: a = -2..2 step 0.1 = -1 m
slider: b = -1.5..1.5 step 0.1 = 0 m
slider: r = 0.2..2.5 step 0.1 = 0.6 m
dx: 17.98*(l1*(x + 1)/((x + 1)^2 + y^2) + l2*(x - 1)/((x - 1)^2 + y^2))
dy: 17.98*(l1*y/((x + 1)^2 + y^2) + l2*y/((x - 1)^2 + y^2))
grid: 18
dot: -1, 0 | label: λ₁
dot: 1, 0 | label: λ₂ | color: ch2
path: a + r*cos(u), b + r*sin(u) | over: u = 0..2*pi | flux: P | color: ch3
readout: flux out per meter (V) = P
readout: λ inside ÷ ε₀ (V) = (l1*step(r - sqrt((a + 1)^2 + b^2)) + l2*step(r - sqrt((a - 1)^2 + b^2)))*1e-9/8.854e-12
```

::: predict
## A closed surface surrounds +3 nC and −3 nC, with a +5 nC charge just outside it. What is the total flux out of the surface?

- [x] Zero
- [ ] $5\text{ nC}/\varepsilon_0$
- [ ] $3\text{ nC}/\varepsilon_0$
- [ ] $11\text{ nC}/\varepsilon_0$

::: reveal
Zero. The net charge inside is zero, and only charge inside counts. The outside charge's field lines enter the surface on one side and leave on the other, adding nothing net. The field on the surface is far from zero, though: Gauss's law fixes the total flux, not the field at each point.
:::
:::

::: nameit
## Gauss's law

$$\oint_S \mathbf E \cdot d\mathbf A = \frac{Q_\text{inside}}{\varepsilon_0}$$

The total electric flux out of any closed surface equals the net charge inside divided by $\varepsilon_0$. It's Coulomb's law rewritten: the $1/r^2$ fall-off of a point charge's field exactly balances the $r^2$ growth of a sphere's area, so the flux through any sphere around the charge is the same, and the same through any other closed surface too.

**What it gives you.** Gauss's law always holds, but it only *finds the field* easily when symmetry tells you the field's shape. Then choose a surface on which the field is constant and either perpendicular or parallel to it, and the integral becomes field times area:

- **Point charge or sphere** (spherical symmetry): a sphere of radius $r$. $E \cdot 4\pi r^2 = Q/\varepsilon_0$.
- **Long line or cylinder** (cylindrical symmetry): a cylinder of radius $r$ and length $L$. Only its curved side has flux: $E \cdot 2\pi rL = \lambda L/\varepsilon_0$, so $E = \lambda/(2\pi\varepsilon_0 r)$. The sim's wires use this field.
- **Large flat sheet** (planar symmetry): a short box straddling the sheet. Next lesson.

**Without symmetry**, like the two wires in the sim, Gauss's law still tells you the total flux but not the field at each point; for that you add up the fields of the charges (superposition).

**Conductors again.** A Gaussian surface drawn just inside a conductor has zero field everywhere on it, so it encloses zero net charge. That's why excess charge sits on a conductor's surface, and it's the key to shielding (lesson 12).
:::

::: example
## A ball of radius 5 cm carries 10 nC spread through it. What is the field 20 cm from its center?

::: solution
1. **Choose the surface.** A Gaussian sphere of radius 20 cm encloses all 10 nC, and by symmetry the field is the same all over it.
2. **Apply Gauss's law.**
   $$E \cdot 4\pi r^2 = \frac{Q}{\varepsilon_0}$$
3. **Solve for the field.**
   $$\begin{aligned} E &= \frac{kQ}{r^2} \\ &= 2.25\ \text{kV/m} \end{aligned}$$
   exactly as if the charge were a point at the center.

**Answer:** the field 20 cm from the center is 2.25 kV/m.
:::
:::

::: example
## A closed surface around an unknown component has a net outward flux of 565 V·m. What charge is inside?

::: solution
1. **Gauss's law.**
   $$\begin{aligned} Q &= \varepsilon_0\Phi \\ &= 8.85 \times 10^{-12} \times 565 \\ &= 5.0\ \text{nC} \end{aligned}$$
2. **No details needed.** Gauss's law gives the total without knowing how it's arranged.

**Answer:** 5.0 nC is inside.
:::
:::

::: check
given: q1 = 1..9 int; q2 = -9..-1 int; q3 = 1..5 int
answer: (q1 + q2)*1e-9/8.854e-12
unit: V*m
tolerance: 1%

## A closed surface contains {q1} nC and {q2} nC; a {q3} nC charge sits outside it. What is the total flux out?

::: right
Right. Only the charge inside counts: $(\given{q1} + \given{q2})\text{ nC}/\varepsilon_0$ = {answer}.
:::

::: misses
- [(q1 + q2 + q3)*1e-9/8.854e-12] The outside charge contributes no net flux.
- [(q1 - q2)*1e-9/8.854e-12] Add the charges with their signs.
- [any] Not yet. $Q_\text{inside}/\varepsilon_0$.
:::
:::

::: check
given: lam = 1..9 int; r = 1 | 2 | 5 | 10
answer: lam*1e-9/(2*pi*8.854e-12*r/100)
unit: V/m
tolerance: 1%

## A long wire carries {lam} nC per meter. Using Gauss's law, how strong is its field {r} cm away?

::: right
Right. $E \cdot 2\pi rL = \lambda L/\varepsilon_0$, so $E = \lambda/(2\pi\varepsilon_0r)$ = {answer}.
:::

::: misses
- [lam*1e-9/(4*pi*8.854e-12*(r/100)^2)] That's a point charge's field. A long line spreads over a cylinder, not a sphere.
- [lam*1e-9/(2*pi*8.854e-12*r)] Convert centimeters to meters.
- [any] Not yet. Use a cylinder around the wire.
:::
:::

::: check
given: Q = 1..9 int; r = 0.1 | 0.2 | 0.5 | 2
answer: Q*1e-9/(4*pi*8.854e-12*r^2)
unit: V/m
tolerance: 1%

## A {Q} nC charge sits at the center of a sphere of radius {r} m. Using Gauss's law, how strong is the field on the sphere?

::: right
Right. $E = Q/(4\pi\varepsilon_0r^2)$ = {answer}, which is Coulomb's $kQ/r^2$.
:::

::: misses
- [Q*1e-9/(8.854e-12*r^2)] The sphere's area is $4\pi r^2$.
- [Q*1e-9/(4*pi*8.854e-12*r)] Divide by the area, which goes as $r^2$.
- [any] Not yet. $E \cdot 4\pi r^2 = Q/\varepsilon_0$.
:::
:::

::: check
given: F = 1..9 int
answer: F*8.854e-12*1e9
unit: nC
tolerance: 1%

## The total flux out of a closed surface is {F} V·m. How much charge is inside?

::: right
Right. $Q = \varepsilon_0\Phi$ = {answer}.
:::

::: misses
- [F/8.854e-12*1e9] Multiply by $\varepsilon_0$: $Q = \varepsilon_0\Phi$.
- [any] Not yet. Rearrange Gauss's law.
:::
:::

::: check
kind: choice

## A Gaussian surface encloses no net charge. What can you conclude about the field on it?

- [ ] It's zero everywhere on the surface
- [x] The total flux is zero, but the field at individual points can be anything
- [ ] It points inward everywhere
- [ ] It's uniform

::: right
Right. Zero net flux means as much field goes in as comes out, not that there's no field.
:::

::: misses
- [1] Field from outside charges can pass through; only the total flux is zero.
- [3] Inward everywhere would mean net negative charge inside.
- [4] Gauss's law says nothing about uniformity.
:::
:::

::: check
kind: parts
given: q = 1 | 3 | 10

## A {q} nC charge sits at the center of a cube.

::: part
answer: q*1e-9/8.854e-12
unit: V·m
tolerance: 0.5%

### What is the total electric flux out through the cube's surface?

::: misses
- [q*1e-9/(6*8.854e-12)] That's one face. The whole surface encloses all the charge.
- [any] Not yet. $\Phi = q/\varepsilon_0$.
:::
:::

::: part
answer: q*1e-9/(6*8.854e-12)
unit: V·m
tolerance: 0.5%

### How much passes through one face?

::: misses
- [q*1e-9/8.854e-12] By symmetry the six faces share it equally.
- [any] Not yet. One sixth of $q/\varepsilon_0$.
:::
:::

::: right
Right. Gauss's law gives the total; symmetry divides it without any integration.
:::
:::

::: explain
## Why doesn't a charge outside a closed surface change the total flux through it?

::: model
Every field line from an outside charge that enters the surface somewhere must leave it somewhere else, since field lines only start and end on charges and there's no charge inside for it to end on. So each such line contributes one inward crossing and one outward crossing, which cancel. Only lines that begin or end inside the surface, on charges in there, cross it a net number of times.
:::
:::

::: practice

::: check
given: q = 1..9 int
answer: q*1e-9/8.854e-12
unit: V*m
tolerance: 1%

## What is the flux out of a closed surface around {q} nC?

::: misses
- [q*1e-9*8.854e-12] Divide by $\varepsilon_0$.
- [any] $Q/\varepsilon_0$.
:::
:::

::: check
given: lam = 1..9 int; r1 = 1 | 2; r2 = 4 | 5
answer: r2/r1
tolerance: 0.5%

## How many times stronger is a line charge's field at {r1} cm than at {r2} cm?

::: misses
- [(r2/r1)^2] A line's field falls as $1/r$.
- [any] $E \propto 1/r$ for a line.
:::
:::

::: check
given: q = 1..5 int; n = 2..5 int
answer: n*q*1e-9/8.854e-12
unit: V*m
tolerance: 1%

## A box contains {n} separate charges of {q} nC each. What is the flux out of it?

::: misses
- [q*1e-9/8.854e-12] Count all {n} charges.
- [any] Total charge inside over $\varepsilon_0$.
:::
:::
:::
