Biot–Savart always works but often means a hard integral. For electric fields, Gauss's law gave a shortcut when the charge had symmetry. Magnetism has its own shortcut, built not on flux through a closed surface but on the field around a closed path.
Key idea
Ampère's law: around any closed path,
$$\oint \vec{B}\cdot d\vec{\ell} = \mu_0 I_{\text{enc}},$$
where $I_{\text{enc}}$ is the net current through any surface bounded by the path. Sign: curl the fingers of your right hand along the path; current along your thumb counts as positive. Currents outside the path do not count.
Why it works
Start with one long wire and a circle around it. The field is $\mu_0 I/(2\pi r)$ and points along the circle, so $\oint\vec{B}\cdot d\vec{\ell} = \dfrac{\mu_0 I}{2\pi r}\cdot 2\pi r = \mu_0 I$: the radius cancels. For any path, $\vec{B}\cdot d\vec{\ell}$ around a wire is $\dfrac{\mu_0 I}{2\pi}\,d\varphi$, where $d\varphi$ is the angle the step sweeps out as seen from the wire. A path that goes around the wire sweeps a full $2\pi$; a path that does not enclose it sweeps out and back, for a total angle of zero. Fields add, so each enclosed current adds its own $\mu_0 I$.
Worked examples
Worked example: Counting currents
A path circles counterclockwise (seen from above) around a wire carrying $5.0\ \text{A}$ up (out of the page) and one carrying $2.0\ \text{A}$ down. A third wire, outside the path, carries $3.0\ \text{A}$. Find $\oint\vec{B}\cdot d\vec{\ell}$.
- Counterclockwise: out of the page is positive. $I_{\text{enc}} = 5.0 - 2.0 = 3.0\ \text{A}$; the outside wire does not count.
- $\oint\vec{B}\cdot d\vec{\ell} = (4\pi \times 10^{-7})(3.0) = 3.77 \times 10^{-6}\ \text{T·m}$.
Answer: $3.77 \times 10^{-6}\ \text{T·m}$
Worked example: The field of a long wire, from symmetry
Use Ampère's law to find $B$ at $2.0\ \text{cm}$ from a long wire carrying $10\ \text{A}$.
- By symmetry $\vec{B}$ circles the wire with the same size all around a circle of radius $r$, and points along it. So $\oint\vec{B}\cdot d\vec{\ell} = B(2\pi r)$.
- $B(2\pi r) = \mu_0 I$, so $B = \dfrac{\mu_0 I}{2\pi r} = \dfrac{(4\pi \times 10^{-7})(10)}{2\pi(0.020)} = 1.00 \times 10^{-4}\ \text{T}$.
Answer: $B = 100\ \text{μT}$
Worked example: Going the other way around
What is $\oint\vec{B}\cdot d\vec{\ell}$ for the first path if you go around it clockwise instead?
- Reversing the path reverses every $d\vec{\ell}$, so the integral changes sign: $-3.77 \times 10^{-6}\ \text{T·m}$.
- The right-hand rule agrees: clockwise makes into-the-page positive, so $I_{\text{enc}} = 2.0 - 5.0 = -3.0\ \text{A}$.
Answer: $-3.77 \times 10^{-6}\ \text{T·m}$
Common mistake
Counting currents outside the path. An outside wire does change $\vec{B}$ at every point of the path, so it feels as if it should count. But going around, its field helps on the near side and opposes on the far side, and those parts cancel exactly in the integral. Check: only currents that pierce a surface spanning the path go into $I_{\text{enc}}$.
Like Gauss's law, Ampère's law is always true, but it hands you $B$ only when symmetry makes $\vec{B}$ constant and along the path on the parts that matter. It also needs one correction when currents change in time: the displacement current.