Skip to content

Biot–Savart Field Builder

Learning goal

Ampère's law is quick but only works when the symmetry is perfect. Biot–Savart always works, but it means doing an integral. This widget does that integral numerically for real coil geometries and checks itself against every exact formula the course quotes.

Each conductor is chopped into current elements and

\[\mathbf{B} = \frac{\mu_0 I}{4\pi}\sum_i \frac{d\boldsymbol{\ell}_i\times\hat{\mathbf{r}}_i}{r_i^2}\]

is evaluated directly. Nothing is a stored picture.

Things to try

  1. Straight wire. The field circles the wire and falls as \(1/r\); the computed values track \(\mu_0I/2\pi r\) to about 0.015%. Check the readout for the radial and axial components: both are exactly zero. The field is purely azimuthal, which is what the right-hand rule means and what makes Ampère's law give the answer in one line.

  2. Single loop. On the axis the computed field matches \(\mu_0Ia^2/2(a^2+z^2)^{3/2}\) to machine precision. Now look off the axis in the arrow plot: that field has no elementary closed form — it needs elliptic integrals. This is exactly why textbooks only ever quote the axial result, and why the numerical sum earns its keep.

  3. Helmholtz pair. Two coils separated by exactly one radius. Watch the readout: not only does \(dB/dz\) vanish at the centre (that is just symmetry), but so does \(d^2B/dz^2\) — and that is the Helmholtz condition. Cancelling the second derivative as well leaves the field uniform to an unusually high order: it varies by only 0.01% over a tenth of a radius. This is how a genuinely uniform laboratory field is made.

  4. Change the separation in your head. The choice "separation = radius" is not arbitrary — it is the unique spacing that kills the second derivative. Any other spacing leaves a quadratic variation through the centre.

  5. Anti-Helmholtz. Reverse one current and the field cancels at the centre (to one part in \(10^{17}\)) and grows toward each coil. You have built a magnetic bottle — the field configuration behind the magnetic mirror that traps the Van Allen belts, and the same geometry used to trap cold atoms in a magneto-optical trap.

  6. Solenoid, and the honest end effect. Inside a long solenoid the field approaches the ideal \(\mu_0nI\) — but a finite one always falls short, and the readout says by how much (about 10% at the centre of this one, which is only four radii long). Textbooks mention end effects and rarely quantify them; here it is a number.

Ampère versus Biot–Savart

Both are correct always. The difference is practical:

Ampère's law Biot–Savart
Form \(\oint\mathbf{B}\cdot d\boldsymbol{\ell} = \mu_0I_{\rm enc}\) integral over current elements
Gives \(B\) directly only with enough symmetry always
Good for infinite wire, solenoid, toroid any geometry
Effort one line an integral (often numerical)

Ampère's law is true for the single loop too — but the field is not constant on any convenient loop, so \(\oint\mathbf{B}\cdot d\boldsymbol{\ell}\) cannot be pulled apart to isolate \(B\). The law still holds; it just stops being useful. That distinction is worth being clear about, because it is the same distinction as Gauss's law being universally true but only practically useful for spheres, cylinders and planes.

Biot–Savart law · Ampère's law · Magnetic field · Magnetic flux · Gauss's law for magnetism — note every field here is source-free · Magnetic mirror (PC368) — the anti-Helmholtz bottle