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

I am studying the software by

https://cadabra.science/notebooks/schwarzschild.html

and I am redoing the steps present in Chapter 6, on the Schwarchield coordinates. When I'm going to calculate the inverse metric, using the complete algorithm:

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

# Schwarchield metric:
scw:= { g_{t t} = -(1-2 M/r), g_{r r} = 1/(1-2 M/r), g_{\theta\theta} = r**2, g_{\phi\phi}=r**2 sin(\theta)**2 };

# inverse metric:
complete(scw, $g^{\mu\nu}$);

the following error:

NonInvertibleMatrixError: Matrix det == 0; not invertible.

At: 
    /usr/lib/python3/dist-packages/sympy/matrices/matrices.py(3587): inverse_GE
    /usr/lib/python3/dist-packages/sympy/matrices/dence.py(265): _eval_inverse
    /usr/lib/python3/dist-packages/sympy/matrices/matrices.py(3672): inv
<\string>(1): <\module>
    /usr/lib/python3/dist-packages/sympy/parsing/sympy_parser.py(902): eval_expr
    /usr/lib/python3/dist-packages/sympy/parsing/sympy_parser.py(1008): parse_expr
<\string>(2): <\module>

Would anyone know if there is a problem with sympy?Because I’ve updated several times.

in General questions by
retagged by

1 Answer

+1 vote

Be careful with your brackets and backslashes. The following segment works:

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

# Schwarzschild metric:
scw:= { g_{t t} = -(1-2 M/r), g_{r r} = 1/(1-2 M/r), g_{\theta\theta} = r**2, g_{\phi\phi}=r**2 \sin(\theta)**2 };

# inverse metric:
complete(scw, $g^{\mu\nu}$);

I had to fix the declaration of the indices (a missing curly opening bracket) and the use of sin (which you need to write as \sin, with a backslash).

If you copy-paste the above, do you still get the error?

by (82.6k points)

First of all, thanks for the corrections in the code, I hadn't noticed.

So, the error persisted, but I think I managed to get around it. A few lines before, I made some statements for different calculations, I believe that is what caused the problem. When I put a reset() between them the problem goes away, or if I leave the first statement as a comment. I will leave the two statements here because I am not sure the source of the error, in case you know, I will be happy to know.

- First statement:

{\theta, \varphi}::Coordinate; {a,b,c,d,e,f,g,h#}::Indices(values={\theta, \varphi}, position=independent); \partial{#}::PartialDerivative;

- Second statement:

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

...