The key to computing ``parenthesized'' representations of a polynomial is the use of NCCollectOnVariables which has the NCAlgebra command NCCollect at its core. Before discussing the NCCollect command, we define a notion of homogeneous (noncommuting) polynomial.
Definition 9.1 Let p be a polynomial and V be a set of variables. p is homogeneous in V if for every v V, the number of occurences of v in each term of p is independent of the term.
Of course, x y z x + x x is homogeneous in {x,x}, x y z x + x z y is homogeneous in {y, z} and but x y z x + x z is not homogeneous in {x, x} (since the number of x is the first term is 1 and the number of x is the second term is 0).
When given a polynomial p and a set of variables V, NCCollect first writes the polynomial p as a sum of polynomials which are homogeneous in V. For each summand, NCCollect writes (to the extent possible) the polynomial into a ``parenthesized'' form using the rules
c p v + c p v p | = | p v (c + c p) | c p v p + c p v | = | p v (c p + c) |
c p v p + c v p | = | (c p + c) v p | c v p + c p v p | = | (c + c p) v p |
c p v p + c p v p | = | p v (c p + c p) | c p v p + c p v p | = | (c p + c p) v p |
c v + c v p | = | v (c + c p) | c v + c p v | = | (c + c p) v |
where v is a variable in V, c and c are scalars, and p , p and p are polynomials.
If none of the above rules apply to a V-homogeneous polynomial, then we say that its only collected form is trivial. If a polynomial is a sum of polynomials whose only collected form is trivial, then we say that this sums only collected form is trivial.