# 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. $A_m A^m$ does not get reduced to $(A_m)^2$).ex:=A A B A B A;

\(\displaystyle{}A A B A B A\)

collect_factors(_);

\(\displaystyle{}A^{4} B^{2}\)

Arbitrary powers can be collected this way,

ex:=X X**(-1) X**(-4);

\(\displaystyle{}X X^{-1} X^{-4}\)

collect_factors(_);

\(\displaystyle{}X^{-4}\)

The exponent notation can be expanded again
using

`expand_power`

.ex:=X**4;
expand_power(_);

\(\displaystyle{}X^{4}\)

\(\displaystyle{}X X X X\)