Magnetic Field Lines, Explained

After reading this you can predict the field-line pattern of one or several bar magnets, compute the field vector at any point from the pole model, and read filing streaks the way Faraday did.

What the simulation shows

Drop a bar magnet on the dark board and thousands of tiny tracer particles start to crawl. Each one rides the local magnetic field direction and leaves a short glowing streak. Half the tracers move along +\vec{B} and half against it, so the streaks trace the same curves in both directions. Together they sketch the field lines: dense loops that leave the north pole, sweep out into space, and dive back into the south pole.

Here is the hook. Place two magnets end to end with opposite poles facing, and the streaks between them straighten into a bridge of parallel lines. Flip one magnet so like poles face, and the bridge collapses: the lines bend away and a gap of near-zero field opens between them. Nothing in the code tells the filings to do this. They only follow the summed field vector at their own position, and the pattern falls out of that single rule.

When this model helps, and when it misleads

Use the simulation to build intuition about direction and relative strength. It answers questions like "which way does the field point here?" and "where is the field strongest?" honestly. It is a faithful picture of a 2D slice through a static magnetic field made of dipoles.

Do not read absolute numbers off it. The strength slider is a display gain, not a value in tesla. The tracers show field direction, not force on a compass needle over time, and they ignore the magnetisation physics inside real iron. A real bar magnet is a volume of aligned dipoles, not two point poles, so the field very close to the ends differs from the toy.

Magnetic monopoles have never been observed. The two-pole model is a calculating trick that reproduces the far field of a dipole correctly. It is exact for the field of a genuine dipole once you are a few magnet-lengths away.

The formula behind each streak

Each magnet is modelled as two opposite point poles at its ends, a north pole of strength +q_m and a south pole of strength -q_m. A single pole produces a field that points radially and falls off with the square of distance:

\vec{B}(\vec{r}) = \frac{k\, q_m}{r^2}\, \hat{r}

Here \vec{r} is the vector from the pole to the observation point, r = |\vec{r}| is its length, \hat{r} = \vec{r}/r is the unit vector along it, q_m is the pole strength (positive for north, negative for south), and k is a constant that folds into the strength slider. A north pole pushes the field outward; a south pole pulls it inward.

The total field at a point is the vector sum over every pole on the board. This is superposition, and it is the whole engine:

\vec{B}_{\text{total}}(\vec{r}) = \sum_{i} \frac{k\, q_{m,i}}{r_i^2}\, \hat{r}_i

Each tracer reads \vec{B}_{\text{total}} at its own location and steps a small distance along it (or against it, for the reversed half). Because the field is smooth, neighbouring tracers step in nearly the same direction, and their streaks line up into continuous curves.

A worked example with the default two magnets

The demo loads two magnets with opposite poles facing, the arrangement that attracts. Put the board on a grid where 1 unit is a comfortable fraction of the magnet length, and use k q_m = 1 for each pole so the arithmetic stays clean.

Field at the midpoint between two attracting magnets

Place the left magnet's north pole at (-1, 0) and the right magnet's south pole at (+1, 0). Both face inward. Find the field at the origin (0, 0), the midpoint.

  1. From the north pole at (-1, 0) to the origin: \vec{r} = (1, 0), so r = 1 and \hat{r} = (1, 0). A north pole pushes outward, so this contributes \vec{B}_1 = (1)/(1^2)\,(1,0) = (1, 0).
  2. From the south pole at (+1, 0) to the origin: \vec{r} = (-1, 0), r = 1. A south pole pulls inward, so the field points toward it, giving \vec{B}_2 = (1)/(1^2)\,(1, 0) = (1, 0).
  3. Add them: \vec{B}_{\text{total}} = (2, 0). The field is horizontal, points from north to south, and has magnitude 2.

Both poles reinforce along the axis, which is why the streaks between opposite poles form that strong straight bridge. Now flip the right magnet so its north pole sits at (+1, 0). Step 2 reverses: \vec{B}_2 = (-1, 0). The sum is (0, 0). The field cancels at the midpoint, which is the dead spot you see between like poles.

