# Define tensor made of other tensors in xAct

I'm fairly new to the xAct project for Mathematica, but feel like I understand fairly well how to define an arbitrary tensor using xTensor. My problem is that I want to define a tensor that is composed of other tensors. Specifically, I'm trying to construct an abstract tensor that looks like the following, $\mathcal{H}^{MN}=\left(\begin{array}{cc}g_{ij}-b_{ik}g^{kl}b_{lj}&&b_{ik}g^{kj}\\-g^{ik}b_{kj}&&g^{ij}\end{array}\right)$

This is known as the generalized metric in generalized geometry. Additionally, the indices $M,N$ take values from $1$ to $2D$, while the $i,j$ takes values from 1 to D. The $g_{ij}$ here corresponds to a normal Riemannian metric and the $b_{ij}$ is an antisymmetric matrix. The indices on the generalized metric would be raised and lowered using the O(D,D) invariant metric, $\eta^{MN}=\left(\begin{array}{cc}0&\mathbb{1}\\\mathbb{1}&0\end{array}\right)$.

From the xAct documentation, it isn't clear to me how (or even if) it is possible to abstractly define this using the built-in functions. Any tips or references to useful information would be much appreciated!

In this case, there can be several ways of doing what you want. My way of doing this is to define separately the tensors in different vbundles and then using a MakeRule to define how you write $\cal{H}^{MN}$ in terms of the other tensors. Here is an example of a small code which achieves this:

DefManifold[M, 2 D, IndexRange[a, m]]
DefTensor[H[a, b], M4, Symmetric[{a, b}]]


After defining the main manifold, where the generalized metric lives, you have to define two different vbundles which I called "first" and "second" for lack of better names. Note the AIndex they have, this is important, with that you always know with which one you are dealing.

DefVBundle[first, M4, D, {i1, j1, k1, l1, m1, n1}]
DefVBundle[second, M4, D, {i2, j2, k2, l2, m2, n2}]


Also, the numbers allow you to identify which part of the matrix you are dealing with (eg. if you write H[i1,j2] you are referring to the first "line", second "columm" of $\cal{H}^{MN}$). Now you have to define what you call $g_{ij}$ (with inverse $g^{ij}$). In this case you have to define two different tensors, otherwise xTensor will complain about not having the indices in the right positions. This will become clearer later.

DefTensor[g1[i1, j1], M4, Symmetric[{i1, j1}]]
DefTensor[g2[i2, j2], M4, Symmetric[{i2, j2}]]


Thus the tensor g1[i1,j1] with upper indices is meant to represent the $g_{ij}$ with lower indices. It is complicated I know, but I had not found any better way. After that you define the antisymmetric tensor $b_{ij}$.

DefTensor[B[-a, -b], M4, Antisymmetric[{-a, -b}]]


And define the rules:

MakeRule[{H[i1, j1], g1[i1, j1] - B[i1, -k2] g2[k2, l2] B[-l2, j1]}]
MakeRule[{H[i1, j2], B[i1, -k2] g2[k2, j2]}]
MakeRule[{H[i2, j1], -B[-k2, j1] g2[i2, k2]}]
MakeRule[{H[i2, j2], g2[i2, j2]}]


And you can also define them all together in a big rule. About using the invariant $O(D,D)$ metric, this is a bit harder to implement automatically, but I hope this helps.

• This is great! Before reading this I had been just forming a table that I called the generalized metric. I just wish there was a nice way for xTensor to treat generalized tangent bundles on manifolds. – Kenny H Feb 23 '18 at 16:52