Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

my first go at cadabra, 1)do I have to declare M(u) as a function? 2)it does not seem to calculate the inverse metric, either does nothing, or says that the det g is 0, or writes it out without having simplified the terms, in particular it does not get g^{uu}=0,

{u,,r\phi,\theta}::Coordinate;
{\mu,\nu,\rho,\sigma,\lambda,\kappa,\chi,\gamma}::Indices(values={u,r,\phi,\theta}, position=fixed);
\partial{#}::PartialDerivative;
g_{\mu\nu}::Metric.
g^{\mu\nu}::InverseMetric.

ss:= { g_{u u} = -(1-2 M(u)/r),  
   g_{r u} = 1,
   g_{u r} = 1, 
   g_{\theta\theta} = r**2, 
   g_{\phi\phi}= r**2 \sin(\theta)**2
 };

complete(ss, $g^{\mu\nu}$);
in General questions by (210 points)

1 Answer

+2 votes

It's probably down to a single typo in your notebook, or the fact that you had evaluated different forms of this cell before and then did not restart the kernel (like with mathematica, just deleting a cell does not undo the effects of running the cell).

The following works:

{u,r,\phi,\theta}::Coordinate;
{\mu,\nu,\rho,\sigma,\lambda,\kappa,\chi,\gamma}::Indices(values={u,r,\phi,\theta}, position=fixed);
\partial{#}::PartialDerivative;
g_{\mu\nu}::Metric.
g^{\mu\nu}::InverseMetric.

(you had {u,,r\phi,\theta}::Coordinate; in the first line, note the comma).

ss:= { g_{u u} = -(1-2 M(u)/r),  
   g_{r u} = 1,
   g_{u r} = 1, 
   g_{\theta\theta} = r**2, 
   g_{\phi\phi}= r**2 \sin(\theta)**2
 };

complete(ss, $g^{\mu\nu}$);

(unchanged wrt. your file). This does not yet give $g^{uu}=0$ because by default we do not run any simplification on the result of the inversion of the metric. But that's easy to add:

map_sympy(ss, "simplify");

Which gives the expected result for the inverse metric.

If you want to not write $M(u)$ everywhere, but prefer just $M$, simply add (before you start computing)

M::Depends(u);
by (83.1k points)

it does not recognise map_sympy which is odd as I think that there are versions of python on this machine I guess that it just cannot find them. I tried running without this command and got did not match C++ signature, I guess because g^{uu} has not been found to equal 0 yet.

...