Divergence of field in spherical coordinates does not match Cartesian

grad-curl-divmultivariable-calculusspherical coordinatesVector Fields

I have a vector field

$$\vec{F}(x,y,z)=\frac{x \hat{x}}{(x^2+y^2+z^2)^{3/2}} + \frac{y \hat{y}}{(x^2+y^2+z^2)^{3/2}} + \frac{z \hat{z}}{(x^2+y^2+z^2)^{3/2}}$$

Solving this in Cartesian coordinates, I found that the divergence is 0. However, the process was tedious and error-prone. I'm sure there must be an easier way to solve this. I tried converting the vector field to spherical coordinates, because I recognized the $x \hat{x} + y \hat{y} + z \hat{z}$ as $\rho \hat{\rho}$, which gave me:

$$\vec{F}(\rho,\theta,\phi)=\frac{\rho \hat{\rho}}{(x^2+y^2+z^2)^{3/2}}$$

And taking the divergence of this in spherical coordinates, I get $$\frac{3}{(x^2+y^2+z^2)^{3/2}}$$
which is not the correct answer. What have I done wrong?

Best Answer

Please be careful about the singularity at the origin. Yes the divergence is zero at all points but the origin.

To convert to spherical coordinates, know that $\hat\rho=\frac{x \hat{x}}{\sqrt{x^2+y^2+z^2}} + \frac{y \hat{y}}{\sqrt{x^2+y^2+z^2}} + \frac{z \hat{z}}{\sqrt{x^2+y^2+z^2}}$

and $\rho = \sqrt{x^2+y^2+z^2}$

So, $\vec{F}(\rho,\theta,\phi)=\frac{1}{\rho^2} \hat{\rho}$

As we only have $\hat \rho$ component, divergence at points other than the origin in spherical coordinates is given by,

$ \displaystyle \nabla \cdot \vec F = \frac{1}{\rho^2} \frac{\partial}{\partial \rho} (\rho^2 F_{\rho}) = 0$.

Depending on the context of the problem and the domain, you will have to handle the origin differently. For example, this is a very well known vector field in Electrodymanics. In other words, if origin is part of your domain, do not trivially assume that divergence is zero. It is not zero at the origin for the given vector field.

Related Question