Move off the axis and the cancellation is only partial. At (0, 0.5) with like poles facing, each pole sits a distance \sqrt{1^2 + 0.5^2} = 1.118 away, so r^2 = 1.25. The horizontal parts still cancel, but the vertical parts add, giving a small upward field of about 2 \times (1/1.25) \times (0.5/1.118) = 0.716. That is why the lines near a repulsion gap bow outward instead of vanishing everywhere.

Field magnitude along the line joining two attracting poles. It dips at the midpoint where distance to both poles is largest, then climbs steeply near each pole because of the inverse-square rise.

Explore superposition yourself

The single idea a static picture cannot show is how the whole pattern reorganises when one pole strength changes sign or size. Move the slider below and watch the midpoint field swing between reinforcement and cancellation.

With two poles of strength 1 at x = -1 and x = +1, the field at the midpoint is the vector sum of two inverse-square contributions. When both point the same way (attraction) the magnitudes add to 2; when they oppose (repulsion) they cancel to 0. Off the axis the cancellation is only partial.

Reading the filing pattern

Three visual cues carry almost all the information.

Line density
Where streaks crowd together the field is strong; where they spread out it is weak. Density is proportional to field magnitude, so twice as many lines per centimetre means roughly twice the field.
Line direction
The streak points along \vec{B}. Field lines leave the north pole and enter the south pole. A compass placed on a streak would align with it.
Neutral points
Places where the streaks fade to nothing are where \vec{B}_{\text{total}} = 0. The midpoint between two like poles is the clearest example, as the worked example showed.

Field lines never cross. If they did, the field would point two ways at once at the crossing, which is impossible for a single-valued vector. When two magnets compete, the lines bend and reconnect around a neutral point rather than intersecting.

Common mistakes when reading the board

The streaks are not the paths that a filing would travel over time. Iron filings and the tracers both settle along the field direction at each point; they do not flow down the line like water. A line shows orientation, not motion.

A second mistake is treating line count as an absolute strength. The tracer-density slider changes how many lines you draw, not how strong the field is. Double the density and every region gets more lines, so only the ratio between regions is meaningful.

A third mistake is expecting the near-pole field to be exact. The pole model puts all the strength at a single point, so the field blows up like 1/r^2 as you approach a pole. A real magnet spreads its magnetisation over a finite bar, so its near field is finite and flatter. Trust the pattern a magnet-length or more from the ends.

Finally, do not confuse the fade slider with physics. Slow fading leaves long ghost trails that look like motion; fast fading gives a crisp instantaneous snapshot. Neither changes the field itself.

Related simulations

Superposition of point sources drives several tools here. Wave Interference adds scalar wave amplitudes instead of field vectors, and the same summing rule produces bright and dark fringes rather than field lines. Lightning Simulator grows discharges along electric potential gradients, a close cousin of the field-direction idea. For a contrast in physics, Galaxy Collision Simulator also sums inverse-square contributions, but from gravity, which only attracts. If you want to watch tracer particles reveal a hidden pattern in a different medium, Chladni Plate Patterns gathers sand along nodal lines of a vibrating plate.

Frequently asked questions

Why do the field lines leave the north pole and enter the south?

By convention the north pole is where field lines emerge and the south is where they return, matching the direction a small compass needle would point. In the pole model the north pole has positive q_m, so its field points outward, and the south has negative q_m, so its field points inward.

Why can't two field lines cross?

A field line is tangent to \vec{B} everywhere. If two lines crossed, the field at the crossing point would need two different directions at once. The field is a single vector at each point, so crossings are impossible. Lines instead pinch together at neutral points where the magnitude drops to zero.

Is the field really inverse-square, given magnets have two poles?

Each pole contributes an inverse-square field. When you add the two, the leading term cancels and the combined dipole field falls off like 1/r^3 far away. So a single pole goes as 1/r^2, but a whole bar magnet goes as 1/r^3 at a distance. Both facts follow from the same superposition sum.

What does the strength slider actually change?

It scales k q_m, which sets the field magnitude and therefore how fast the tracers crawl. Turning it up speeds the animation and makes the pattern reorganise faster after you drag a magnet. It does not correspond to a real field strength in tesla.

How many tracers do I need to see the lines clearly?

A few thousand is enough for two magnets. Too few and the lines look grainy; too many and neighbouring streaks merge into a wash that hides the density contrast. Adjust until you can just resolve the gaps between adjacent lines.