Chapter 3
Helpful Tricks

3.1 Expanding

NCExpand is the most common command applied to expressions. Often you must do it to achieve the most obvious cancellations. See page 14 of Chapter 1 or Section 5.1.1.

3.2 Simplifying Expressions

A person experienced in noncommutative calculations simplifies expressions in two ways:

1. Write the expression in the shortest possible form with special attention given to subexpressions with physical or special mathematical meaning.

2. The other is to expand expressions, apply simplifying rules repeatedly to each term, and see which terms cancel.

3.2.1 Simplifying Rules

The second method is the one which for commuting algebras has been developed to a high art in computer calculation. The idea is very simple and intuitive. Simplification is done with rules which replace complicated monomials with sums of simpler monomials, e.g.,

         inv[1-x] ** x -> inv[1-x]-1  
         inv[a+b ** c] ** b ** c -> 1-inv[a+b ** c] ** inv[a]

throughout the expression to be simplified. When you use NCAlgebra you will often be making up such rules and substituting them in expressions. In a fixed collection of applications you can make your life easier if you save the rules and use them over and over again. The best way to do this is to put them in a function, say

    MyRules=  
        {inv[1-x_] :> inv[x]-1,  
         inv[a+b ** c] ** b ** c -> 1-inv[a+b ** c] ** inv[a]};  
 
    MySimplify[expr_]:=Substitute[expr, MyRules];

One of the trickier fine points is how to set the blanks in your rules. If you do not use blanks that’s fine provided you always use the same letters and do not replace them with other notation in some equation. Clearly using blanks is much more powerful. The trick is how many. For example, x_ is ok here. APPENDIX E discusses this.

3.2.2 Orders

The next major point is not to go into a loop. To this end one must select an ordering, call it COM, on monomials. For mnemonic purposes it is best to select the ordering to reflect your intuitive idea of which monomials are more complicated than others. For example if all of your formulas involve polynomials in

            x, inv[x], inv[1-x ** y], inv[1-y ** x],  
                      y,  inv[y]

a natural partial ordering is given by low degree < high degree

We then subdivide equivalence classes of this ordering with

 
                          x            inv[x]           inv[1-x ** y]  
commutative expr  <               <                <  
                          y            inv[y]           inv[1-y ** x]

then we subdivide equivalence classes of this ordering with lexicographical order, i.e , x < y.

A reasonable convention is that higher order expressions move RIGHT.

For example, a basic equality is

   inv[1-x ** y] ** x- x ** inv[1 - y ** x]==0 .

This translates to the rule

   inv[1-x ** y] ** x -> x ** inv[1-y ** x]

because inv[1-x ** y] is ’complicated’ and we move it RIGHT. To harp on an earlier point we would suggest using the more powerful delayed assignment form of the rule:

   inv[1-x__ ** y_] ** x__ :> x ** inv[1- y ** x]

IMPORTANT: these are the ordering conventions we use in NCSR. If you write rules consistent with them then you will then you can use them and NCSR without going into a loop. Indeed NCSR contains a “Gröbner basis” for reducing the set of polynomials in the expressions (inv).

Here is a summary of the ordering conventions ranked from most complicated to the least:

    high degree>low degree  
    inv of complicated polynomials  
    inv of simple polynomials  
    complicated polynomials  
    simple polynomials  
    commuting elements and expressions in them.

REMEMBER HIGHER ORDER EXPRESSIONS MOVE RIGHT.

3.2.3 Automatic generation of rules

Automatic generation of rules is the subject of the NCGB part of this document. Since running the NCGB code requires C++, you may not have it. Here NCSimplifyRationalX1[] does the trick.

Lying around in the directory NC/NCAlgebra/OldmmaGB/ is a primative NCSimplifyRationalX1[] which works entirely under Mma. We don’t support it since our efforts go to Mma C++ hybrids. We do not even recall its name. Anyone who resurrects it must be an intrepid adventurer.

3.3 Edit -  For those without Notebooks

The failsafe command Edit does not get enough emphasis in the Mathematica literature. This command guarantees that Mathematica is never worse than a yellow pad. Whenever you have an expression ’expr’ and the functions at your disposal are not doing what you want just enter

In[102]:=Edit[expr]

Mathematica throws you into a file containing expr. You can edit it with the vi or emacs editor or whatever is set up. Then exiting the file throws your edited expression into the Out[102] (see above). A truly remarkable feature is that

YOU CAN EDIT Mathematica FUNCTIONS (INCLUDING NCAlgebra FUNCTIONS) INTO EXPR, APPLYING DIFFERENT FUNCTIONS TO DIFFERENT PARTS OF EXPR, then these are automatically executed when you finish editing the file. A tutorial example of this extremely powerful feature is

Out[32]= x**y + x**z + x**y**x  
 
In[33]:= Edit[%]

A new screen comes up and you can use your resident editor on it.

x**y + x**z + x**y**x

I usually make another copy of the expression for safety sake and make edits on one of them, while commenting out the second so it does not get read by Mathematica. This way if I make errors, I still have the original expression to fall back on and check with. This is especially useful when dealing with complicated expressions. For example, you could write

NCCollect[x ** y + x ** z,x] + x ** y **x;  
(* x**y + x**z + x**y**x *)

Now quit editing and close the file, (e.g., :wq for vi).

Out[33]: x ** (y + z) + x ** y ** x

3.4 Conventions

The NCAlgebra files which are called by NCAlgebra.m start with NC. This makes moving them easier; cp NC* someplace/ where “someplace” is any directory of your choosing. Many operations on expressions start with NC .

Aliases are all caps like NCC for NCCollect or NCE (for NCExpand). The caps correspond exactly to the caps in the full function name. Exceptions are cases like Sub or SubSym where CAPs are followed by 2 lower case letters. This prevents ambiguities and two letter aliases.

Function names are written in a certain order: Command or action you wish taken comes first. The special properties of what you apply it to are second.

For example, let’s look at NCSimplifyRational. The action is Simplify. The range of validity is “Rational” functions.

Files whose only function is to call other files have names which are all capital letters.