19.2 NCCollectOnVars

An extremely important option for NCProcess is NCCollectOnVars. In addition to being an option, it can be called as a stand-alone command.

19.2.1 NCCollectOnVars[aListOfExpressions, aListOfVariables]

Aliases: NCCV
Description: This is a command which “collects” certain products of each variables in aListOfVariables, thus it returns a ”collected polynomial”. In NCProcess, when this is used via NCCV True, the variables are typically chosen to be knowns. The command NCCollectOnVars itself has the option LeftsAndRights True, which prints out a list containing two lists
{{l1,...,lt},{r1,...,rt}}
Here l1 is the left side of term 1 of ”collected polynomial”, and r1 is the right side of term 1 of ”collected polynomial”, etc. An example is
N CCollectOnV   ars[X  * *A * *B * *Z + Y * *A * *B * *Z +  A * *X + A  * *Y, {A, B}] =

                                               (X + Y ) * *A * *B * *Z + A * *(X +  Y) .
with LeftsAndRights False. When LeftsAndRights True, the output is
{{X  + Y,1}, {1,(X +  Y)}}
More detail is in 19.2.
Arguments: aListOfExpressions is a list of expressions. aListOfVariables is a list of variables.
Comments / Limitations: Not available before NCAlgebra1.2

In the example

N CCollectOnV   ars[X * *A * *B * *Z + Y  * *A * *B * *Z + A * *X  + A * *Y,{A, B}] =

                                              (X  + Y ) * *A * *B * *Z + A * *(X + Y ).
note that if we are in an environment where A and B have been set known and X,Y and Z are unknowns, then one may omit the list of variables {A,B} in the call above. In other words,
In[2]:= SetKnowns[A,B];  
In[3]:= SetUnknowns[X,Y,Z];  
In[4]:= NCCollectOnVars[X**A**B**Z + Y**A**B**Z + A**X+A**Y,{A,B}]  
 
Out[4] := (X+Y)**A**B**Z + A**(X+Y)

Another example is if A,Tp[A], B1, Tp[B1] B2, Tp[B2] C1, Tp[C1] C2 and Tp[C2] are knowns and all other variables are unknowns, then:

In[2] := long = E21 ** A ** iE21 ** E22 - E21 ** B1 ** Tp[B1] ** E12 +  
>    E21 ** B2 ** Tp[B2] ** E12 + E22 ** iE12 ** Tp[A] ** E12 -  
>    E21 ** B2 ** C1 ** iE21 ** E22 -  
>    E22 ** iE12 ** Tp[C1] ** Tp[B2] ** E12 +  
>    E21 ** B1 ** Tp[B1] ** E11 ** iE21 ** E22 -  
>    E21 ** B2 ** Tp[B2] ** E11 ** iE21 ** E22 -  
>    E22 ** iE12 ** E11 ** A ** iE21 ** E22 +  
>    E22 ** iE12 ** E11 ** B1 ** Tp[B1] ** E12 -  
>    E22 ** iE12 ** E11 ** B2 ** Tp[B2] ** E12 -  
>    E22 ** iE12 ** Tp[A] ** E11 ** iE21 ** E22 +  
>    E22 ** iE12 ** E11 ** B2 ** C1 ** iE21 ** E22 +  
>    E22 ** iE12 ** Tp[C1] ** Tp[B2] ** E11 ** iE21 ** E22 -  
>    E22 ** iE12 ** E11 ** B1 ** Tp[B1] ** E11 ** iE21 ** E22 +  
>    E22 ** iE12 ** E11 ** B2 ** Tp[B2] ** E11 ** iE21 ** E22  
 
In[3] := NCCollectOnVariables[long]  
 
Out[3]:= E22 ** iE12 ** Tp[A] ** (E12 - E11 ** iE21 ** E22) +  
>    (E21 - E22 ** iE12 ** E11) ** A ** iE21 ** E22 -  
>    (E21 - E22 ** iE12 ** E11) ** B1 ** Tp[B1] **  
>    (E12 - E11 ** iE21 ** E22) +  
>    (E21 - E22 ** iE12 ** E11) ** B2 ** Tp[B2] **  
>    (E12 - E11 ** iE21 ** E22) -  
>    E22 ** iE12 ** Tp[C1] ** Tp[B2] ** (E12 - E11 ** iE21 ** E22) -  
>    (E21 - E22 ** iE12 ** E11) ** B2 ** C1 ** iE21 ** E22

The NCCollectOnVars option LeftAndRight True

This prints out a list containing two lists

{{l1,...,lt},{r1,...,rt}}
Here l1 is the left side of term 1 of ”collected polynomial”, and r1 is the right side of term 1 of ”collected polynomial”, etc. In the example above the list of left sides is
 E22 ** iE12,  
>    (E21 - E22 ** iE12 ** E11),  
>    -(E21 - E22 ** iE12 ** E11),  
>    (E12 - E11 ** iE21 ** E22),  
>    (E21 - E22 ** iE12 ** E11),  
>    (E12 - E11 ** iE21 ** E22),  
>    -E22 ** iE12,  
>    -(E21 - E22 ** iE12 ** E11)

and the list of right sides is

{  
 (E12 - E11 ** iE21 ** E22), iE21 ** E22,  
-(E12 - E11 ** iE21 ** E22),  (E12 - E11 ** iE21 ** E22),  
 -  (E12 - E11 ** iE21 ** E22), - iE21 ** E22 }

The NCProcess option NCCV True

If the NCProcess option NCCV True is set NCProcess will perform the sort of collection described in Section 19.2. Specifically, NCCollectOnVars[ OutputofGroebnerBasisAlgorithms, KnownIndeterminates ] is called before the result is output to LATEX. This has been shown to be useful in the discovery of “motivated unknowns” as discussed in [HS].