Tensor defenition

51 views
Skip to first unread message

Petr Tretyakov

unread,
Feb 3, 2026, 9:57:18 AMFeb 3
to xAct Tensor Computer Algebra
Dear All,
I'm the novice user of xAct and many thing are clear, but some is not. Please help me understand it. 

Suppose I would like to define some tensor value, which is some combination of metric (and may be something else). I define Some tensor: DefTensor[R[-i, -k, -l, -m], M4] after that I write R[-i,-k,-l,-m]=f  where f is combination of metric tensors what I need. After that I would like to calculate some complicate product of this tensor R with some another one say h[-i,-k] defined before. Program give me result in the terms of tensor R but not metric.  How I can to see the result in the form of metric? 

I try different possibilities like // Simplification // ToCanonical // ContractMetric // ExpandAll and others -- nothing work. May be there exist some special command or may be I need to introduce my combined tensor R by another way?

Juan Margalef

unread,
Feb 4, 2026, 1:34:34 PMFeb 4
to xAct Tensor Computer Algebra
To be able to help you, a bit more information is required. In any case, my educated guess is that your assigment:

R[-i,-k,-l,-m]=f

is not correct. If you use the standard Mathematica approach, the indices are not handled correctly. You have to use IndexSet or IndexSetDelayed, something like this:


DefTensor[R[-i, -k, -l, -m], M4] 
IndexSet[ R[i_, k_, l_, m_]  , B[i,l] C[k, m]

Let us know if that helps or give us a minimal working example.

Best!
Juan

Petr Tretyakov

unread,
Feb 5, 2026, 5:59:25 AMFeb 5
to xAct Tensor Computer Algebra
Ok. Here all commands that I input:

Needs["Xact`xTensor`"]
DefManifold[M4, 4, {\[Lambda], \[Mu], \[Nu], \[Rho], \[Sigma], \[Alpha], \[Beta], \[Gamma], \[Delta], \[Kappa], \[Iota]}]
DefMetric[-1, g[-\[Mu], -\[Nu]], CD];
DefTensor[h[-\[Iota], -\[Kappa]], M4, Symmetric[{-\[Iota], -\[Kappa]}]]
DefTensor[L[-\[Iota], -\[Kappa], -\[Lambda], -\[Mu]], M4]
L[-\[Iota], -\[Mu], -\[Kappa], -\[Nu]] = (g[-\[Iota], -\[Kappa]] g[-\[Mu], -\[Nu]] - g[-\[Mu], -\[Kappa]] g[-\[Iota], -\[Nu]])
eq4 = -h[\[Iota], \[Nu]] L[-\[Iota], -\[Kappa], -\[Lambda], -\[Mu]] L[-\[Nu], \[Kappa], \[Lambda], \[Mu]]
eq4 // Simplification // ToCanonical // ContractMetric // ExpandAll

The question is: I would like to see result for eq4 in terms of g, whereas program return it in terms of h and L -- so how I can do it? 

Juan Margalef

unread,
Feb 5, 2026, 2:53:08 PMFeb 5
to xAct Tensor Computer Algebra
As I guessed, you assigment is not correct for xAct. When you write


L[-\[Iota], -\[Mu], -\[Kappa], -\[Nu]] = (g[-\[Iota], -\[Kappa]] g[-\[Mu], -\[Nu]] - g[-\[Mu], -\[Kappa]] g[-\[Iota], -\[Nu]])

you are telling mathematica to substitute "L with the specific indices -\[Iota], -\[Mu], -\[Kappa], -\[Nu]" by your expression on the right. However, if you put other indices or raise one of them, Mathematica identifies the expression as a different one and it doesn't make the substitution. You can easily check that running:

L[-\[Iota], -\[Mu], -\[Kappa], -\[Nu]]
L[-\[Iota], -\[Mu], -\[Nu], -\[Kappa]]
L[-\[Iota], -\[Mu], -\[Kappa], \[Nu]]


The first expression, which is exactly what you defined, is substituted, but the other ones are not. For that, as I mentioned on my last message, you cannot use your assigment but you need to use IndexSet instead. In your case:

IndexSet[L[\[Iota]_, \[Mu]_, \[Kappa]_, \[Nu]_], g[\[Iota], \[Kappa]] g[\[Mu], \[Nu]] -  g[\[Mu], \[Kappa]] g[\[Iota], \[Nu]]]

If you do that, the expression is substituted regardless of which specific indices you use. You can try again to run 

L[-\[Iota], -\[Mu], -\[Kappa], -\[Nu]]
L[-\[Iota], -\[Mu], -\[Nu], -\[Kappa]]
L[-\[Iota], -\[Mu], -\[Kappa], \[Nu]]

to see the difference. With this correction, you have

IN: eq4 // Simplification 
OUT: -6  g[\[Iota], \[Nu]]   h[-\[Iota], -\[Nu]]

Best,
Juan

Petr Tretyakov

unread,
Feb 7, 2026, 9:18:51 AMFeb 7
to xAct Tensor Computer Algebra
It's working. Great thanks!

Petr
Reply all
Reply to author
Forward
0 new messages