Formula for the magnetic field due to a current loop

Remember, $\vec{\nabla} \times \vec{B} = \mu_0 \vec{J}$, and $\vec{J}$ will be zero anywhere except on the loop itself, where it will be singular. Do you mean, perhaps, that the line integral around the loop equals the current, a la Ampere's law?


As mentioned in the accepted answer, the second link in the original question (now hijacked) does have the correct exact expression for the magnetic field, which is essentially given by direct line integration of the vector potential into \begin{align} \mathbf A &= \frac{\mu_0 I}{4\pi} \oint_C \frac{\mathrm d\mathbf l}{r} \\ & = \frac{\mu_0 I}{2\pi} \frac{\sqrt{z^2+(R+\rho)^2}}{2R\rho} \Bigg[ \left(1-\frac{2R\rho}{z^2+(R+\rho)^2}\right) K\mathopen{}\left(\sqrt{\frac{4R\rho}{z^2+(R+\rho)^2}}\right)\mathclose{} \\& \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad - E\mathopen{}\left(\sqrt{\frac{4R\rho}{z^2+(R+\rho)^2}}\right)\mathclose{} \Bigg] \hat{\mathbf e}_\phi , \end{align} where $K(k)$ and $E(k)$ are complete elliptic integrals of the first and second kind, evaluated at the position-dependent argument $$ k=\sqrt{\frac{4R\rho}{z^2+(R+\rho)^2}}, $$ and where obviously $\rho^2=x^2+y^2$ and the current ring has radius $R$ in the $x,y$ plane. The magnetic field $\mathbf B$ can then be obtained by taking the curl of this vector potential, as usual. (Don't trust the exact detailed constants on my expressions, by the way ─ double-check everything if you're going to use it.)

The catch here, as mentioned in the accepted answer, is that the elliptic-integral functions have singularities at the argument $k=1$, which is reached when $z=0$ and $\rho=R$ (i.e. at the current ring), and those singularities need to be handled carefully when evaluating the derivatives in $\mathbf B=\nabla \times\mathbf A$: they almost certainly can be done rigorously, but to do so, you need to treat the derivatives of the singular functions as derivatives in the distributional sense, at which point they will give Dirac-delta contributions to the derivative that exactly match what's required for Ampère's law to hold with a Dirac-delta current density.