Magnetic Fields from Currents · Guide · glidepathscience.org
GuideMagnetic Fields from Currents
Contents
This Guide explains the ideas and equations behind every Walkthrough step, Concept Challenge question and Predict round, in the order a textbook takes them. Part 1 prepares the Intro track and Part 2 the Advanced track; each takes about a quarter of an hour to read. Each section ends with a worked example that is not one of the sim’s own problems. Throughout, x points east, y north and z up, out of the table; a loop’s axis is z.
Part 1 · The essentials
Math you’ll need: algebra, right-triangle trigonometry and adding vectors; calculus only in a box marked “With calculus.”
Currents make magnetic fields
In 1820 Hans Christian Ørsted noticed that a compass needle near a wire swung whenever a current flowed in the wire. Within weeks Jean-Baptiste Biot, Félix Savart and André-Marie Ampère had turned the observation into laws. Every current, however it flows, makes a magnetic field $\vec B$ in the space around it, and every magnetic field we use in a lab, from an electromagnet’s to a motor’s, comes from currents.
This Guide asks two questions about that field. How big is it, and which way does it point, near a wire, a loop or a coil? And how do two currents act on each other through their fields? The tools are a compass, which shows the field’s direction, and a probe, which measures its size. Fields are measured in teslas (T); Earth’s field is about 50 µT, so the fields of lab currents are usually quoted in microteslas (µT) and milliteslas (mT).
What a compass shows
A compass needle is a small magnet free to turn in the horizontal plane. It turns until it lines up with the net horizontal field where it sits: the vector sum of every source’s field, Earth’s included. It does not single out the nearest source, and it is not drawn toward a current: it only lines up with the total.
Earth’s field supplies a steady reference. At a mid-latitude town in the United States its horizontal part is roughly 20 µT, pointing north (the field also dips steeply into the ground, but a level needle feels only the horizontal part). A vertical wire makes a horizontal field that circles it. Due north of the wire that field points east or west, at right angles to Earth’s, so the needle swings to an angle θ from north given by
$\tan θ = B_w/B_h$
where $B_w$ is the wire’s field and $B_h$ Earth’s. Where the wire’s field points exactly against Earth’s and is just as large, the two cancel: a neutral point. There the needle has nothing to line up with, and friction holds it wherever it was left. A vertical wire has one neutral point, on the side where its field points south.
Biot–Savart: every piece contributes
Biot and Savart found how each short piece of a current contributes. A piece of length $dl$ carrying current $I$ adds, at a point P a distance $r$ away,
$dB = \frac{μ_0}{4π}\frac{I\,dl\sin θ}{r^2}$
where θ is the angle between the piece and the line from it to P, and $μ_0$ = 4π × 10⁻⁷ T·m/A is the permeability of free space (since 2019 measured rather than defined, but equal to that value to about one part in 10¹⁰). The contribution points at right angles to both the piece and the line to P, by the right-hand rule. The field of the whole current is the sum of all its pieces’ contributions.
Two features matter most. The contribution falls as $1/r^2$, so nearby pieces dominate; and a piece pointed straight at P, with θ = 0, adds nothing at all. For a straight wire with P a distance $R$ from its line, adding up the pieces gives
$B = \frac{μ_0 I}{4π R}(\sin θ_2 − \sin θ_1)$
where θ₁ and θ₂ are the angles from the perpendicular to the wire’s two ends, measured from P (negative on one side of the perpendicular, positive on the other). On the perpendicular bisector the two terms are equal.
The long straight wire
When the wire extends far beyond P in both directions, θ₁ → −90° and θ₂ → +90°, and the finite-wire formula becomes
$B = \frac{μ_0 I}{2π R}$
The field lines are circles centered on the wire, in planes at right angles to it. Grip the wire with your right hand, thumb along the current: your fingers curl the way B points. The field falls as $1/R$, not $1/R^2$: a long wire is a line of current, and its field spreads over circles whose length grows only in proportion to R.
Currents push on currents
A current in a magnetic field feels a force, so two currents push on each other: each sits in the other’s field. For two long parallel wires a distance $r$ apart, wire 2 sits in wire 1’s field $μ_0 I_1/2πr$, and the force on each length $l$ of it is
$F/l = \frac{μ_0 I_1 I_2}{2π r}$
Currents running the same way attract; currents running opposite ways repel. The formula is symmetric in $I_1$ and $I_2$, so the force on each wire has the same size, whatever the currents: the larger current sits in the smaller current’s weaker field. Newton’s third law holds.
From 1948 to 2019 this force defined the ampere: one ampere was the current that, in two long parallel wires 1 m apart, gives a force of 2 × 10⁻⁷ N on each meter. The ampere is now defined through the electron’s charge, and μ₀ is measured.
Loops: the center and the axis
Bend the wire into a circle of radius R. At the center every piece is the same distance R away and at right angles to the line to the center, so every piece contributes fully, in the same direction, and the sum is simply $2πR$ times one piece’s share. With N turns at one place, each adding the same,
$B = \frac{μ_0 N I}{2R}$
On the axis, a distance z from the center, each piece’s contribution tilts, and only its part along the axis survives the sum around the loop:
$B = \frac{μ_0 N I R^2}{2(z^2 + R^2)^{3/2}}$
At z = 0 this is the center’s value. Far out, where z is much larger than R, it falls as $1/z^3$, much faster than a wire’s $1/R$. (In this sim the loop’s axis is z, the axis of its 3-D drawings; some books put it along y.)
Ampère’s law
Biot–Savart adds up pieces; Ampère’s law looks at a whole closed path at once. Walk around any closed path, adding up at each step the part of B along the path times the step’s length. The total, the circulation, is
$\sum B_\parallel\,Δl = μ_0 I_{enc}$
where $I_{enc}$ is the current threading the path (counted positive by the right-hand rule: fingers along the path, thumb along the current). The path’s shape and size do not matter, and currents outside it do not count. A path around no current gives zero, although B is not zero along it: where B runs with the path and where it runs against it cancel exactly.
The law is always true, but it gives B itself only when symmetry makes B the same size and along the path all the way round. Then $B L = μ_0 I_{enc}$, with L the path’s length. A circle centered on a long wire gives $B·2πR = μ_0 I$, the long-wire formula again. Inside a wire of radius R with its current spread evenly, a circle of radius r encloses the fraction $(r/R)^2$ of the current, so
$B = \frac{μ_0 I r}{2π R^2}$
B is zero on the axis and largest at the surface, then falls as $1/r$ outside.
The toroid, and the solenoid it unrolls into
A toroid is a coil wound on a ring: N turns, each crossing the ring’s hole once. By symmetry its field runs in circles around the ring’s axis, inside the core. A circle of radius r inside the core encloses every turn once, NI, so
$B = \frac{μ_0 N I}{2π r}$
stronger near the inner edge than the outer. A circle inside the hole encloses no current, and one outside the ring encloses NI up and NI down: the field is zero there. An ideal toroid keeps its field entirely inside.
Cut the ring and straighten it into a long straight coil. $N/2πr$ becomes $n$, the number of turns per meter, and the field inside becomes uniform:
$B = μ_0 n I$
Outside a long solenoid the field is nearly zero. The Slinky Solenoid measures this field and its ends.
Part 2 · Going further
Math you’ll need: vectors and their components, logarithms, and some calculus: integrals along a path, and the curl in one section.
Building fields from pieces: polygons and arcs
Because fields add, any wire made of straight pieces and arcs can be solved piece by piece. A straight side of a regular n-gon is a finite wire seen from its center at a distance $R\cos(π/n)$, with R the circumradius, subtending ±π/n. Adding n of them,
$B = \frac{nμ_0 I}{2πR}\tan\frac{π}{n}$
which tends to the circle’s $μ_0 I/2R$ as n grows: 1.273 times the circumscribed circle’s field for a square, 1.103 for a hexagon. An arc of angle φ (in radians) contributes $μ_0 Iφ/4πR$ at its center: a semicircle gives $μ_0 I/4R$. A straight wire that ends beside the point, running off to infinity the other way, gives half a long wire’s field, $μ_0 I/4πR$; a straight piece aimed through the point gives nothing.
How fields fall off
The power of r with which a field falls says what kind of source it is. A long wire, a line of net current, falls as $1/r$. Two opposite currents close together, a cord out and back, nearly cancel: what remains, a line dipole, falls as $1/r^2$:
$B = \frac{μ_0 I d}{2π(r^2 + d^2/4)}$
A closed loop of any shape, seen from far away, is a magnetic dipole of moment $m = NIA$ ($NIπR^2$ for a circle), and on its axis
$B ≈ \frac{μ_0 m}{2π z^3}$
falling as $1/z^3$, exactly the shape of a small bar magnet’s field. The dipole formula overestimates the exact loop field close in; it is within 1 % beyond about 12 radii. Near a very wide sheet, at the other extreme, B hardly falls at all.
Many wires, crossed wires, and the ampere balance
With several parallel wires, each pair’s force is $μ_0 I_i I_j/2πr$ along the line between them, and the forces add as vectors. Three wires in a line, A, B and C, a spacing s apart, push on the middle one with
$F_x = \frac{μ_0 I_B(I_C − I_A)}{2π s}$
Wires that cross at right angles feel no net force: where the upper wire passes over one side of the lower, the force on it points one way, and over the other side the opposite way. They do feel a torque, which turns them toward lying parallel with their currents the same way.
A current balance weighs the force between two rods. Real rods are finite: two rods of length L a distance d apart repel with $\frac{μ_0 I^2}{2π d}(\sqrt{L^2 + d^2} − d)$, slightly less than the infinite-wire $μ_0 I^2 L/2π d$. Fitting with the infinite formula reads μ₀ low by a systematic error that more readings never remove.
A uniform field: the Helmholtz pair
Two equal coaxial coils carrying the same current, spaced exactly one radius apart, make a field that is unusually uniform near their midpoint. Each coil’s axial field is flat-topped at its center but curves downward away from it; at spacing R, the curvature of one coil’s field at the midpoint cancels the other’s, so the second derivative of B vanishes there. The midpoint field is
$B = (4/5)^{3/2}\frac{μ_0 N I}{R}$
Closer coils make a peak in the middle; farther ones, a dip. Helmholtz pairs supply the uniform field of e/m tubes and cancel Earth’s field in calibration rooms.
Ampère’s law with winding numbers, cables and sheets
A path may wind round a current more than once, or the wrong way. Each current then counts once for each counterclockwise turn and minus once for each clockwise turn, its winding number w:
$\oint \vec B\cdot d\vec l = μ_0 \sum w_i I_i$
A coaxial cable carries I along its inner conductor (radius a) and back along its outer one (from b to c). A circle between the conductors encloses I; one inside the outer conductor encloses I minus part of the return, so
$B = \frac{μ_0 I}{2π r}\frac{c^2 − r^2}{c^2 − b^2}$
there, and outside the cable the enclosed current is zero: a coax neither makes nor feels a field outside it. A flat strip of width w carrying K amperes per meter of width has, a height y above its middle, $B = \frac{μ_0 K}{π}\arctan\frac{w}{2y}$. Close to a wide strip this is
$B = \frac{μ_0 K}{π}\arctan\frac{w}{2y} ≈ \frac{μ_0 K}{2}$
independent of the distance, as Ampère’s law with a rectangle straddling the sheet gives directly. A solenoid is two such sheets with opposite currents: their fields add inside, $μ_0 K = μ_0 nI$, and cancel outside.
The law at a point: the curl
Shrink an Amperian path around a point. The circulation per unit area of the path, as the path shrinks, is the curl of B, and Ampère’s law becomes a statement at every point:
$\nabla × \vec B = μ_0 \vec J$
where $\vec J$ is the current density. Wherever no current flows, the curl is zero, even where the field lines circle something. Outside a long wire, a tiny path’s near side has a stronger field but a shorter arc than its far side, and the two cancel exactly. A small paddle wheel there would not turn; inside the wire it would.
Magnetic materials: an iron core
Matter responds to a field. Most materials respond weakly, described by a susceptibility χ, small and positive (paramagnets) or negative (diamagnets); ferromagnets such as iron respond enormously. Inside a closed toroid, Ampère’s law fixes $H = NI/2πr$ whatever the core is made of, and the field is
$B = μ_r\frac{μ_0 N I}{2π r}$
with $μ_r = 1 + χ$ the relative permeability, a few thousand for soft iron. That linear rule holds only up to saturation, about 1.5 T for soft iron, beyond which B grows only at the rate of air. An open core, a rod, gains far less than $μ_r$, because the poles at its ends oppose the magnetization; the closed ring avoids that.
Where Ampère’s law needs Maxwell
Ampère’s law as written assumes the current closes: what flows in returns. A lone segment of wire whose ends are charging breaks that. Biot–Savart still gives its field, and a circle of radius ρ around its middle, where the segment subtends a half-angle with $\sin θ = h/\sqrt{h^2 + ρ^2}$, has a circulation of only $μ_0 I\sin θ$. A different surface bounded by the same circle, a bubble that misses the wire, would enclose no current at all. The law must be completed. Maxwell added the displacement current, $ε_0$ times the rate of change of the electric flux through the surface:
$\oint \vec B\cdot d\vec l = μ_0\left(I + ε_0\frac{dΦ_E}{dt}\right)$
For the segment, the end charges’ growing field sends $−(1 − \sin θ)I$ through the flat disk, against the current, and the total matches Biot–Savart exactly. Between a charging capacitor’s plates, where no charge flows at all, the displacement current carries the whole of I, and a magnetic field circles the gap just as it circles the wires. The same term lets changing electric and magnetic fields sustain each other in light.
Reference
Common mistakes
Part 1
- Taking a compass to show only the nearest source’s field: it shows the net field, Earth’s included.
- Using $1/r^2$ for a long wire: a line of current falls as $1/r$.
- Swapping 4π and 2π: $μ_0/4π$ belongs to Biot–Savart and the finite wire, $2π$ to the long wire.
- Thinking the larger current feels the larger force: the forces between two wires are equal and opposite.
- Using the diameter for R in $μ_0 NI/2R$.
- Thinking B is largest at the center of a thick wire: it is zero there and largest at the surface.
- Using Ampère’s law to find B without symmetry: the law is always true, but gives B only when B is the same all along the path.
Part 2
- Using the dipole formula close to a loop, where it overestimates the field.
- Counting each current once when a path winds round it twice, or ignoring a clockwise turn’s sign.
The equation sheet
| Part 1 | |
|---|---|
| Biot–Savart | $dB = \frac{μ_0}{4π}\frac{I\,dl\sin θ}{r^2}$ |
| finite wire | $B = \frac{μ_0 I}{4π R}(\sin θ_2 − \sin θ_1)$ |
| long wire | $B = \frac{μ_0 I}{2π R}$ |
| compass | $\tan θ = B_w/B_h$ |
| two wires | $F/l = \frac{μ_0 I_1 I_2}{2π r}$ |
| loop’s center | $B = \frac{μ_0 N I}{2R}$ |
| loop’s axis | $B = \frac{μ_0 N I R^2}{2(z^2 + R^2)^{3/2}}$ |
| Ampère | $\oint \vec B\cdot d\vec l = μ_0 I_{enc}$ |
| inside a wire | $B = \frac{μ_0 I r}{2π R^2}$ |
| toroid | $B = \frac{μ_0 N I}{2π r}$ |
| solenoid | $B = μ_0 n I$ |
| Part 2 | |
|---|---|
| polygon | $B = \frac{nμ_0 I}{2πR}\tan\frac{π}{n}$ |
| semicircle; half wire | $B = \frac{μ_0 I}{4R}$; $B = \frac{μ_0 I}{4π R}$ |
| a cord | $B = \frac{μ_0 I d}{2π(r^2 + d^2/4)}$ |
| three in a line | $F_x = \frac{μ_0 I_B(I_C − I_A)}{2π s}$ |
| dipole | $B ≈ \frac{μ_0 m}{2π z^3}$, $m = NIπR^2$ |
| Helmholtz | $B = (4/5)^{3/2}\frac{μ_0 N I}{R}$ |
| winding | $\oint \vec B\cdot d\vec l = μ_0 \sum w_i I_i$ |
| coax, outer conductor | $B = \frac{μ_0 I}{2π r}\frac{c^2 − r^2}{c^2 − b^2}$ |
| strip | $B = \frac{μ_0 K}{π}\arctan\frac{w}{2y} ≈ \frac{μ_0 K}{2}$ |
| curl | $\nabla × \vec B = μ_0 \vec J$ |
| iron core | $B = μ_r\frac{μ_0 N I}{2π r}$ |
| Maxwell | $\oint \vec B\cdot d\vec l = μ_0\left(I + ε_0\frac{dΦ_E}{dt}\right)$ |
Symbols: $I$ a current; $R$ a distance from a wire, or a loop’s radius; $r$ a distance; θ an angle; $N$ turns, $n$ turns per meter; $z$ a distance along a loop’s axis; $B_h$ Earth’s horizontal field and $B_w$ a wire’s; $m$ a magnetic moment; $w$ a winding number, or a strip’s width; $K$ current per meter of width; $a$, $b$, $c$ a coax’s radii; $\vec J$ current density; $μ_r$ relative permeability; $Φ_E$ electric flux; μ₀ = 4π × 10⁻⁷ T·m/A and ε₀ = 8.85 × 10⁻¹² F/m.
Sources and further reading
- OpenStax, University Physics Volume 2, Chapter 12, “Sources of Magnetic Fields,” and §11.2, CC BY-NC-SA 4.0 (openstax.org): the Intro track follows its order of topics and notation, with the loop’s axis along z here.
- D. J. Griffiths, Introduction to Electrodynamics, chapter 5, for Biot–Savart, Ampère’s law and the curl, and chapter 7 for Maxwell’s correction.
- J. C. Hanson and S. P. Hirshman, Physics of Plasmas 9, 4410 (2002), and N. Derby and S. Olbert, American Journal of Physics 78, 229 (2010), for the closed forms the engine uses.
- NOAA’s World Magnetic Model, for the size and direction of Earth’s field at any town.
- This sim’s Field Manual (H) for the model and its limits; the Right-Hand Rule Trainer for every direction; the Slinky Solenoid for a measured μ₀nI; the Loop Torque Lab for forces on loops.
Magnetic Fields from Currents v1.1 · © 2026 Dr. David Meier · CC BY-NC-SA 4.0 · glidepathscience.org