The previous topic told you what a magnetic field does — bends a moving charge's path, pushes on a current-carrying wire — without ever saying where a magnetic field actually comes from. Oersted's compass needle demands an answer: a current made that needle move, so a current must be creating a magnetic field around itself, the same way a charge creates an electric field around itself. What's the law?
The Biot-Savart law: building a field piece by piece
Split a current-carrying wire into infinitesimal segments , each carrying current . Just as a point charge contributes a piece to an electric field (Coulomb's law in differential form), each current element contributes a piece of magnetic field at a point displaced from it by (with the unit vector from the element to the field point):
This is the Biot-Savart law, and the constant (the permeability of free space) plays exactly the role played in Coulomb's law: a fixed conversion factor between the units chosen for current and the units chosen for field. Everything about the field's direction lives in the cross product — the field circles around the current element, perpendicular to both the wire and the line to the field point, never pointing straight at it the way an electric field does. That's the geometric fingerprint of magnetism: electric field lines start and end on charges; magnetic field lines wrap around currents in closed loops, with no beginning and no end.
Getting the total field at a point means integrating this contribution over the entire current distribution:
This is completely general and always works, in principle. In practice it can be a brutal integral, exactly the way Coulomb's law's field integral can be brutal for a complicated charge distribution — which is precisely the situation that motivated Gauss's law as a shortcut for symmetric cases. Magnetism has the identical shortcut, built from the identical kind of idea.
Ampère's law: the magnetic analog of Gauss's law
Gauss's law rewrote Coulomb's law as a statement about flux through a closed surface, exploiting symmetry to skip the direct integral entirely. The magnetic analog exploits Stokes' theorem instead of the divergence theorem, and it relates not flux but circulation — the line integral of around a closed loop — to the current passing through that loop:
This is Ampère's law. is the total current threading through any surface bounded by the closed loop you integrate around; it doesn't matter which surface you pick, bulging or flat, exactly as Stokes' theorem guarantees.
Here is where the derivation actually connects to something already built. Stokes' theorem says for any vector field . Apply it to :
Meanwhile, the enclosed current can be written as the flux of the current density through that same surface, . Ampère's law in integral form, , therefore reads
Since this has to hold for every surface bounded by every possible loop — not just one convenient choice — the integrands themselves must agree at every point, giving the differential form:
Read this the same way divergence and curl taught you to read such an equation: current density is a local source of circulation for the magnetic field, exactly as charge density is a local source of divergence for the electric field in Gauss's law. Two completely parallel statements, one for each field, both proven the same way — a local differential law and a global integral law, connected by an integral theorem, exactly the machinery built for this purpose.
Worked example
Use Ampère's law to find the magnetic field a distance from an infinite straight wire carrying current , and the field inside an ideal solenoid with turns per unit length carrying current . (click to reveal the solution)
Part 1 — the straight wire. Setting up: by the symmetry of an infinite straight wire, the field can only depend on the distance from the wire, and by the Biot-Savart law's cross product, it must circle the wire — so choose the Amperian loop to be a circle of radius centered on the wire, in the plane perpendicular to it. On this loop, is tangent to the circle everywhere and has the same magnitude at every point on it, by symmetry.
Evaluating the circulation integral: because is parallel to everywhere on this particular loop and constant in magnitude, it comes straight out of the integral:
using the fact that around a circle of radius is just its circumference, .
Applying Ampère's law: the loop encloses the entire wire, so , giving
The field falls off as — not — a direct consequence of the geometry: field lines here are circles that grow in circumference, not spheres that grow in area.
Part 2 — the ideal solenoid. Setting up: an ideal solenoid is idealized as producing a uniform field inside, parallel to its axis, and (approximately) zero field outside. Choose a rectangular Amperian loop: one long side of length buried inside the solenoid, parallel to the axis; the opposite side of the same length , running parallel to it but outside the solenoid, where the field is taken to be zero; and two short sides connecting them, perpendicular to the field, contributing nothing to the circulation since there.
Evaluating the circulation integral piece by piece: the outside segment contributes zero ( there); each perpendicular segment contributes zero (); only the inside segment survives, where is uniform and parallel to :
Counting the enclosed current: the rectangular loop of length encloses individual turns of wire (since there are turns per unit length), each carrying current , so
Applying Ampère's law:
with the length cancelling from both sides — as it must, since the loop's length was an arbitrary choice, and the physical field inside the solenoid can't depend on how long a loop we happened to draw. The result is uniform, independent of position inside an ideal (infinitely long) solenoid, and depends only on the turn density and the current — which is exactly why solenoids are the standard way to build a controllable, uniform laboratory magnetic field.
Where this leads
Ampère's law as written here — — is correct for steady, unchanging currents, and it will turn out to need one more piece before it's the complete story. But first, there's a second, independent way that magnetic fields connect to electric ones, running in the opposite direction: a changing magnetic field turns out to create an electric field, all on its own, with no charges required. That's Faraday's law, and it's the last ingredient needed before all of electricity and magnetism can be assembled into one unified set of equations.