Solution (source code)

= Solution

In <magnetostatics>, <Ampère's circuital law> is
$$
\oint_C\mathbf B\cdot d\boldsymbol\ell=\mu_0I_{\rm enclosed}.
$$
It relates magnetic circulation around a closed curve to the steady current through a spanning surface. It is especially useful when <symmetry> makes the tangential field constant on a chosen path: an infinite straight wire gives $B=\mu_0I/(2\pi r)$, while an ideal long <solenoid> gives approximately $B=\mu_0nI$ inside.

The <Biot-Savart law> gives the field contribution from the actual current geometry:
$$
\mathbf B(\mathbf r)=\frac{\mu_0I}{4\pi}\int\frac{d\boldsymbol\ell'\times(\mathbf r-\mathbf r')}{|\mathbf r-\mathbf r'|^3}.
$$
The <cross product> determines the direction by the <right-hand rule>. Integrating around a circular loop of radius $a$ gives $B=\mu_0I/(2a)$ at its centre. A finite wire segment can also be integrated directly, even though it lacks enough <symmetry> for an Ampère-loop shortcut. The full steady-current circuit includes a return path; a segment calculation specifies that segment's contribution.