Solution (source code)

= Solution

<Ampère's law> in magnetostatics is
$$
\oint_\Gamma B\cdot d\ell=\mu_0 I_S,\qquad I_S=\int_SJ\cdot n\,dS,
$$
with boundary and surface orientations related by the right-hand rule. Stokes' theorem gives the left side as $\int_S(\nabla\times B)\cdot n\,dS$, proving the integral law from the stated curl equation.

For a circular contour of radius $r$ about the axis, the left side is $2\pi rB_\theta$. For $r\le a$ the enclosed current is $Ir^2/a^2$; for $r\ge a$ it is $I$. Therefore
$$
\boxed{B(r)=\begin{cases}\dfrac{\mu_0 I r}{2\pi a^2}\,e_\theta,&0<r\le a,\\[2mm]\dfrac{\mu_0 I}{2\pi r}\,e_\theta,&r\ge a.\end{cases}}
$$
Both expressions agree at the boundary. At the axis the field is zero, interpreted by <continuity> even though the angular unit vector is undefined there.