3
$\begingroup$

I am try to compute the metric tensor under under a coordinate transformation, using the formula:

\begin{align} g_{\mu'\nu'} = \frac{\partial x^{\mu}}{\partial x^{\mu'}} \frac{\partial x^{\nu}}{\partial x^{\nu'}} g_{\mu\nu}, \end{align}

where $g_{\mu\nu}$ is the diagonal metric $(-1, 1, r^2, 1)$ for cylincdircal coordinates. The coordinates transformation equations are given in the code. Here's the code:

metric1 = {{-1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, r^2, 0}, {0, 0, 0, 1}};

n = 4;

tPrime[t_] := t;

rPrime[r_] := r;

\[Theta]Prime[\[Theta]_, t_] := \[Theta] - \[Omega]*t;

zPrime[z_] := z;

coordold = {t, r, \[Theta], z};

coord = {tPrime, rPrime, \[Theta]Prime, zPrime};

When I try and execute Table[g[M, N], {M, 1, 4}, {N, 1, 4}] // MatrixFormI get the zero matrix, which isn't the correct answer.

What could be going wrong?

$\endgroup$
5
  • $\begingroup$ Well, you define the coordinates with argument, but in coord you refer to them without arguments... $\endgroup$ – user46676 Apr 12 '17 at 18:55
  • $\begingroup$ I change coord to coord[t_, r_, \[Theta]_, z_] := {tPrime[t], rPrime[r], \[Theta]Prime[\[Theta], t], zPrime[z]};. Now I get the error, SetDelayed::write: Tag List in {tPrime,rPrime,\[Theta]Prime,zPrime}[t_,r_,\[Theta]_,z_] is Protected. $\endgroup$ – Junaid Aftab Apr 12 '17 at 18:57
  • $\begingroup$ Got it, thanks. $\endgroup$ – Junaid Aftab Apr 12 '17 at 18:59
  • $\begingroup$ I am not quite sure, but it seems that you turned your transformation matrix upside-down. $\endgroup$ – Alexei Boulbitch Apr 13 '17 at 6:54
  • $\begingroup$ @AlexeiBoulbitch Yes, I corrected that mistake as well. Apparently, Mathematica doesn't automatically invert the linear system of equations (of course, why would it do automatically), so I made that correction. Thanks. $\endgroup$ – Junaid Aftab Apr 13 '17 at 7:33
3
$\begingroup$

Try using this code

ClearAll["Global`*"];

n = 4;
coord = {t, r, \[Theta], \[Phi]};

\[Eta] = {{-1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
\[Eta] // MatrixForm;

"e-Metric";
e = {{-1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, r^2, 0}, {0, 0, 0, 1}};
e // MatrixForm
dete = Det[e];
inve = Inverse[e];
inve // MatrixForm
detinve = Det[inve];

Answer := Answer = Simplify[Table[Sum[
     D[D[e[[\[Mu], \[Nu]]], coord[[a]]], coord[[b]]]
     , {\[Mu], 1, n}, {\[Nu], 1, n}]
    , {a, 1, n}, {b, 1, n}]]
listAnswer := 
 Table[If[UnsameQ[Answer[[a, b]], 0], {ToString[Ans[a, b]], 
    Answer[[a, b]]}] , {a, 1, n}, {b, 1, n}]
TableForm[Partition[DeleteCases[Flatten[listAnswer], Null], 2], 
 TableSpacing -> {2, 2}]

The trick to differentiating a metric is to define a 'coord' then refer to it. I had to use a different variable $a$ and $b$ instead of $\mu'$ and $\nu'$ respectively

$\endgroup$
1
$\begingroup$

Here is my solution. This works for the spherical coordinate system but can be generalized for any other system as well. This example is for the FLRW in the spherical polar coordinates and it gives back the metric in the cartesian coordinates.

ncoor={t,x,y,z};
r[x_,y_,z_]:=Sqrt[x^2+y^2+z^2];
\[Theta][x_,y_,z_]:=ArcTan[Sqrt[x^2+y^2]/z];
\[Phi][x_,y_,z_]:=ArcTan[y/x];
ocoor={t,r[x,y,z],\[Theta][x,y,z],\[Phi][x,y,z]};
oldmet={{1,0,0,0 },{0,-a[t]^2,0,0},{0,0,-a[t]^2 r^2,0},{0 ,0,0,-a[t]^2 Sin[\[Theta]]^2 r^2}};
newmet=Simplify[Table[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(\[Alpha] = 1\), \(4\)]\(
\*UnderoverscriptBox[\(\[Sum]\), \(\[Beta] = 1\), \(4\)]\(oldmet[[\[Alpha]]]\)[[\[Beta]]] D[ocoor[[\[Alpha]]], ncoor[[\[Mu]]]] D[ocoor[[\[Beta]]], ncoor[[\[Nu]]]]\)\),{\[Mu],1,4},{\[Nu],1,4}]/.Sin[\[Theta]]->Sqrt[x^2+y^2]/r/.r->Sqrt[x^2+y^2+z^2]]

This definitely is not the most elegant way of going about it. But it works nevertheless. This gives the following answer

{{1, 0, 0, 0}, {0, -a[t]^2, 0, 0}, {0, 0, -a[t]^2, 0}, {0, 0, 
  0, -a[t]^2}}
$\endgroup$
2
  • $\begingroup$ Please provide your code in Mathematica format rather than as an image. $\endgroup$ – bbgodfrey Feb 25 '20 at 16:58
  • $\begingroup$ Here is the code. $\endgroup$ – Ramanuja Feb 25 '20 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.