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?