## Having trouble writing down a metric in terms of metric tensor in matrix form?

Can someone please explain to me how exactly you write down a metric, say the FLRW metric in matrix form. Say we have the given metric here.

ds^2 = dt^2 - R(t)^2 * [dw^2 + s^2 * (dθ^2 + sin^2(θ)dΦ^2)]

Thank you.
 PhysOrg.com science news on PhysOrg.com >> Ants and carnivorous plants conspire for mutualistic feeding>> Forecast for Titan: Wild weather could be ahead>> Researchers stitch defects into the world's thinnest semiconductor
 Recognitions: Science Advisor Let the coordinates be q1,q2,q3,q4. The line element will be a sum of terms like C12dq1dq2. In matrix form, C12 will be in row 1 column 2 of the matrix. Edit: See Rasalhague's post for the correct version. I forgot the 1/2 for the off-diagonal terms.
 In your example, if q0 = t, q1 = w, q2 = θ, q3 = Φ (where superscripts are indices), then the matrix of coefficients will be as follows, with superscript 2 denoting an exponent: $$\begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & R(t)^2 & 0 & 0\\ 0 & 0 & (R(t) \cdot s)^2 & 0\\ 0 & 0 & 0 & (R(t)\cdot s \cdot \sin(\theta))^2 \end{pmatrix}$$ = diag(1,0,0,0) - R(t)2[diag(0,1,0,0) + s2(diag(0,0,1,0)+diag(0,0,0,sin(θ)2)]. Here diag(a,b,c,d) denotes a diagonal 4x4 matrix with diagonal entries as indicated, from top left to bottom right. In general, given an expression of the form $$ds^2 = ...,$$ where the values of the indices are not equal, the scalar coefficients in each term of the form $$A \, dx^\mu dx^\nu \enspace (\text{no summation} )$$ (EDIT: Ignore the words "no summation" - a relic of previous version which I forgot to remove before posting. Sorry.) correspond to matrix entries $$g_{\mu\nu} = \frac{1}{2} A.$$ And where the values of the indices are equal, the scalar coefficients in each term of the form $$B \, (dx^\mu)^2$$ correspond to matrix entries $$g_{\mu\mu} = B.$$

Recognitions:
Gold Member
$$\begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & -R(t)^2 & 0 & 0\\ 0 & 0 & -R(t)^2 \, s^2 & 0\\ 0 & 0 & 0 & -R(t)^2 \, s^2 \, \sin^2\theta \end{pmatrix}$$