CliffSymNil11`

Sym-Clifford, Idem-Clifford, and Nil-Clifford computations

G. Stacey Staples

August 2011

BeginPackage["CliffSymNil11`"];
Needs["CliffMath11`"];

(* Define symmetric product for commutative algebra ((Subscript[Cl, p,q,r])^sym). Generators satisfy the following rules *)

(* (Subscript[e, {j}]) ⊕ (Subscript[e, {k}]) = (Subscript[e, {k}]) ⊕ (Subscript[e, {y}])   k ≠ j  *)
(* (Subscript[e, {j}]) ⊕ (Subscript[e, {j}]) = 1 if 1 ≤ j ≤ p   *)
(* (Subscript[e, {j}]) ⊕ (Subscript[e, {j}]) = -1 if p+1 ≤ j ≤ p+q  *)
  (* (Subscript[e, {j}]) ⊕ (Subscript[e, {j}]) = 0 if p+q < j ≤ p+q+r *)

Unprotect[CirclePlus];(* symmetric Clifford product *)


SymProductSignatureMap[I_,J_]:=Module[{j},If[Mu[pPart+qPart,Intersection[I,J]]≠0,0,(-1)^(Mu[pPart,Intersection[I,J]])]];
Protect[SymProductSignatureMap];

Unprotect[CirclePlus];
ClearAll[CirclePlus];
SetAttributes[CirclePlus,{Flat, OneIdentity, Listable}];

CirclePlus[x_. (Subscript[e, a_]),y_. (Subscript[e, b_])]:=Expand[x y SymProductSignatureMap[a,b]](Subscript[e, SetSymmetricDifference[a,b]])/.{(Subscript[e, {}])->1};

CirclePlus[x_, y_]:=Expand[x y] /;(FreeQ[x,(Subscript[e, _])]∨FreeQ[y,(Subscript[e, _])]);

CirclePlus=Symbol["CirclePlus"];
Protect[CirclePlus];

Unprotect[ClSymExpand];
ClearAll[ClSymExpand];
SetAttributes[ClSymExpand,Listable];
ClSymExpand[x_ + y_]:= Block[{$RecursionLimit=∞},Simplify[ClSymExpand[x] + ClSymExpand[y]]];
ClSymExpand[x_?NumericQ  arg1_]:=x ClSymExpand[arg1];
ClSymExpand[arg1_]:= Module[{arg2},
arg2 = Distribute[ExpandAll[arg1],Plus, CirclePlus];
If[!FreeQ[arg2,_⊕_] && arg2  !=  arg1,
arg2 =  ClSymExpand[arg2];
];
Return[Collect[arg2,(Subscript[e, _])]];
];
Protect[ClSymExpand];


(* Compute powers of Clifford elements *)
ClSymPower[x_,n_Integer]:=Module[{y},y=ClSymExpand[x];Switch[EvenQ[n],
True,If[n==0,Return[1],Return[ClSymPower[(y⊕y),(n/2)]]],
False,If[n==1,Return[y],Return[ClSymExpand[y⊕ClSymPower[(y⊕y),((n-1)/2)]]]]];];

(* Procedure to multiply matrices with (Cl^sym) entries *)
ClSymMatrixProduct[A_,B_]:=Inner[CirclePlus, A, B, Plus];

(* A procedure for computing powers of matrices with (Cl^sym) entries. In this method, A^m is computed by recursive squaring ((A^2)^2...)A *)
ClSymMatrixPower[A_,m_]:=Module[{y},y=ClSymExpand[A];Switch[EvenQ[m],
True,If[m==0,Return[IdentityMatrix[Length[y]]],Return[ClSymMatrixPower[ClSymMatrixProduct[y,y],(m/2)]]],
False,If[m==1,Return[y],Return[ClSymExpand[ClSymMatrixProduct[ClSymMatrixPower[ClSymMatrixProduct[y,y],((m-1)/2)],y]]]]]];

(* Define product for commutative algebra ((Subscript[Cl, n])^nil).  Generators satisfy the following conditions: *) 
(*(Subscript[e, {j}]) ⊖ (Subscript[e, {k}]) = (Subscript[e, {k}]) ⊖ (Subscript[e, {j}])   k≠j *)
(* (Subscript[e, {j}]) ⊖ (Subscript[e, {j}])=0                *)
  
Unprotect[CircleMinus];
ClearAll[CircleMinus];
SetAttributes[CircleMinus,{Flat, OneIdentity, Listable}];
CircleMinus[x_. (Subscript[e, a_]),y_. (Subscript[e, b_])]:=If[Length[a⋂b]>0,0,Expand[x y (Subscript[e, a⋃b])]];

CircleMinus[x_, y_]:=Expand[x y] /;(FreeQ[x,(Subscript[e, _])]∨FreeQ[y,(Subscript[e, _])]);

CircleMinus=Symbol["CircleMinus"];
Protect[CircleMinus];

