# How to construct the metric tensor?

Let’s check the definition of metric again.

If we choose a basis ✟\hat e_\mu✟, then a vector (at one certain point) in this coordinate system is

x^a=x^\mu \hat e_\mu

Then we can construct the expression of metric of this point under this coordinate system,

g_{\mu\nu}=\hat e_\mu\cdot \hat e_\nu

For example, in spherical coordinate system,

\vec x=r\sin \theta\cos\phi \hat e_x+r\sin\theta\sin\phi \hat e_y+r\cos\theta \hat e_z \label{eq:relativity_metric_point}

Now we have to find the basis under spherical coordinate system. Assume the basis is ✟\hat e_r, \hat e_\theta, \hat e_\phi✟. Choose some scale factors ✟h_r=1, h_\theta=r, h_\phi=r\sin\theta✟. Then the basis is
✟\hat e_r=\frac{\partial \vec x}{h_r\partial r}=\hat e_x \sin\theta\cos\phi+\hat e_y \sin\theta\sin\phi+\hat e_z \cos\theta✟, etc. Then collect the terms in formula \ref{eq:relativity_metric_point} is we get ✟\vec x=r\hat e_r✟, this is incomplete. So we check the derivative.
\begin{eqnarray}
\mathrm d\vec x&=& \hat e_x (\mathrm dr \sin\theta\cos\phi+r\cos\theta\cos\phi\mathrm d\theta-r\sin\theta\sin\phi\mathrm d\phi)\\
&&\hat e_y (\mathrm dr\sin\theta\sin\phi+r\cos\theta\sin\phi\mathrm d\theta+r\sin\theta\cos\phi\mathrm d\phi) \\
&&\hat e_z (\mathrm dr\cos\theta-r\sin\theta\mathrm d\theta) \\
&=&\mathrm dr(\hat e_x\sin\theta\cos\phi +\hat e_y \sin\theta\sin\phi -\hat e_z \cos\theta) \\
&&\mathrm d\theta (\hat e_x\cos\theta\cos\phi +\hat e_y \cos\theta\sin\phi – \hat e_z \sin\theta)r \\
&&\mathrm d\phi (-\hat e_x\sin\phi +\hat e_y \cos\phi)r\sin\theta \\
&=&\hat e_r\mathrm dr+\hat e_\theta r\mathrm d\theta +\hat e_\phi r\sin\theta\mathrm d \phi
\end{eqnarray}

Once we reach here, the component (✟e_r ,e_\theta, e_\phi✟) of the point under the spherical coordinates system basis (✟\hat e_r, \hat e_\theta, \hat e_\phi✟) at this point are clear, i.e.,

\begin{eqnarray}
\mathrm d\vec x&=&\hat e_r\mathrm d r+\hat e_\theta r\mathrm d \theta+\hat e_\phi r\sin\theta \mathrm d\phi \\
&=&e_r\mathrm d r+e_\theta \mathrm d\theta+e_\phi \mathrm d\phi
\end{eqnarray}

In this way, the metric tensor for spherical coordinates is

g_{\mu\nu}=(e_\mu\cdot e_\nu)=\left(\begin{matrix}
1 &0&0 \\
0& r^2&0 \\
0&0& r^2\sin^2\theta \\
\end{matrix}\right)