# Action of sort_product depends on the choice of index

+1 vote

Hi everyone,

I encountered the following surprising example while trying to simplify the expression

F^{d}_{a e}* F^{f}_{b f}  -  F^{f}_{b f}* F^{d}_{a e}

to zero using the following code

{a, b, c, d, e, f, g#}::Indices(T, position= independent, parent=double);
{F^{d}_{a e}, F^{f}_{b f}}::SortOrder.
Exp:= F^{d}_{a e}* F^{f}_{b f}  -  F^{f}_{b f}* F^{d}_{a e};
sort_product(_);
sort_sum(_);
canonicalise(_);
rename_dummies(_);
collect_terms(_);

Strangely, the obtained result is

F^{d}_{a e} F^{c}_{b c}-F^{c}_{b c} F^{d}_{a e}

i.e. sort_product failed to order the products.

Even stranger, if I replace the index f in the first term by c i.e. if use the code:

{a, b, c, d, e, f, g#}::Indices(T, position= independent, parent=double);
{F^{d}_{a e}, F^{f}_{b f}}::SortOrder.
Exp:= F^{d}_{a e}* F^{c}_{b c}  -  F^{f}_{b f}* F^{d}_{a e};
sort_product(_);
sort_sum(_);
canonicalise(_);
rename_dummies(_);
collect_terms(_);

then everything works fine and the output is zero, as it should.

I tested this on both Mac and Ubuntu and the result is the same.

Does anyone have an idea where the bug came from and how to fix it?

Thank you already for any information,

Kevin

Interesting one, let me dig a bit. Just sort_product should have done the trick.