# Computing gradient in cylindrical polar coordinates using metric?

I am trying to understand coordinate transformations properly (having studied some general relativity in the past).

Let us consider the transformation from cartesian to cylindrical coordinates, $x=\rho\cos\varphi$, $y=\rho\sin\varphi$, $z=z$. I know that the line element (invariant at coord transformations) is simply defined as $$ds^{2}=g_{ij}dx^{i}dx^{j}=\tilde{g}_{ij}d\tilde{x}^{i}d\tilde{x}^{j}$$ where the non-tilde quantities belong to one coordinates (cartesian in my example) and the tilde ones to another (cylindrical in my example). The cartesian coordinates are simply $$ds^{2}=dx^{2}+dy^{2}+dz^{2}$$ where the metric is $g_{ij}=diag(1,1,1)$ and the inverse metric is $g^{ij}=g_{ij}$. Simply using total differentials I can compute that $dx^{2}=\left[d(\rho\cos\varphi)\right]^{2}$ and do the derivatives etc. This way, I obtain $$ds^{2}=d\rho^{2}+\rho^{2}d\varphi^{2}+dz^{2}$$ which means $\tilde{g}_{ij}=diag(1,\rho^{2},1)$ and $\tilde{g}^{ij}=diag(1,\frac{1}{\rho^{2}},1)$. So far, so good.

Now I was wondering how I can use the metric in order to obtain expressions for simple things, for instance the gradient of a scalar field $\phi$. In my thinking, it should simply be $$\nabla\phi=\left(\partial^{i}\phi\right)\mathbf{e}_{\left(i\right)}=\tilde{g}^{ij}\left(\partial_{i}\phi\right)\mathbf{e}_{\left(j\right)}=\tilde{g}^{\rho\rho}\left(\partial_{\rho}\phi\right)\mathbf{e}_{\rho}+\tilde{g}^{\varphi\varphi}\left(\partial_{\varphi}\phi\right)\mathbf{e}_{\varphi}+\tilde{g}^{zz}\left(\partial_{z}\phi\right)\mathbf{e}_{z}.$$ where $\mathbf{e}_{\left(i\right)}$ represents the $i$-th unit vector, e.g. $\mathbf{e}_{\left(2\right)}=\mathbf{e}_{\varphi}$. The result should then be $$\nabla\phi=\frac{\partial\phi}{\partial\rho}\mathbf{e}_{\rho}+\frac{1}{\rho^{2}}\frac{\partial\phi}{\partial\varphi}\mathbf{e}_{\varphi}+\frac{\partial\phi}{\partial z}\mathbf{e}_{z}$$ which is wrong.

Computing other expressions, like the Laplacian, gets things considerably more wrong. My thinking about using the metric in this way must be flawed. Can you help me out and rectify this?

-
I think your formula is correct actually. Where I've usually seen the divergence written down, instead of using $e_\phi$, they use a unit vector in the same direction $e_\varphi$: $\hat{e_\varphi} = e_\varphi /|e_\varphi| = e_\varphi/\rho$. In other words, after substituting in $e_\varphi = \rho\hat{e_\varphi}$, you get the usual gradient formula. –  Jason DeVito Dec 19 '12 at 2:18

You can also determine the expression for $\nabla$ in other coordinate systems just by using the Jacobian.

Let $f(r) = r' = \rho e_1 + \varphi e_2 + z e_3$ be our nonlinear coordinate transformation, with $e_i$ being cartesian basis vectors.

Now, let $\phi'(r') = \phi(r)$ for some scalar field $\phi$. For any vector $a$, the chain rule then tells us that

$$a \cdot \nabla \phi = [(a \cdot \nabla )f] \cdot \nabla' \phi'$$

The quantity $(a \cdot \nabla)f$ is the Jacobian (hint: evaluate it with respect to basis vectors for $a$ and then to extract components of the resulting vector). We'll call the Jacobian $\underline f(a)$ when it acts on some vector $a$. The law above can be rewritten as

$$a \cdot \nabla \phi = \underline f(a) \cdot \nabla' \phi'$$

But, we can transpose the Jacobian (or more precisely, use the adjoint operator) to have it act on $\nabla'$ instead!

$$a \cdot \nabla \phi = a \cdot \overline f(\nabla') \phi' = a \cdot \overline f(\nabla') \phi$$

Or more succinctly,

$$\nabla = \overline f(\nabla')$$

The expression for $\nabla'$ is easy enough: it's $\nabla' = e^1 \partial_\rho + e^2 \partial_\varphi + e^3 \partial_z$. This is not enough, however. We actually want $\nabla$, just expressed in terms of the cylindrical coordinate partials. To get that, we must find $\overline f(\nabla')$.

Calculating the Jacobian (and its adjoint) is more of a tedious than complicated process. Let's just take as given that the adjoint Jacobian is

\begin{align*}\overline f(e^1) &= e^\rho \\ \overline f(e^2) &= e^\varphi \\ \overline f(e^3) &= e^3 = e^z\end{align*} The vectors $e^\rho, e^\varphi, e^z$ form the basis covectors in cylindrical coordinates. They are not all normalized--in particular, $e^\varphi \cdot e^\varphi = 1/\rho^2$. (Actually carrying out the computation of the Jacobian generates these expressions in terms of cartesian basis covectors, which is instructive, but not really necessary. It is, however, one way you verify the norm of $e^\varphi$.) This makes $\nabla$ equal to

$$\nabla = e^\rho \partial_\rho + e^\varphi \partial_\varphi + e^z \partial_z$$

In this light, the gradient is actually pretty trivial because, as long as the new coordinate frame is orthogonal, you get a result like this. Maybe one of the basis covectors is non-unit, but that's not really a big deal. The divergence tends to be more interesting because you have to account for the transformation law for the underlying vector field (is it actually a vector field? is it instead a covector field?) and because the dot product requires you to transform $\nabla$ and the field separately.

Long story short: because you expressed $\nabla$ in terms of basis vectors instead of covectors, you got what looks like the wrong result but isn't. $e_\varphi$ is indeed equal to $e^\varphi \rho^2$, and neither has unit magnitude, as Jason points out.

This approach is the basic idea behind that of tetrads or frame fields. Note that the metric $\underline g(a) = \overline f^{-1} \underline f^{-1}(a)$, so everything you naturally do with the metric can be done with the Jacobian (or, in a case where the underlying space isn't flat, with the frame field) instead.

-