# A question about 'sort_product' or 'canonicalise'

+1 vote

Recently, I always stuck on an issue as the following: (In Cadabra2)

{a, b, c}::Indices.
D{#}::Derivative.
ex:=  D^{a}{A} D_{a}{B} + D^{a}{B} D_{a}{A};
sort_product(_);
canonicalise(_);
collect_terms(_);

The correct answer should be 2D^{a}{A} D_{a}{B}. But, I always can't get it. Thus, I am not quite sure what the problem is.

• sort_product : ex should be sorted by indices? or the objects(i.e. A or B)?
• canonicalize : which seems only care about the indices.

By the way, I wish there can be a feature like sort_sum as in the old Cadabra1.

This is now fixed in the version on github. sort_sum is coming.

by (64.9k points)
selected by

sort_sum is now included.

Thanks for spotting this one, it's a bug in sort_product, which should have moved the derivative on $A$ to the left of the derivative on $B$. A subsequent canonicalise would then do the trick. The bug is a consequence of some new code for expression comparison. I'll try to get a fix out asap.