# Proof divergence of magnetic field is 0

I work in an R&D role that involves magnetism. I am refreshing my memory of electromagnetic and this stumps me. In polar coordinates, the magnetic field of a current loop for distances $R >> r$ is [reference]:

$$|u| =i \vec{A}$$

$$\vec{B} = \left ( 2 |u| \frac{\mu \cos \theta}{4 \pi |\vec{R}|^3}\right )\hat{r} + \left (|u| \frac{\mu \sin \theta}{4 \pi |\vec{R}|^3}\right )\hat{\theta} + 0\hat{\phi} \, .$$

Gauss's Law for Magnetism stats that $\bigtriangledown \cdot \vec{B} = 0$. However, this:

$$\left( \hat{r}\frac{\partial}{\partial r}+ \frac{\hat{\theta}}{r}\frac{\partial}{\partial \theta} + \frac{\hat{\phi}}{r\sin\theta}\frac{\partial}{\partial \phi} \right) \cdot \left[\left( 2 |u| \frac{\mu \cos \theta}{4 \pi |\vec{R}|^3}\right )\hat{r} + \left (|u| \frac{\mu \sin \theta}{4 \pi |\vec{R}|^3}\right )\hat{\theta} + 0\hat{\phi}\right] \neq 0 \, .$$

All terms should cancel, but they do not. Where am I going wrong?

What I got is:

$$\bigtriangledown \cdot \vec{B} = -\frac{6|u|\mu \cdot \hat{r}}{4 \pi |R|^4} + \frac{|u|\mu \cdot \hat{r}}{4 \pi |R|^4} + 0 \therefore \neq 0 \, .$$

• Where did you find that expression? – Salvatore Baldino Apr 19 '17 at 15:42
• I don't know if your expression is correct, but if it's an approximation you shouldn't expect the equations to hold exactly. Notice that the divergence goes as $1/R^4$, much smaller than the field. – Javier Apr 19 '17 at 15:43
• – macas Apr 19 '17 at 15:45
• Then how can I mathematically prove to myself that $\bigtriangledown\cdot \vec{B} = 0$? I understand the concept.. that makes sense, but the math has to support it, no? – macas Apr 19 '17 at 15:46
• A note: your procedure to calculate the divergence is wrong. You have to apply the $\hat r$ part in the divergence only to the $\hat r$ part in the field, and cancel the $\hat r$ (as $\hat r\cdot\hat r$ is 1). Same for $\theta$: to each part of the divergence its vector component. And, in the end, the divergence is a number, not a vector. And the trigonometric functions do not cancel. However, even computing the divergence in the right way, something's amiss. I'll look for an alternative source for your formula (or try to derive it). – Salvatore Baldino Apr 19 '17 at 15:53

This is the magnetic field generated by a magnetic dipole. The problem is in the way you calculate $\nabla\cdot \mathbf B$. The correct expression is $$\nabla \cdot \mathbf B = {1 \over r^2}{\partial \left( r^2 B_r \right) \over \partial r}+ {1 \over r\sin\theta}{\partial \over \partial \theta} \left( B_\theta\sin\theta \right)+ {1 \over r\sin\theta}{\partial B_\varphi \over \partial \varphi}.$$ Then $$\nabla \cdot \mathbf B = -2 |u| {1 \over R^4} \frac{\mu cos \theta}{4 \pi}+2 |u| {1 \over R^4} \frac{\mu cos \theta}{4 \pi} = 0$$

I believe you are using an incorrect form for the divergence in spherical coordinates... see the table here for the full correct form:

https://en.wikipedia.org/wiki/Del_in_cylindrical_and_spherical_coordinates#Del_formula

I did a quick check in Mathematica and it returned 0.

(one can use the command Div[{f1(R,t,phi), f2(R,t,phi), f3(R,t,phi)}, {R, t, phi}, "Spherical"] )

You are using the wrong expression for the gradient. I suppose you think that $\vec \nabla$ is some sort of vector, that you can use in dot and cross products: but each operator is expressed in a different way in different coordinate systems.

From Wikipedia (https://en.wikipedia.org/wiki/Del_in_cylindrical_and_spherical_coordinates), the divergence is $$\vec\nabla\cdot\vec B=\frac{1}{r^2}\partial_r(r^2B_r)+\frac{1}{r\sin\theta}\partial_\theta(B_\theta\sin\theta)+...$$ This is all the divergence you need: the last piece is useless here, as $\vec B$ has no $\phi$ component.

Try calculating it like that, you'll obtain zero.