Unprotect[ClNilExpand];
ClearAll[ClNilExpand];
SetAttributes[ClNilExpand,Listable];
ClNilExpand[x_ + y_]:=Block[{$RecursionLimit=∞}, Simplify[ClNilExpand[x] + ClNilExpand[y]]];
ClNilExpand[x_?NumericQ  arg1_]:=x ClNilExpand[arg1];
ClNilExpand[arg1_]:= Module[{arg2},
arg2 = Distribute[ExpandAll[arg1],Plus, CircleMinus];
If[!FreeQ[arg2,_⊖_] && arg2  !=  arg1,
arg2 =  ClNilExpand[arg2];
];
Return[Collect[arg2,(Subscript[e, _])]];
];
Protect[ClNilExpand];

(* Compute powers of (Cl^nil) elements *)
ClNilPower[x_,n_Integer]:=Module[{y},y=ClNilExpand[x];Switch[EvenQ[n],
True,If[n==0,Return[1],Return[ClNilPower[(y⊖y),(n/2)]]],
False,If[n==1,Return[y],Return[ClNilExpand[y⊖ClNilPower[(y⊖y),((n-1)/2)]]]]];];

(* Procedure to multiply matrices with (Cl^nil) entries *)
ClNilMatrixProduct[A_,B_]:=Inner[CircleMinus, A, B, Plus];

(* A procedure for computing powers of (Cl^(nil ))matrices. In this method, A^m is computed by recursive squaring ((A^2)^2...)A *)
ClNilMatrixPower[A_,m_]:=Module[{y},y=ClNilExpand[A];Switch[EvenQ[m],
True,If[m==0,Return[IdentityMatrix[Length[y]]],Return[ClNilMatrixPower[ClNilMatrixProduct[y,y],(m/2)]]],
False,If[m==1,Return[y],Return[ClNilExpand[ClNilMatrixProduct[ClNilMatrixPower[ClNilMatrixProduct[y,y],((m-1)/2)],y]]]]]];

(* Define idempotent product for commutative algebra ((Subscript[Cl, MaxIndex])^idem). Generators satisfy the following rules *)
(* (Subscript[e, {j}])⋄(Subscript[e, {k}]) = (Subscript[e, {k}])⋄(Subscript[e, {y}])   k ≠ j     *)
(* (Subscript[e, {j}])⋄(Subscript[e, {j}]) = (Subscript[e, {j}])   1 ≤ j ≤ MaxIndex *)
(* x⋄y is entered by typing x[ESC]dia[ESC]y *)  

Unprotect[Diamond];
ClearAll[Diamond];
SetAttributes[Diamond,{Flat, OneIdentity, Listable}];
Diamond[x_. (Subscript[e, a_]),y_. (Subscript[e, b_])]:=Expand[x y ](Subscript[e, a⋃b])/.{(Subscript[e, {}])->1};

Diamond[x_, y_]:=Expand[x y] /;(FreeQ[x,(Subscript[e, _])]∨FreeQ[y,(Subscript[e, _])]);


Diamond=Symbol["Diamond"];
Protect[Diamond];

Unprotect[ClIdExpand];
ClearAll[ClIdExpand];
SetAttributes[ClIdExpand,Listable];
ClIdExpand[x_ + y_]:= Block[{$RecursionLimit=∞},Simplify[ClIdExpand[x] + ClIdExpand[y]]];
ClIdExpand[x_?NumericQ  arg1_]:=x ClIdExpand[arg1];
ClIdExpand[arg1_]:= Module[{arg2},
arg2 = Distribute[ExpandAll[arg1],Plus, Diamond];
If[!FreeQ[arg2,_⋄_] && arg2  !=  arg1,
arg2 =  ClIdExpand[arg2];
];
Return[Collect[arg2,(Subscript[e, _])]];
];
Protect[ClIdExpand];

(* Compute powers of (Cl^sym) elements *)
ClIdPower[x_,n_Integer]:=Module[{y},y=ClIdExpand[x];Switch[EvenQ[n],
True,If[n==0,Return[1],Return[ClIdPower[(y⋄y),(n/2)]]],
False,If[n==1,Return[y],Return[ClIdExpand[y⋄ClIdPower[(y⋄y),((n-1)/2)]]]]];];

(* Procedure to multiply matrices with (Cl^sym) entries *)
ClIdMatrixProduct[A_,B_]:=Inner[Diamond, A, B, Plus];


(* A procedure for computing powers of matrices with (Cl^sym) entries. In this method, A^m is computed by recursive squaring ((A^2)^2...)A *)
ClIdMatrixPower[A_,m_]:=Module[{y},y=ClIdExpand[A];Switch[EvenQ[m],
True,If[m==0,Return[IdentityMatrix[Length[y]]],Return[ClIdMatrixPower[ClIdMatrixProduct[y,y],(m/2)]]],
False,If[m==1,Return[y],Return[ClIdExpand[ClIdMatrixProduct[ClIdMatrixPower[ClIdMatrixProduct[y,y],((m-1)/2)],y]]]]]];


EndPackage[];