# can i define a metric using 'tensorwithindices', such that it is defined as one entity only and not by 16 components?

I've been trying to derive equations of general relativity on sagemath, I would want to define my metric as g_ij instead of having to define it component by component. Can you help me with how to do that? I tried using the object 'tensor with indices' but that does not allow me to use attributes from the metric object.

Or if there is any other way to deal with this problem, please let me know.

Please provide an actual code illustrating the issue.

okay so first i tried doing it component by component. It is a simple code, just finding riemann tensor for a metric, but the computation time exceeds 16 hours.

So i wanted it to be a bit generlised, like instead of having 16 components, with 16 memory allocations if i could do it just one component like this

(to be cont)

the error is

Please define

`M`

, and best reedit the question showing the mathematical intention and the attempt to mimic the situation inside sage. Which is in fact the intention, what should be calculated after having the instance initialized? The doc sting of`TensorWithIndices`

gives:And examples are shown.

the manifold is lorentzian. M= Manifold(4, 'M'). Also what examples are shown, I didn't get that. Can you please provide a link?