Divergence of magnetic field $B = \frac{\mu_0 I}{2\pi r}$

dirac deltamultivariable-calculusphysicsvector analysis

I have to show that the divergence of this magnetic field is 0. I can do this pretty easily using the divergence theorem; however, if I try using try computing the divergence directly $\nabla B$ does not equal $0$.
To solve it indirectly I used the definition that defines the divergence as the limit of a surface integral. I chose a cylindrical surface and then showed that the flux through that surface is zero as the field lines form circles.

Best Answer

The answer is quite simple. If I understand correctly, then you are solving the problem of a magnetic field around a infinite conductor with current. Writing down the equation for the magnetic field circulation, you got the $\phi$-th component of the magnetic field (only it is nonzero), i.e. \begin{equation} B_{\phi} = \frac{\mu_0 I}{2\pi r},\\ B_{z} = 0,\\ B_{r} = 0. \end{equation} The divergence in cylindrical coordinates is as follows \begin{equation} \vec{\nabla}\cdot\vec{B} =\frac{1}{r}\frac{\partial(r B_{r})}{\partial r} + \frac{\partial B_z}{\partial z} + \frac{1}{r}\frac{\partial B_{\phi}}{\partial\phi}, \end{equation} which is in your case is \begin{equation} \vec{\nabla}\cdot\left(\frac{\mu_0 I}{2\pi r}\vec{e}_{\phi}\right) = \frac{1}{r}\frac{\partial\left(\frac{\mu_0 I}{2\pi r}\right)}{\partial\phi} = 0, \end{equation} where $\vec{e}_{\phi}$ is the unit vector along $\phi$.