# Divergence in cartesian coordinates conflicts with spherical divergence.

Consider the vector $$\vec{a}=f(r)\hat{r}+r\hat{\theta}+r\hat{\phi}$$ Where $$\vec{a}$$ is a vector in spherical coordinates and $$f(r)$$ is a function of $$r$$.
Let's calculate $$\nabla\cdot(\vec{a}\times\vec{r})$$, where $$\vec{r}$$ is the position vector.
$$\nabla\cdot(\vec{a}\times\vec{r})=\vec{r}\cdot(\nabla\times\vec{a})-\vec{a}\cdot(\nabla\times\vec{r})$$ $$\nabla\times\vec{r}=0$$. Thus, by using divergence formula in spherical coordinates, I concluded that $$\nabla\cdot(\vec{a}\times\vec{r})=r\cot(\theta)$$ But, the same calculation in cartesian coordinates lead to $$\nabla\cdot(\vec{a}\times\vec{r})=0$$ Why is this quantity different in these coordinates?

• In your first equation $\vec{a}=f(r)\hat{r}+r\hat{\theta}+r\hat{\phi}$ what is $\hat{r},\hat{\theta},\hat{\phi}$? Aug 28, 2023 at 21:09
• @Somos This page is an excellent refresher or starting reference if you are seeing this notation for the first time. Aug 28, 2023 at 21:12
• Your product rule formula is incorrect since there should be a minus sign, but it may not have affected your answer since that term with the sign change vanished. It is hard to tell where you went wrong if you don't post your full calculation in both coordinate systems. Aug 28, 2023 at 21:21
• Thanks for telling me, the sign was incorrect. I checked my results with mathematica, they're completely correct. Aug 28, 2023 at 22:33

I think you are using the wrong identity .

$$\nabla \cdot (\vec{a} \times \vec{r}) = \frac{\partial }{\partial x_i}(\epsilon_{ijk}a_jr_k)=\epsilon_{ijk}(\partial a_j/\partial x_i)r_k + \epsilon_{ijk} ( \partial r_k/ \partial x_i)a_j= \vec{r}\cdot (\nabla \times \vec{a} )-\vec{a} \cdot (\nabla \times \vec{r})$$

$$\nabla \cdot (\vec{a} \times \vec{r}) = \vec{r}\cdot (\nabla \times \vec{a} )-\vec{a} \cdot (\nabla \times \vec{r})$$

$$\vec{a}=f(r)\hat{r} + r \hat{\theta}+r \hat{\phi}$$

$$\vec{r}=r\hat{r}$$

$$\vec{a}\times \vec{r}= -r^2\hat{\phi}+r^2\hat{\theta}$$

$$\nabla \cdot \vec{E} = \frac{1}{r^2}\frac{\partial }{\partial r}(r^2 E_r)+ \frac{1}{r \sin \phi }\frac{\partial E_\theta}{\partial \theta}+\frac{1}{r \sin \phi}\frac{\partial }{\partial \phi}(\sin \phi E\phi)$$

Since the $$r$$ component is $$0$$ and the other components only have radial dependence, the divergence is $$0$$.

Further $$\nabla (r^2/2)=\vec{r}$$ and for any scalar $$f$$, $$\nabla \times \nabla f=0$$ in any coordinate system.

It follows that $$\nabla \times \vec{r}=0.$$

$$\nabla \times \vec{E} = \frac{1}{r \sin \phi}(\frac{\partial }{\partial \phi }(A_\theta \sin \phi)-\frac{\partial A_\phi}{\partial \theta })\hat{r}+ \frac{1}{r}(\frac{1}{\sin \phi} \frac{\partial A_r}{\partial \theta}-\frac{\partial }{\partial r}(rA_\theta))\hat{\theta}+\frac{1}{r}(\frac{\partial }{\partial r}(rA_\phi)-\frac{A_r}{\partial \phi})\hat{\phi}$$

Since the components of $$\vec{a}$$ are only dependent on $$r$$, the derivatives for the r-component of the curl are 0, so the r coordinate of the curl is 0.

$$\nabla \times \vec{a}= 0 \hat{r} -2\hat{\theta}+2\hat{\phi}$$

So $$\vec{r} \cdot (\nabla \times \vec{a}) = 0.$$

Combining this we have $$\nabla \cdot (\vec{a} \times \vec{r})=0$$

• I'm completely sure that you're using the wrong formula for divergence in spherical coordinates. please check en.wikipedia.org/wiki/… Aug 28, 2023 at 22:29
• I first learned about these with $\theta$ and $\phi$ switched, which I think makes more sense intuitively. Keeping that in mind, does my equation otherwise hold? Aug 28, 2023 at 23:00
• I guess you omitted the partial derivative of sine function with respect to phi when you were computing the divergence. Aug 28, 2023 at 23:28