Solenoid Magnetic Field Simulator
Turn a real coil in 3D and see why the field at its mouth is half the field at its centre, with the field drawn from a Biot-Savart sum.
Simulator
Drag the coil to turn it, or use the arrow keys. Space plays and pauses.
- Field at the centre 99.23 percent of the infinite-solenoid value, mu0 n I.
- 3.117 mT
- Field at the mouth 0.503 of the centre value. Tends to exactly one half for a long coil.
- 1.568 mT
- Length over diameter Long enough that mu0 n I is good to 0.77 percent at the centre.
- 8
- Uniform to 1 percent The usable region is always shorter than the coil, because the field falls before the mouth.
- 51.5 % of length
- Inductance Scales with the square of the turns, not linearly.
- 1542 uH
- Wire needed Turns times circumference. Easy to forget when choosing a radius.
- 78.5 m
- On axis
- mu0 n I
Two things to try. Shorten the coil to 200 mm at a 25 mm radius, a length over diameter of 4. The centre field falls 3 percent below mu0 n I, the uniform region shrinks to 32.5 percent of the length, and the mouth rises to 0.511 of the centre, above one half. Then lengthen the coil and watch both come good together: the centre closes on mu0 n I as the mouth closes on one half, and neither gets there without a long coil.
Citing this tool
Last updated . Add the date you accessed it as well, which a citation of a page that can change asks for. If a specific result matters, cite the permalink from the tool’s share row instead of this page: it reproduces the exact parameters.
The equation
Biot and Savart (1820), with Ampere (1823)
The field at the mouth is exactly half the field at the centre
Not roughly half. Half, in the limit of a long coil, and the reason is something you can see rather than derive.
Stand at the centre. Turns stretch away from you in both directions, and every one contributes to the field where you are. Now stand at the mouth. They stretch away in one direction only. The other half is not there, and its contribution is not there either.
The closed form says the same thing in one line. Each of its two terms belongs to one end of the coil, and each is a ratio between a distance along the axis and a straight-line distance to the rim. At the centre both terms are close to one. At the mouth one is close to one and the other is close to zero.
This is the commonest error in the topic. People learn
B = μ₀nI, where μ₀ is the
vacuum permeability, apply it at the
ends, and are wrong by a factor of two.
When μ₀nI is allowed, and when it is not
That formula is the limit for an infinitely long solenoid. Real coils are finite, so it is an approximation, and how good it is depends entirely on length over diameter.
| Length ÷ diameter | Centre field | Verdict |
|---|---|---|
| 25 | 99.9% | Use it freely |
| 10 | 99.5% | Fine for most work |
| 3 | 95% | Noticeably optimistic |
| 0.4 | 37% | Wrong by a factor of three |
Set a short length and a large radius in the tool and watch the centre field fall far below the dashed line on the plot. Nothing in the formula warns you that this happens, which is why the readout shows the centre field as a percentage of the ideal value.
The usable region is shorter than the coil
The field is highest at the centre and falls monotonically outward, reaching half at the mouth. There is no boundary where uniformity stops; it degrades the whole way.
So the number worth knowing is the fraction of the length over which the field stays within some tolerance of the centre. For a coil ten diameters long, staying within one percent gets you only about three fifths of the length. Wind a coil 200 mm long and 20 mm across and roughly 117 mm of it is usable; four fifths needs a coil about 24 diameters long.
Why the field vanishes so fast outside
Inside the coil, both ends of the winding push the field the same way and their contributions add. Step past the mouth and you are on the far side of the near end, so its contribution reverses and starts cancelling the other.
Within two or three radii beyond the coil the field has fallen to a few percent of its central value. That comes from the shape rather than from the winding: a bar magnet of the same size and shape, magnetised to match, has the same field outside it.
Turns count twice for inductance
Adding turns raises the field in proportion to the number of turns. It also raises the number of turns that field has to thread through. Flux linkage therefore goes as turns squared, so doubling the winding quadruples the inductance.
The formula for it, L = μ₀N²A/ℓ, carries the same assumption as
μ₀nI: a uniform field right to the ends. It overestimates a
short fat coil for exactly the same reason.
How the field in the picture is computed
Not sketched. Every arrow is computed at the point it sits on, by adding up the contribution of each piece of the winding: a segment’s field is proportional to the cross product of its length with the vector to the point you care about, falling off as the inverse square of the distance.
One detail makes the difference between a picture and a decoration. The winding has to be divided finely enough that the spacing between modelled rings is smaller than the coil radius. Divided too coarsely, at a ring spacing of twice the radius, the field at the centre came out 22 percent low. The check that the fine version is right is the axis: there an exact closed form exists, and the sum agrees with it to within a few tenths of a percent through the interior. That agreement is the only reason to trust the arrows off the axis, where there is nothing exact to compare against.
The arrows themselves are drawn from a coarser version of the same sum, which keeps the picture responsive and costs a few percent. They are less reliable close to the winding, within about half a radius of it inside the coil and about a radius outside, where the field is weak, and on the thinnest, longest coils the sliders allow, where the number of modelled rings is capped and they read low.
Why arrows and not field lines
Because the loops do not fit. Field lines are the usual way to draw this, and every textbook figure shows them closing in a neat oval around the coil. Trace them through the real field instead of drawing them by hand and they go a long way out: lines started inside this coil turn back at ten to twenty coil radii. A frame big enough to hold a closed loop is around forty radii across, and in it the coil itself is a few pixels wide.
So the textbook oval is schematic, not measured, and there is no honest way to show both the coil and its closed loops in one picture. Arrows have no such problem, and they carry the point of this page better anyway: the claim here is about the size of the field at two places, and an arrow’s length states a size where the spacing of a clipped line states nothing you can read off.
Common mistakes
- Using μ₀nI at the ends. It is a centre value for a long coil. At the mouth the field is half of it.
- Using μ₀nI on a short coil at all. At an aspect ratio below about 3 it is optimistic; below 1 it is simply wrong.
- Thinking the field depends on the coil’s area. It depends on turns per metre and current. Area enters the inductance and the flux, not the field.
- Assuming inductance scales with turns. It scales with turns squared.
- Treating the whole interior as uniform. The field is already falling long before the mouth.
- Confusing turns with turns per metre. Doubling both the turns and the length leaves the field unchanged and doubles the wire bill.
Model and assumptions
- Method
- Exact expression, no time stepping
- Repeatability
- Deterministic. The same link gives the same numbers on any machine.
What it assumes
- A finite solenoid of circular turns, with the on-axis field evaluated exactly from the geometry.
- Current is steady and the winding is treated as a uniform current sheet rather than discrete wires.
- No magnetic material anywhere, so the permeability is that of free space.
Where it stops holding. The plotted curve is the exact on-axis field, but the arrows are a numerical Biot-Savart sum over coaxial rings. They are good to a few percent except close to the winding: within about half a radius of it inside the coil, and within about a radius outside, where the field is weak. On coils more than about 300 radii long the ring count is capped and they read low. A real helical winding also adds a weak circumferential field outside the coil that the ring model leaves out.
Numerical accuracy
No time stepping, so nothing accumulates. The field plotted along the axis is a closed form, exact to rounding. The arrows are not: each is a numerical Biot-Savart sum over coaxial rings, each ring split into straight segments, so they carry a discretisation error that the curve does not, largest close to the winding and on the longest, thinnest coils.
Common questions
Why is the field at the end of a solenoid half the field at the centre?
Because of what you can see from each place. Standing at the centre, turns stretch away from you in both directions and every one of them contributes. Standing at the mouth, they stretch away in one direction only, so the contribution from the missing half is simply absent. For a coil long compared with its radius the result is exactly one half, and it falls out of the closed form in one line: at the centre both terms of the expression are near one, while at the mouth one term is near one and the other is near zero. This is the single most common error in the topic, because people learn B equals mu0 n I and then apply it at the ends, where it is wrong by a factor of two.
When does the formula mu0 n I actually apply?
At the centre of a coil that is long compared with its diameter, and nowhere else. It is the limit of an infinitely long solenoid, so it is an approximation whose error depends on the aspect ratio. At a length over diameter of about 10 the centre field is within a percent of it. At an aspect ratio of 1, a coil as long as it is wide, the centre field is only around 70 percent of mu0 n I, and for a short fat coil it can be under 40 percent. The readout here shows the centre field as a percentage of the ideal value precisely so that gap is visible rather than assumed away.
Why is the uniform region shorter than the coil?
Because the field starts falling well before you reach the mouth. It is at its maximum at the centre and decreases monotonically outward, reaching half at the end, so there is no sharp boundary where uniformity stops: it degrades continuously. The figure quoted here is the fraction of the length over which the field stays within one percent of its central value, and for a coil ten diameters long that is a little under three fifths of the length. Reaching four fifths takes a coil about 24 diameters long. This is the number that matters if you are building anything, because a solenoid is only useful over the region where the field can be treated as constant, and that region is always shorter than the coil you wound.
Why does the inductance grow with the square of the turns?
Because turns count twice over. Adding turns increases the field the coil produces, in proportion to the number of turns, and it also increases the number of turns that field has to thread through. Flux linkage is therefore proportional to turns times turns. That is why doubling the winding quadruples the inductance rather than doubling it, and why inductance is far more sensitive to turn count than the field is. The formula used here, mu0 N squared A over the length, has the same limitation as mu0 n I: it assumes the field is uniform right to the ends, so it overestimates a short fat coil.
How is the field in the picture calculated?
By summing the Biot-Savart contribution of every piece of the winding. The coil is treated as a stack of circular rings, each divided into short straight segments, and each segment contributes a field proportional to the cross product of its length with the vector to the point of interest, falling off as the inverse square of the distance. Nothing is sketched and nothing is interpolated from the on-axis formula. The check that this is right is that along the axis, where an exact closed form exists, the sum agrees with it to within a few tenths of a percent through the interior; that agreement is what licenses the arrows off the axis, where there is nothing exact to compare against. The arrows themselves are drawn from a coarser version of the same sum, to keep the picture responsive, so they are good to a few percent and less reliable close to the winding and on the thinnest, longest coils the sliders allow.
Why does this draw arrows instead of field lines?
Because traced field lines do not fit in the picture. Every textbook figure of a solenoid shows lines closing in a neat oval around the coil, but those figures are drawn by hand rather than measured. Trace a line through the actual field and it goes a long way out: lines started inside a coil eight diameters long turn back at ten to twenty coil radii, so a frame large enough to contain one closed loop is around forty radii across, and in it the coil is a few pixels wide. There is no choice of starting point that avoids this, because it is a fact about where the flux returns. Arrows sample only the region on screen, so the problem cannot arise, and they state the size of the field at each point, which is what this page is about.
Why does the field collapse so quickly outside the coil?
Because outside the coil the two ends work against each other. Inside, both ends of the winding push the field the same way and their contributions add. Once you pass the mouth, you are on the far side of the near end, so its contribution reverses and partially cancels the other, and within two or three radii beyond the coil the field has fallen to a few percent of its central value. That comes from the shape rather than from the winding: a bar magnet of the same size and shape, magnetised to match, has the same field outside it.