Help defining a commutator and using rules

72 views
Skip to first unread message

Alexis Navarro Ruiz

unread,
Mar 25, 2026, 5:48:16 PMMar 25
to xAct Tensor Computer Algebra
Hey everyone, I'm new to Mathematica and even newer to xAct, so I don't really know much about it. I'm currently working on gauge theories in gravity, and I'd like to define a commutator for the covariant derivative or set up the abstract algebra of the group I'm working with, so I can use it in later calculations maybe like MakeRule… but I have no idea how to do it. Could anyone give me a hand or share their experience on how to go about this sort of thing?

Thanks to everyone
Alex

Juan Margalef

unread,
Mar 30, 2026, 11:47:39 AMMar 30
to xAct Tensor Computer Algebra
Hi Alex,

It is a bit hard to know what you are trying to achieve without further details. Try to provide some examples of what you have done and exactly what you want to do (add code and formulas if possible). When you sat "commutator for the covariant derivative" are you talking about the curvature on a vector bundle? If so, you can use

DefManifold[M, 4, {a, b, c, d, f}]
DefVBundle[inner, M, 5, {A, B, C, D, F}]
DefCovD[CD[-a], inner]

That would define the FRiemann tensor which might be what you are looking for.

Best,
Juan

Alexis Navarro Ruiz

unread,
Apr 11, 2026, 1:59:04 AM (12 days ago) Apr 11
to xAct Tensor Computer Algebra
Right, what I was trying to say is that I needed a way to properly define a commutator for the covariant derivative defined as D[-i]u = P[-i][u] + [A[-i], u]. The problem was that the 'times' product was commutative, so the commutator kept giving me zero. I found that I can define a product like this to get around it:

<< xAct`xTensor`;
DefManifold[Mint, 4, {a, b, c, d, f, h}];
DefMetric[-1, \[Eta][-a, -b], PD, PrintAs -> "\[Eta]", FlatMetric -> True];
DefTensor[GenJ[-a], {Mint}, PrintAs -> "J"];

DefProduct[prod, {
  AssociativeProductQ -> True,
  IdentityElementOfProduct -> 1,
  CommutativityOfProduct -> None,
  GradedProductQ -> False,
  GradeOfProduct -> 0,
  ScalarsOfProduct -> NumericQ,
  PrintAs -> " "}];

Now though, when I try using MakeRule:

Rule1 = MakeRule[{prod[GenJ[-b], GenJ[-a]], prod[GenJ[-a], GenJ[-b]]},
   MetricOn -> All];
prod[GenJ[-a], GenJ[-b]] - prod[GenJ[-b], GenJ[-a]] /. Rule1 // ToCanonical

It returns:

-(prod[GenJ[-a], GenJ[-b]]) + prod[GenJ[-b], GenJ[-a]]

hich should be zero. 
The rule doesn't apply to the whole expression—but when it's just a single term, it does.
Do you know any way to handle this?

Thank you
Alex

Juan Margalef

unread,
Apr 12, 2026, 10:55:15 AM (11 days ago) Apr 12
to xAct Tensor Computer Algebra
Several comments:

1. Instead of  CommutativityOfProduct -> None use  CommutativityOfProduct -> "Anticommutative".
2. The rule you created just works for the specific case  prod[GenJ[-b], GenJ[-a]]. If you put any other indices, it won't work. 
3. For your purposes, I think is better to use abstract internal indices with DefVBundle instead of DefProduct. Take a look at https://www.youtube.com/watch?v=FlkuIEyalPA&list=PLdIcYTEZ4S8TSEk7YmJMvyECtF-KA1SQ2&index=5

Best,
Juan
Reply all
Reply to author
Forward
0 new messages