Metric tensor in spherical coordinates using basis vector?

I'm using these spherical basis vectors but it's not agreeing with other literature when I use the definition of the metric tensor to derive the metric tensor in spherical coordinates.

\begin{align} {\mathbf e}_r &=\sin \theta \cos \phi \,\hat{\mathbf x} + \sin \theta \sin \phi \,\hat{\mathbf y} + \cos \theta \,\hat{\mathbf z} \\[5px] {\mathbf e}_\theta &=\cos \theta \cos \phi \,\hat{\mathbf x} + \cos \theta \sin \phi \,\hat{\mathbf y} -\sin \theta \,\hat{\mathbf z} \\[5px] {\mathbf e}_\phi &=-\sin \phi \,\hat{\mathbf x} + \cos \phi \,\hat{\mathbf y} \end{align}

\begin{equation} \mathbf{\overline{g}} = \begin{pmatrix} g_\text{rr} & g_{r \theta} & g_{r \phi} \\ g_{\theta r} & g_{\theta \theta} & g_{\theta \phi} \\ g_{\phi r} & g_{\phi \theta} & g_{\phi \phi} \\ \end{pmatrix} = \begin{pmatrix} \mathbf{e}_\text{r}\cdot\mathbf{e}_\text{r} & \mathbf{e}_\text{r}\cdot\mathbf{e}_{\theta} & \mathbf{e}_\text{r}\cdot\mathbf{e}_{\phi} \\ \mathbf{e}_{\theta}\cdot\mathbf{e}_{r} & \mathbf{e}_{\theta}\cdot\mathbf{e}_{\theta} & \mathbf{e}_{\theta}\cdot\mathbf{e}_{\phi} \\ \mathbf{e}_{\phi}\cdot\mathbf{e}_{r} & \mathbf{e}_{\phi}\cdot\mathbf{e}_{\theta} & \mathbf{e}_{\phi}\cdot\mathbf{e}_{\phi} \\ \end{pmatrix} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{pmatrix} = \delta_{ij} \\ \end{equation}

• It would help if you could clarify just what you expect to get, or how you think this is wrong. You haven't actually asked a question here. I'll take a shot at inferring what you mean, but this is not clear at all. – Mike Feb 28 '18 at 19:15
• Hi Mike I apologize. Other literature has the metric tensor in spherical coordinates as 1, $r sin(\theta)$ and $r^2 sin^2(\theta)$ for the elements on the diagonal and 0 elsewhere. I've used the definition for a metric tensor as a function of its basis but I didn't get what I expected. – Johndo Feb 28 '18 at 20:05

You're confused because you usually see the metric tensor in spherical coordinates given as $$\begin{equation} \mathbf{g} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & r^2 & 0 \\ 0 & 0 & r^2 \sin^2\theta \end{pmatrix}. \end{equation}$$ This is the metric with respect to the coordinate basis, whereas you've (correctly) written the metric with respect to the orthonormalized vector basis — and it's very important to remember the distinction between those types of bases. I'll explain.
Let's write the coordinate basis vectors as $$\begin{equation} \mathbf{r}, \boldsymbol{\theta}, \boldsymbol{\phi}. \end{equation}$$ (Note that I'm using a bold font to indicate that these are vectors, but I'm not putting hats on them, for reasons that will become clear soon.) These vectors represent the amount you would move through the space if you changed the corresponding coordinate by a certain amount. For example, if $$\mathbf{p}(r, \theta, \phi)$$ is the position vector to the point with spherical coordinates $$r, \theta, \phi$$, then those coordinate basis vectors are defined as \begin{align} \mathbf{r} &= \frac{\partial \mathbf{p}} {\partial r} \\ \boldsymbol{\theta} &= \frac{\partial \mathbf{p}} {\partial \theta} \\ \boldsymbol{\phi} &= \frac{\partial \mathbf{p}} {\partial \phi}. \end{align} To relate that back to your basis given in Cartesian components, remember that $$\begin{equation} \mathbf{p} = r\sin\theta\cos\phi\, \hat{\mathbf{x}} + r\sin\theta\sin\phi\, \hat{\mathbf{y}} + r\cos\theta\, \hat{\mathbf{z}}, \end{equation}$$ which we can differentiate to find \begin{align} \mathbf{r} &= \sin\theta\cos\phi\, \hat{\mathbf{x}} + \sin\theta\sin\phi\, \hat{\mathbf{y}} + \cos\theta\, \hat{\mathbf{z}} \\ \boldsymbol{\theta} &= r\cos\theta\cos\phi\, \hat{\mathbf{x}} + r\cos\theta\sin\phi\, \hat{\mathbf{y}} - r\sin\theta\, \hat{\mathbf{z}} \\ \boldsymbol{\phi} &= -r\sin\theta\sin\phi\, \hat{\mathbf{x}} + r\sin\theta\cos\phi\, \hat{\mathbf{y}}. \end{align} Using these expressions, it's a simple exercise to see that we have \begin{align} \mathbf{r} \cdot \mathbf{r} &= 1 \\ \boldsymbol{\theta} \cdot \boldsymbol{\theta} &= r^2 \\ \boldsymbol{\phi} \cdot \boldsymbol{\phi} &= r^2 \sin^2 \theta. \end{align} So this basis is not orthonormal — and that's where the "usual" metric components come from, which is why the metric isn't just the identity as you expected. In fact, usually the only type of coordinates that lead to orthonormal basis vectors is a Cartesian coordinate systems (though even Cartesian coordinates are not orthonormal in nontrivial geometries).
On the other hand, a nearly identical simple exercise shows that your basis $$(\mathbf{e}_r, \mathbf{e}_\theta, \mathbf{e}_\phi)$$ is orthonormal. In fact, comparing our expressions in the Cartesian basis, we see that \begin{align} \mathbf{r} &= \mathbf{e}_r \\ \boldsymbol{\theta} &= r\, \mathbf{e}_\theta \\ \boldsymbol{\phi} &= r\sin\theta\, \mathbf{e}_\phi. \end{align} In an orthonormal basis, the metric is — essentially by definition — just the identity matrix, which is what you found.