An electric charge $q$ at the origin produces the field $$\mathbf{E} = \frac{q}{4\pi\varepsilon_0}\,\frac{\mathbf{r}}{|\mathbf{r}|^3},$$ an inverse-square field like gravity, where $\varepsilon_0$ is a physical constant. You computed in using the divergence theorem that $\frac{\mathbf{r}}{|\mathbf{r}|^3}$ has flux ${}4\pi$ through every closed surface around the origin. Multiply by $\frac{q}{4\pi\varepsilon_0}$: the electric flux is $q/\varepsilon_0$, whatever the surface. That is Gauss's law.
Key idea
Why it works
Many charges: fields add, so fluxes add.
Differential form: $$\iiint_E \nabla \cdot \mathbf{E}\,dV = \iint_S \mathbf{E} \cdot d\mathbf{S} = \frac{1}{\varepsilon_0}\iiint_E \rho\,dV$$ for every region $E$, so the integrands agree.
Worked examples
Worked example: Counting charges
- Inside (distance less than ${}2$): the first two. Outside: the third.
- Flux $= \frac{3 - 1}{\varepsilon_0} = \frac{2\,\mu\text{C}}{\varepsilon_0}$.
Answer: ${}2\,\mu\text{C}/\varepsilon_0$
Worked example: A charged ball
- By symmetry $\mathbf{E}$ points radially with size $E(r)$, so the flux through the sphere of radius $r$ is $E \cdot 4\pi r^2$.
- Outside ($r > R$): all of $Q$ is enclosed, so $E = \frac{Q}{4\pi\varepsilon_0 r^2}$, as if the charge sat at the center.
- Inside ($r < R$): the enclosed charge is $Q\frac{r^3}{R^3}$, so $E = \frac{Q r}{4\pi\varepsilon_0 R^3}$, growing linearly from ${}0$ at the center.
Answer: $\frac{Qr}{4\pi\varepsilon_0 R^3}$ inside, $\frac{Q}{4\pi\varepsilon_0 r^2}$ outside
Worked example: A charged wire
- Use a closed cylinder of radius $r$ and length $\ell$ around the wire. The field points straight out, so the end caps have zero flux and the side has $E \cdot 2\pi r\ell$.
- Gauss: $E \cdot 2\pi r\ell = \frac{\lambda\ell}{\varepsilon_0}$, so $E = \frac{\lambda}{2\pi\varepsilon_0 r}$.
Answer: $\frac{\lambda}{2\pi\varepsilon_0 r}$
Common mistake