# Gradient vector derived from the metric tensor

According to Frankel's book "The Geometry of Physics", the components of a contravariant gradient vector can be obtained from the inverse of the metric tensor as follows (in section 2.1d, Page 73):

$$(\nabla f)^i = \sum_j g^{ij} \frac{\partial f}{\partial x^j},$$

while the metric sensor is:

$$g_{ij} = \bigg\langle \frac{\partial}{\partial x^i}, \frac{\partial}{\partial x^j} \bigg\rangle.$$

Take the spherical coordinate as example,

\begin{align} x &= r\sin\theta\cos\phi \\ y &= r\sin\theta\sin\phi \\ z &= r\cos\theta \end{align}

and let $J$ be the Jacobi matrix

$$J = \begin{pmatrix} \sin\theta\cos\phi & -r\sin\phi\sin\theta & r\cos\phi\cos\theta \\ \sin\theta\sin\phi & r\cos\phi\sin\theta & r\sin\phi\cos\theta \\ \cos\theta & 0 & -r\sin\theta \end{pmatrix},$$

the metric tensor can be obtained as

$$\left( g_{ij} \right) = J^TJ = \begin{pmatrix} 1 & 0 & 0 \\ 0 & r^2\sin^2\theta & 0 \\ 0 & 0 & r^2 \end{pmatrix}.$$

Finally, the contravariant gradient vector can be obtained as follows according to the first equation:

$$\nabla f = \begin{pmatrix}\displaystyle{ \frac{\partial f}{\partial r} \\ \frac{1}{r^2\sin^2\theta} \frac{\partial f}{\partial \phi} \\ \frac{1}{r^2} \frac{\partial f}{\partial \theta}} \end{pmatrix}.$$

$$\nabla f = \begin{pmatrix}\displaystyle{ \frac{\partial f}{\partial r} \\ \frac{1}{r\sin\theta} \frac{\partial f}{\partial \phi} \\ \frac{1}{r} \frac{\partial f}{\partial \theta}} \end{pmatrix}.$$
In your first equation for $\nabla f$, $$\nabla f = \Big( \frac{\partial f}{\partial r}, \frac{1}{r^2 \sin^2 \theta} \frac{\partial f}{\partial \phi}, \frac{1}{r^2} \frac{\partial f}{\partial \theta} \Big),$$ what you've written down is an expression for $\nabla f$ with respect to the coordinate vectors $\tfrac{\partial}{\partial r}, \tfrac{\partial}{\partial \phi}, \tfrac{\partial}{\partial \theta}$. That is, your equation means $$\nabla f = \frac{\partial f}{\partial r} \frac{\partial}{\partial r} + \frac{1}{r^2 \sin^2 \theta} \frac{\partial f}{\partial \phi} \frac{\partial}{\partial \phi} + \frac{1}{r^2} \frac{\partial f}{\partial \theta} \frac{\partial}{\partial \theta}.$$ Note that these coordinate vectors are not unit vectors; if we use $\boldsymbol{\hat{r}}, \boldsymbol{\hat{\phi}}, \boldsymbol{\hat{\theta}}$ to denote the associated unit vectors, then $$\boldsymbol{\hat{r}} = \frac{\partial}{\partial r}, \qquad \boldsymbol{\hat{\phi}} = \frac{1}{r \sin \theta} \frac{\partial}{\partial \phi}, \qquad \boldsymbol{\hat{\theta}} = \frac{1}{r} \frac{\partial}{\partial \theta}.$$ Your second equation (the standard one written in physics) is written in terms of these unit vectors; it states $$\nabla f = \frac{\partial f}{\partial r} \boldsymbol{\hat{r}} + \frac{1}{r \sin \theta} \frac{\partial f}{\partial \phi} \boldsymbol{\hat{\phi}} + \frac{1}{r} \frac{\partial f}{\partial \theta} \boldsymbol{\hat{\theta}}.$$ It should now be clear that there is no inconsistency between these equations.