corrections to: Re: calculus with Grassmann variables
- To: mathgroup at smc.vnet.net
- Subject: [mg21034] corrections to: Re: [mg20970] calculus with Grassmann variables
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Sun, 12 Dec 1999 23:51:04 -0500 (EST)
- Organization: Wolfram Research, Inc.
- References: <199912010650.BAA07735@smc.vnet.net> <8264m8$da7@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Daniel Lichtblau wrote: > > Diego Bellisai wrote: > > > > Hi everybody, > > I am looking for a Mathematica package or notebook which allows me > > to deal with Grassmann (anticommuting) variables and to perform > > calculations with both (standard) commuting and anticommuting variables. > > In particular, I am interested in performing matrix calculus (products, > > determinants and so on) with "anticommuting entries" matrices and with > > commuting entries matrices. > > ... > > Say you encapsulate all anticommuting variables with the head avar[]. > Then you can define product rules to handle the commutation relations > and furthermore distribute over Plus, pull out "scalars" (everything not > with head of avar) using ordinary Times, and so on... > > The rules below illustrate this method, though perhaps they could be > simplified somewhat. They pass some basic sanity tests but I'd not > guarantee that they are bug-free. > > Clear[myTimes]; > myTimes[a___,avar[x_],b___,avar[x_],c___] := 0 > myTimes[avar[x_],avar[y_],avar[z_]...] /; Not[OrderedQ[{x,y,z}]] := > (Signature[{x,y,z}]* > myTimes[Sequence @@ Map[avar,Sort[{x,y,z}]]]) > myTimes[a_] /; Head[a]=!=Times := a > myTimes[x___,y_Plus,z___] := > myTimes[x,#,z]& /@ y > myTimes[x___,y_Times,z___] := > myTimes[x,Apply[Sequence,y],z] > myTimes[x___,y_myTimes,z___] := > myTimes[x,Apply[Sequence,y],z] > myTimes[] = 1; > myTimes[vars__] /; Length[{vars}]>2 := Module[{vl={vars},antis,coms}, > antis = Cases[vl,avar[_]]; > coms = Complement[vl, antis]; > Apply[Times,coms]*Apply[myTimes,antis] > ] > myTimes[a_,b_] /; Head[a]=!=avar && Head[b]=!=avar := a*b > Here is an example. We take a 3x3 matrix with avar[] entries and find > its inner product with itself using these rules. > > m1 = {{avar[1],x,avar[2]}, > {x2,avar[1]+2*avar[2],3*avar[1]-avar[2]}, > {avar[1]-avar[2],x3,-3*avar[1]+avar[2]}}; > > In[324]:= InputForm[Inner[myTimes, m1, m1]] > Out[324]//InputForm= > {{x*x2 - myTimes[avar[1], avar[2]], 2*x*avar[2] + myTimes[x, avar[1]] + > myTimes[avar[1], x] + myTimes[avar[2], x3], 3*x*avar[1] - x*avar[2] + > 4*myTimes[avar[1], avar[2]]}, {2*x2*avar[2] + myTimes[x2, avar[1]] + > myTimes[avar[1], x2] - 2*myTimes[avar[1], avar[2]], > x*x2 + 3*x3*avar[1] - x3*avar[2], myTimes[x2, avar[2]] - > 7*myTimes[avar[1], avar[2]]}, {x2*x3 + 3*myTimes[avar[1], avar[2]], > -3*x3*avar[1] - x*avar[2] + 2*x3*avar[2] + myTimes[x3, avar[1]] + > myTimes[avar[1], x] + myTimes[avar[2], x3], 3*x3*avar[1] - x3*avar[2] > + > myTimes[avar[1], avar[2]]}} The example above shows a small flaw wherein we do not correctly change products involving a single anticommuting variable. In particular the last rule should have an Or rather than an And. myTimes[a_,b_] /; Head[a]=!=avar || Head[b]=!=avar := a*b Moreover the next-to-last rule allowed for an infinite recursion problem (try doing Inner[myTimes, Inner[myTimes,m1,m1], m1] to see it). The fix is myTimes[vars__] /; Length[{vars}]>2 := Module[{vl={vars},antis,coms}, antis = Cases[vl,avar[_]]; coms = Complement[vl, antis]; Apply[Times,coms]*Apply[myTimes,antis] /; Length[coms]>0 ] > Now for the determinant computation. > > Clear[ncDet] > ncDet[{{a_}}] := a > ncDet[mat_?MatrixQ] /; Length[mat]===Length[mat[[1]]] := > With[{len=Length[mat], mat1=Drop[mat,{1}]}, > Sum[myTimes[mat[[1,j]],ncDet[Drop[mat1,None,{j}]]], {j,len}]] This needs a correction and an improvement. The correction is to alternate signs (otherwise we have the permanent rather than the determinant). The improvement, for efficiency, is to memo-ize results so that we do not recompute minor expansions but instead look them up after they are once computed. We get: ncDet[mat_?MatrixQ] /; Length[mat]===Length[mat[[1]]] := ncDet[mat] = With[{len=Length[mat], mat1=Drop[mat,{1}]}, Sum[(-1)^(j+1)*myTimes[mat[[1,j]],ncDet[Drop[mat1,None,{j}]]], {j,len}]] Daniel Lichtblau Wolfram Research
- References:
- calculus with Grassmann variables
- From: Diego Bellisai <diego.bellisai@pd.infn.it>
- calculus with Grassmann variables