# Why does MetricInBasis not define rules for the inverse metric?

18 views

### Andrew Kovachik

Jan 26, 2023, 2:54:26 PM1/26/23
to xAct Tensor Computer Algebra
From the following minimal example:

DefManifold[M, 4, IndexRange[a, q]]
DefMetric[-1, met[-a, -b], CD, PrintAs -> "g"]
DefChart[cartesian, M, {0, 1, 2, 3}, {t[], x[], y[], z[]},
FormatBasis -> {"Partials", "Differentials"}, ChartColor -> Red]
flatmetriccart =
CTensor[DiagonalMatrix[{-1, 1, 1, 1}], {-cartesian, -cartesian}, 0];
MetricInBasis[met, -cartesian, flatmetriccart]

Should the inverse metric not be fully defined by requiring it to give the identity when multiplying in the metric? Instead I get the algebraic term:

met[{-0, -cartesian}, {-0, -cartesian}] // ToValues
met[{0, cartesian}, {0, cartesian}] // ToValues
Out: -1
Out: met[{0, cartesian}, {0, cartesian}]

Cheers, thanks all :)

### Jose

Jan 26, 2023, 11:08:23 PM1/26/23
to xAct Tensor Computer Algebra
Hi,

xCoba has two main modes of work: what I call the TensorValues framework and the CTensor framework. TensorValues is older, slower, but allows finer control of the operations, because it works very close to the low-level functions of xTensor. Then CTensor is newer, faster, easier but more limited in scope. My recommendation is always to try to stay at the level of CTensor, unless one really needs something more powerful and less automated.

The code you give mixes both frameworks. I'd suggest this instead:

DefManifold[M, 4, IndexRange[a, q]]
DefChart[cartesian, M, {0, 1, 2, 3}, {t[], x[], y[], z[]}, FormatBasis -> {"Partials", "Differentials"}, ChartColor -> Red]
met = CTensor[DiagonalMatrix[{-1, 1, 1, 1}], {-cartesian, -cartesian},0]
SetCMetric[met, cartesian, SignatureOfMetric -> {3, 1, 0}]

(In your simple case SetCMetric can figure out the signature, but it doesn't hurt to be specific in general.)

Now these both work:

met[{-0, -cartesian}, {-0, -cartesian}]
met[{0, cartesian}, {0, cartesian}]
Out[7]= -1
Out[8]= -1

Note in particular that there is no need to use DefMetric. SetCMetric can be considered as the CTensor version of DefMetric, and it does precompute various things. Then all other computations (say curvature) can be performed efficiently with MetricCompute. See the examples in xCobaDoc.nb.

Cheers,
Jose.