next up previous contents index
Next: Pretty Output Up: NCAlgebra Previous: ReleaseNotes NCAlgebra   Contents   Index


The Most Basic NCAlgebra Commands -- A short tutorial

NCAlgebra is a Mathematica package which allows one to do noncommutative algebraic computations. We will begin by presenting some calculations done with our package which should give some idea of what may be accomplished with NCAlgebra. We suggest that the reader later do these computations for himself with our package when it has been properly installed since it will provide a tutorial as well as an illustration.

In our package ** denotes noncommutative multiply, tp[x] denotes the transpose of an element x, and aj[x] denotes the adjoint of an element x. Note that the properties of transposes and adjoints that everyone constantly uses are built-in. The multiplicative identity is denoted Id in the program. At the present time, Id is set to 1. A element A may have an inverse, which will be denoted by inv[A], of it may have a left or right inverse, denoted inv[A] and invR[A], respectively.

The following examples are independent of each other, however they may be executed in one continuous session. At present, single-letter lower case variables are noncommutative by default and all others are commutative by default.

A Mathematica 3.0 user inside a notebook can use our special Palette by opening the file NCPalette.nb (see Section 2).

To begin start Mathematica and load NCAlgebra.m or NCGB.m.

 

In[1]:= a ** b - b ** a 
Out[1]= a ** b - b ** a

In[2]:= A ** B - B ** A 
Out[2]= 0

In[3]:=	A ** b - b ** a
Out[3]= A b - b ** a

In[4]:= CommuteEverything[a ** b - b ** a] 
Out[4]= 0

In[5]:= SetNonCommutative[A, B]
Out[5]= {False, False}

In[6]:= A ** B - B ** A
Out[6]= A ** B - B ** A     

In[7]:= SetNonCommutative[A];SetCommutative[B]
Out[7]= {True} 

In[8]:= A ** B - B ** A
Out[8]= 0
SNC is an alias for SetNonCommutative. So, SNC can be typed rather than the longer SetNonCommutative.
In[9]:= SNC[A]; 	
In[10]:= A ** a - a ** A  
Out[10]= A ** a - a ** A 

In[11]:= SetCommutative[v]; 
In[12]:= v ** b
Out[12]= v b

In[13]:= NCCollect[a ** x + b ** x, x]
Out[13]= (a + b) ** x

In[14]:= NCExpand[(a + b) ** x]
Out[14]= a ** x + b ** x

In[15]:= NCCollect[tp[x] ** a ** x + tp[x] ** b ** x + z, {x, tp[x]}]  
Out[15]= z + tp[x] ** (a + b) ** x 

In[16]:= DirectionalD[x ** x, x, h]
Out[16]= h ** x + x ** h

In[17]:= Grad[tp[x] ** x + tp[x]**A**x + m**x, x]
         (* Here A is noncommutative and x represents a column vector*)
Out[17]= 2 x + A ** x + tp[A] ** x + tp[m]
Warning: Grad is trustworthy only on certain quadratics.


IMPORTANT: The Mathematica substitute commands $ \backslash.  \rightarrow $ and $ \backslash :>$ are not reliable in NCAlgebra, so you must use our substitute command.

In[18]:= Substitute[x ** a ** b, a ** b -> c]
Out[18]= x ** c

In[19]:= Substitute[ tp[b ** a] + b ** a, b ** a -> p]  
Out[19]= tp[a] ** tp[b] + p

In[21]:= SubstituteSymmetric[tp[b] ** tp[a] + w + a ** b, a**b->c] 
Out[21]= c + w + tp[c] 

In[23]:= MatMult[{{a, b}, {c, d}}, {{d, 2}, {e, 3}}]  
Out[23]= {{a ** d + b ** e, 2 a + 3 b}, {c ** d + d ** e, 2 c + 3 d}}

In[24]:= tp[a ** b]
Out[24]= tp[b] ** tp[a]

In[25]:=tp[5]
Out[25]= 5

In[26]:= tp[2 + 3 I]
Out[26]= 2 + 3 I

In[27]:= tp[a]
Out[27]= tp[a]

In[28]:= tp[a + b]
Out[28]= tp[a] + tp[b]

In[29]:= tp[6 x]
Out[29]= 6 tp[x]

In[30]:= tp[tp[a]]
Out[30]= a

In[31]:= aj[5]
Out[31]= 5

In[32]:= aj[2 + 3 I]
Out[32]= 2 - 3 I

In[33]:= aj[a]  
Out[33]= aj[a]

In[34]:= aj[a + b] 
Out[34]= aj[a] + aj[b]

In[35]:= aj[6 x] 
Out[35]= 6 aj[x]

In[36]:= aj[aj[a]]  
Out[36]= a

In[37]:= Id 
Out[37]= 1

In[38]:= inv[a ** b]  
Out[38]= inv[b] ** inv[a]

In[39]:= inv[a] ** a
Out[39]= 1

In[40]:= a ** inv[a] 
Out[40]= 1

In[41]:= a ** b ** inv[b] 
Out[41]= a

In[42]:= invL[a] ** a
Out[42]= 1

In[43]:= a ** invR[a]
Out[44]= 1

In[45]:= a ** invL[a] 
Out[45]= a ** invL[a]

In[46]:= invR[a] ** a 
Out[46]= invR[a] ** a 

In[47]:= f1 = 1 + inv[d] ** c ** inv[S - a] ** b - inv[d] ** c ** 
    inv[S - a + b ** inv[d] ** c] ** b - inv[d] ** c ** 
    inv[S - a + b ** inv[d] ** c] ** b ** inv[d] ** c ** 
    inv[S - a] ** b;
In[48]:= NCSimplifyRational[f1]
Out[48]= 1

In[49]:= f2 = inv[1 + 2 a] ** a; 
In[50]:= NCSimplifyRational[f2]
Out[50]= (1 - inv[1 + 2 a]) / 2
NCSR is the alias for NCSimplifyRational.
In[51]:= f3 = a ** inv[1 - a]; 
In[52]:= NCSR[f3] 
Out[52]= inv[1 - a] - 1
 
In[53]:= f4 = inv[1 - b ** a] ** inv[a]; 
In[54]:= NCSR[f4]  
Out[54]= inv[a] ** inv[1 - a ** b]

In[55]:= NCSolve[a ** x == b, x] 
Out[55]= {x -> inv[a] ** b}
Note: NCSolve applies to some linear equations in only one unknown.

Subsections
next up previous contents index
Next: Pretty Output Up: NCAlgebra Previous: ReleaseNotes NCAlgebra   Contents   Index
NCAlgebra Project 2002-09-09