Factorising a tensor outside of an expression

20 views
Skip to first unread message

ali khaled

unread,
Jun 18, 2025, 7:43:20 AMJun 18
to xAct Tensor Computer Algebra
Hello all,

See image below please. 

I have this expression, which involves my tensor J in every term, and I want to factorise it outside. Is there a command that does it?

Screenshot from 2025-06-18 14-12-30.png
Thanks,
Ali

Thomas Bäckdahl

unread,
Jun 18, 2025, 9:05:49 AMJun 18
to xa...@googlegroups.com
Hi!

If the name of your tensor is JJ, you can try things like

Collect[ScreenDollarIndices[%], {JJ[__]}]

However, this will not work perfectly because the indices will be different in the different terms.

The main problem is that you have free indices in your expression. This makes it difficult to get the same indices on J for all terms.
If you don't have any free indices you can use the almost experimental function IndexCollect.
However, in your case with free indices it will not work correctly.

With free indices I don't know if collecting tensors is mathematically well defined due to the index structure.

However, just using Collect as above could help a bit.
You can also change the way ToCanonical is rearranging the indices by setting the xSortPrecedence value for the tensor.
This affects the ordering of the factors used determine the canonical index ordering.
For instance with
xSortPrecedence[JJ] ^= 150;
the tensor JJ is moved to the right and with
xSortPrecedence[JJ] ^= 50;
it is moved to the left.
You will not see this in the output of ToCanonical because Mathematical automatically rearranges the orders of the factors. However, it can affect the canonical ordering of the indices.

When you have set the xSortPrecedence value you can for instance try this on your expression
Collect[ScreenDollarIndices[ToCanonical[SeparateMetric[g]@%, UseMetricOnVBundle -> None]], {JJ[__]}]

This will not completely solve your problem, but you might get slightly shorter expressions.

Regards
Thomas
--
You received this message because you are subscribed to the Google Groups "xAct Tensor Computer Algebra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xact+uns...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/xact/5c4e9ba2-d8d3-4806-8a0d-28446a0eae40n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages