$\operatorname{div}$ and $\operatorname{grad}$ in spherical coordinates. Formula from general relativity goes crazy

804 Views Asked by At

I try to calculate the gradient of a function and the divergence of a vector field in spherical coordinates. Nothing special so far, but a formula that I learned in a general relativity lecture creates confusion.

First of all consider a vector field $f$ and a function $h$ on $\mathbb R^3$. Of course in spherical coordinates we have

\begin{align*} \operatorname{div} f &= \frac{1}{r^2}\partial_r (r^2 f^r) + \frac{1}{r \sin \theta} \partial_\theta (\sin \theta f^\theta) + \frac{1}{r \sin \theta} \partial_\varphi f^\varphi\\ \operatorname{grad} h &= e_r \partial_r h + e_\theta \frac{1}{r}\partial_\theta h + e_\varphi \frac{1}{r \sin \theta} \partial_\varphi h \end{align*}

In the general relativity lecture I learned the two formulas

$$\nabla_\mu f^\mu = \frac{1}{\sqrt{|\operatorname{det} g|}}\partial_\mu (\sqrt{|\operatorname{det}g|}f^\mu)$$

and

$$\nabla h = (\nabla h)^\nu \partial_\nu = g^{\mu\nu}\partial_\mu h \partial_\nu $$

where the Riemannian Metric in spherical coordinates reads

$$g = \text d r^2 + r^2 \text d \theta^2 + r^2 \sin^2 \theta \text d \varphi^2$$

so that

$$\sqrt{|\operatorname{det}g|} = r^2 \sin \theta$$

If I now use the two formulas I get different results for the gradient and the divergence:

\begin{align*} \nabla_\mu f^\mu &= \frac{1}{r^2} \partial_r (r^2 f^r) + \frac{1}{\sin\theta}\partial_\theta(\sin\theta f^\theta) + \partial_\varphi f^\varphi\\ \nabla h &= \partial_r h \partial_r + \frac{1}{r^2}\partial_\theta h \partial_\theta + \frac{1}{r^2 \sin^2 \theta}\partial_\varphi h \partial_\varphi \end{align*}

Can someone tell me what went wrong? I guess that something is wrong when I compare the unit vector notation $e_i$ with $\partial_i$