We want to simplify a polynomial in the variables of (10.1). We begin by setting the variables noncommutative with the following command.
In[5]:= SetNonCommutative[y, Inv[y], Inv[1-y], a, x]
|
Next we must give the computer a precise idea of what we mean by “simple” versus “complicated”. This formally corresponds to specifying an order on the indeterminates. If Inv[y] and Inv[1 - y] are going to stand for the inverses of y and 1 - y respectively, as the notation suggests, then the order
In[6]:= SetMonomialOrder[{ y, Inv[y], Inv[1-y], a, x}]
|
Suppose that we want to connect the Mathematica variables Inv[y] with the mathematical idea of the inverse of y and Inv[1 - y] with the mathematical idea of the inverse of 1 - y. Then just type 3 in the defining relations for the inverses involved.
In[7]:= resol = {y ** Inv[y] == 1, Inv[y] ** y == 1,
(1 - y) ** Inv[1 - y] == 1, Inv[1 - y] ** (1 - y) == 1} Out[7]= {y ** Inv[y] == 1, Inv[y] ** y == 1, (1 - y) ** Inv[1 - y] == 1, Inv[1 - y] ** (1 - y) == 1} |
As an example of simplification, we simplify the two expressions x**x and x + Inv[y] **Inv[1 -y] assuming that y satisfies resol and x **x = a. The following command computes a Gröbner Basis for the union of resol and {x2 - a} and simplifies the expressions x **x and x + Inv[y] **Inv[1 - y] using the Gröbner Basis. Experts will note that since we are using an iterative Gröbner Basis algorithm which may not terminate, we must set a limit on how many iterations we permit; here we specify at most 3 iterations.
In[8]:= NCSimplifyAll[{x**x,x+Inv[y]**Inv[1-y]},Join[{x**x-a},resol],3]
Out[8]= {a, x + Inv[1 - y] + Inv[y]} |
We name the variable Inv[y], because this has more meaning to the user than would using a single letter. Inv[y] has the same status as a single letter with regard to all of the commands which we have demonstrated.
Next we illustrate an extremely valuable simplification command. The following example performs the same computation as the previous command, although one does not have to type in resol explicitly. More generally one does not have to type in relations involving the definition of inverse explicitly. Beware, NCSimplifyRationalX1 picks its own order on variables and completely ignores any order that you might have set.
In[9]:= <<NCSRX1.m
In[10]:= NCSimplifyRationalX1[{x**x**x,x+Inv[z]**Inv[1-z]},{x**x-a},3] Out[11]= {a ** x, x + Inv[1 - z] + inv[z]} |
WARNING: Never use inv[ ] with NCGB since it has special properties given to it in NCAlgebra and these are not recognized by the C++ code behind NCGB