collect_factors
Collect identical factors in a product.
Collect factors in a product that differ only by their exponent. Note
that factors containing sub- or superscripted indices do not get
collected (i.e. AmAm does not get reduced to (Am)2).ex:=A A B A B A;
AABABA
collect_factors(_);
A4B2
Arbitrary powers can be collected this way,
ex:=X X**(-1) X**(-4);
XX−1X−4
collect_factors(_);
X−4
The exponent notation can be expanded again
using
expand_power
.ex:=X**4;
expand_power(_);
X4
XXXX