Solution (source code)

= Solution

Write the axial <current density> as $j(r)=Kr$. Normalize it using the total <electric current>:
$$
I=\int_0^a Kr\,2\pi r\,dr=\frac{2\pi Ka^3}{3},\qquad K=\frac{3I}{2\pi a^3}.
$$
The enclosed <electric current> at radius $r$ is $I_{\rm enc}(r)=2\pi Kr^3/3=I(r/a)^3$. The <magnetostatic Ampère law> now yields
$$
\boxed{B(r)=\frac{\mu_0 I r^2}{2\pi a^3}\quad(0\leq r\leq a).}
$$
Both profiles join the exterior <magnetic flux density> $\mu_0 I/(2\pi a)$ at the surface, but the second vanishes quadratically at the axis because less <electric current> is concentrated near it.