Magnetic fields explained

A compass needle turns to the north because Earth is a magnet, and it turns away when a current flows in a wire nearby, because every electric current is surrounded by a magnetic field. This page explains how magnets and compasses were discovered, how Ørsted linked electricity and magnetism, how the Biot–Savart law gives the field of any current, why field lines are closed, how coils, solenoids and Helmholtz coils shape the field, what makes a permanent magnet, how currents push on each other, and what Earth's own field is like.

A solenoid seen in cross-section, its windings drawn as dots and crosses, with field lines running straight through it and looping round outside, and a grid of compass needles following the field
A solenoid seen in cross-section, its windings drawn as dots and crosses, with field lines running straight through it and looping round outside, and a grid of compass needles following the field

Magnets and compasses

Lodestone, a naturally magnetised iron ore, was known in ancient Greece and China for its pull on iron. Chinese scholars used it to make compasses: Shen Kuo described a magnetised needle pointing south and north in 1088, and by the 1100s sailors steered by it. In 1600 the English physician William Gilbert explained in De Magnete why a compass works: Earth itself is a great magnet. Every magnet has two poles, north and south; like poles repel and unlike poles attract, so the pole near Earth's geographic north, which attracts the north end of a compass, is in fact a magnetic south pole.

Ørsted's discovery

For centuries electricity and magnetism seemed to have nothing to do with each other. In April 1820 the Danish physicist Hans Christian Ørsted noticed, during a lecture, that a compass needle swung when he switched on a current in a wire above it, and that it swung the other way when the current was reversed. The needle did not point along the wire or away from it but across it: the magnetic field of a current runs round the wire in circles. Within weeks André-Marie Ampère in Paris showed that two currents attract or repel each other, and electromagnetism was born.

The Biot–Savart law

Later in 1820 Jean-Baptiste Biot and Félix Savart measured how the field depends on the current and the distance. In its modern form their law says that each small piece of wire dl carrying a current I adds a field dB = (μ₀ / 4π) I dl × r̂ / r², at right angles to both the wire and the direction r̂ to the point. Adding up all the pieces of a long straight wire gives B = μ₀I / 2πr. The magnetic constant μ₀ is 4π × 10⁻⁷ T m/A to within a part in a billion, and fields are measured in tesla. The app adds up the pieces exactly: for a loop and a solenoid the sum has a closed form with elliptic integrals.

Field lines and iron filings

Michael Faraday made the field visible by sprinkling iron filings on paper over a magnet: each filing becomes a tiny magnet and lines up along the field, and tapping the paper lets them settle into chains. He called the lines lines of force. Magnetic field lines have a property that electric ones do not: they never begin or end. No one has ever found a magnetic monopole, a north pole without a south pole, so every line closes on itself, running through a magnet from south to north and back round the outside. In Maxwell's equations this is Gauss's law for magnetism, ∇·B = 0.

Loops, solenoids and electromagnets

A loop of wire concentrates the field in its middle: a coil of N turns and radius R carrying a current I makes B = μ₀NI / 2R at its centre. Far away, its field has the same shape as that of a small bar magnet and falls with the cube of the distance; physicists call both a magnetic dipole. Wind many turns into a long tube, a solenoid, and the field inside becomes nearly uniform. Ampère's circuital law gives its strength, B = μ₀NI / L, independent of the tube's width; at the ends it falls to about half. Put an iron core inside and the iron's own magnetisation multiplies the field hundreds or thousands of times: an electromagnet, as in relays, cranes and loudspeakers.

Helmholtz and anti-Helmholtz coils

Hermann von Helmholtz noticed that two equal coils on the same axis, set as far apart as their radius, make a field that is unusually even between them: the decrease of one coil's field is made up by the increase of the other's so exactly that even the second derivative vanishes in the middle, where B = (4/5)^(3/2) μ₀NI / R. Helmholtz coils cancel Earth's field around delicate experiments and calibrate magnetic sensors. With the current reversed in one coil the fields cancel in the middle and grow evenly on either side. Such anti-Helmholtz coils, combined with laser beams, make the magneto-optical trap, first built in 1987, that cools atoms to millionths of a degree above absolute zero.

Permanent magnets

Ampère suggested that a magnet is full of tiny circulating currents. He was right in spirit: in iron, cobalt, nickel and some alloys the spins of electrons act like tiny magnets, and in a magnetised piece they line up. Inside, these elementary currents cancel, but at the surface they add up to a current flowing round the magnet, so a bar magnet has the same field as a solenoid of the same shape. A magnet's strength is given by its remanence Bᵣ: about 0.4 T for a ceramic ferrite magnet, 1.2 T for alnico and up to 1.4 T for neodymium–iron–boron, developed in the early 1980s and now found in every hard disk, headphone and electric car motor.

Forces on currents

A magnetic field pushes on a moving charge at right angles to its motion, and so on a current: the force on a wire of length L is F = I L × B. Two parallel wires each sit in the other's field; if their currents flow the same way they attract, and if they flow opposite ways they repel, with a force per metre of μ₀I₁I₂ / 2πd. From 1948 to 2019 this force defined the ampere: the current that, in two long wires 1 m apart, gives 2 × 10⁻⁷ newtons per metre. The same force turns every electric motor and moves the cone of every loudspeaker.

Earth's magnetic field

Earth's field is made by currents in its liquid iron outer core, kept going by convection and Earth's rotation: the geodynamo. At the surface it is between about 25 µT near the equator and 65 µT near the magnetic poles, and it tilts downwards in most places; a compass shows only its horizontal part. The magnetic poles wander, the north one by tens of kilometres a year recently, and every few hundred thousand years on average the whole field reverses. Near a current, Earth's field and the current's field add up; where they are equal and opposite there is a neutral point, where a compass has no preferred direction.

Frequently asked questions

What is the difference between B and H?

B, the magnetic flux density, measured in tesla, is the field that pushes on currents and turns compass needles; it is what the app draws. H, the magnetic field strength, measured in amperes per metre, leaves out the part that comes from the magnetisation of materials: H = B / μ₀ − M. In empty space and in air the two differ only by the factor μ₀, and many books simply call B the magnetic field.

How strong are everyday magnetic fields?

Earth's field is about 50 µT. A fridge magnet makes a few millitesla at its surface, a strong neodymium magnet about half a tesla, and a hospital MRI scanner 1.5 or 3 T over the whole body. The strongest steady fields made in laboratories are about 45 T, while the magnetic neutron stars called magnetars reach 10¹⁰ T, enough to distort atoms.

Why does a coil's field fall off so fast far away?

Seen from far away, the opposite sides of a loop carry currents in opposite directions, so their fields nearly cancel, and what is left falls with the cube of the distance instead of with the distance itself, as for a single wire. Double the distance from a small coil or a bar magnet and its field drops to an eighth. A long straight wire has no opposite side nearby, so its field falls only as 1/r.

Do magnetic monopoles exist?

No one has found one. Cut a bar magnet in half and you get two smaller magnets, each with a north and a south pole, down to single atoms. In 1931 Paul Dirac showed that a single monopole anywhere in the universe would explain why electric charge comes in whole multiples of the electron's charge, and some theories of the early universe predict them, but searches in cosmic rays, in moon rocks and at particle colliders have come up empty. So magnetic field lines stay closed.

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

Open the magnetic field simulator