Solution (source code)

= Solution

For steady <electric currents> in <vacuum>, <Ampère's circuital law> is
$$
\boxed{\oint_C\mathbf B\cdot d\mathbf l=\mu_0 I_{\rm enclosed}.}
$$
Choose an oriented closed contour and a spanning surface; the positive enclosed <electric current> crosses that surface according to the <right-hand rule> for the contour. First use the source <symmetry> to establish the direction of $\mathbf B$ and which positions have the same magnitude. Then choose the contour so its useful segments are parallel to $\mathbf B$ with constant magnitude, and the remaining segments are perpendicular to $\mathbf B$ or have vanishing field contribution. The <line integral> reduces to the unknown magnitude times a known length or sum of lengths.

For example, cylindrical <symmetry> around an infinite wire allows a circular contour, giving $B(2\pi r)=\mu_0I$. A uniform <current sheet> instead calls for a rectangle straddling it. The law is always valid in this magnetostatic setting, but by itself does not determine the local <magnetic field> from an arbitrary enclosed current without these extra <symmetry> arguments. Here $\mu_0$ is the <vacuum permeability>.