I am reading through Introduction to Electrodynamics by David J. Griffiths and came across the following problem:
A steady current $I$ flows down a long cylindrical wire of radius $a$. Find the magnetic field, both inside and outside the wire if the current is distributed in such a way that $J$ is proportional to $s$, the distance from the axis.
If $J$ is proportional to the distance from the axis $r$, then we have:
$$\vec{J}(\vec{r})=kr\,\boldsymbol{\hat{z}}$$
We also have:
$$\iint_{\Sigma} \vec{J}(\vec{r})\cdot\:\mathrm{d}\vec{A}=I$$
We therefore have:
$$\int_{0}^{2\pi}\int_{0}^{a}kr^{2}\:\mathrm{d}r\:\mathrm{d}\theta=\frac{2\pi k a^{3}}{3}=I $$
And therefore we have:
$$\vec{J}(\vec{r})=\frac{3Ir}{2\pi a^{3}}\,\boldsymbol{\hat{z}}$$
Using Ampére's law we have:
$$2\pi r B = \mu_{0}I \implies \vec{B}(\vec{r})=\frac{\mu_{0} I}{2\pi r}\,\boldsymbol{\hat{\theta}}$$
If we take a Ampérian loop inside the cylinder, we have:
\begin{align} 2\pi r B &= \mu_{0} \iint_{\Sigma}\vec{J}(\vec{r})\cdot\:\mathrm{d}\vec{A} \\ &= \mu_{0}\int_{0}^{2\pi}\int_{0}^{r}\frac{3 I r'^{2}}{2\pi a^{3}}\:\mathrm{d}r'\:\mathrm{d}\theta \\ &= \frac{\mu_{0} I r^{3}}{a^{3}} \end{align}
And therefore we have:
$$\vec{B}(\vec{r})=\begin{cases}\frac{\mu_{0} I r^{2}}{2\pi a^{3}} \,\boldsymbol{\hat{\theta}} & r < a \\ \frac{\mu_{0} I}{2\pi r}\,\boldsymbol{\hat{\theta}} & r \geq a \end{cases}$$
Is this the correct magnitude and direction of the magnetic field?