/* file pauli1.mac tellsimpafter methods used after commutator has been expanded and scalars, numbers, and %i's have been factored out by commutators.mac. sig[1], etc, with lower case 's' for symbolic sigma matrix Sig[1], etc, with upper case 'S' for explicit matrix. See definitions of explicit matrices S[k], k = 1,2,3, as well as mcomm, Z2, stoex, and xcomm (A,B) with examples of use to compare symbolic calculation with explicit matrix calculation. see examples of use at end of file. loads commutators.mac (code written by Robert Dodier). */ /* copyright 2010 by Edwin Woollett * I release this work under terms of the GNU General Public License. */ load (commutators)$ remove (comm, antisymmetric)$ declare ([s1, s2, s3, s4], scalar)$ /* note: nonscalarp (sig[1]) ---> true */ declare (eps3,antisymmetric)$ tellsimpafter (eps3[1,2,3], 1)$ matchdeclare ([ii,jj,kk],integerp, bb, scalarp )$ tellsimpafter (comm (sig[ii],bb), 0)$ tellsimpafter (comm (bb, sig[ii]), 0)$ tellsimpafter (comm (sig[ii], sig[jj]), sum (2*%i*eps3 [ii,jj,kk]*sig[kk],kk,1,3))$ matchdeclare (aa, nonscalarp, nn, evenp)$ tellsimpafter ( aa^^nn, 1)$ odd1p(x) := (oddp (x) and x > 1)$ matchdeclare (aa, nonscalarp, nn, odd1p)$ tellsimpafter ( aa^^nn, aa)$ pauli_simp(x) := (comm_simp(x), ev (%%,infeval))$ /* ------------------------------------------*/ /* explicit Pauli matrices */ I2 : ident(2)$ Z2 : zeromatrix (2,2)$ Sig[1] : matrix ([0,1],[1,0])$ Sig[2] : matrix ([0,-%i],[%i,0])$ Sig[3] : matrix ([1,0],[0,-1])$ /*********** commutator of two matrices *************/ mcomm (_M1%,_M2%) := _M1% . _M2% - _M2% . _M1% $ /* convert symbolic to explicit matrix */ stoex (_e%) := (subst (sig = Sig, _e%), ev (%%))$ /* compare symbolic to explicit matrix caculation */ xcomm (A, B) := block ([scomm,ecomm,Margs,Mcomm ], /* symbolic calculation */ scomm : comm_simp (comm (A,B)), display (scomm), /* convert symbolic to matrix */ ecomm : stoex (scomm), display (ecomm), /* ab initio matrix calculation */ Margs : subst (sig = Sig,[A,B]), /* display (Margs), */ Mcomm : apply ('mcomm, Margs), Mcomm : ev (Mcomm), display (Mcomm), /* compare symbolic with matrix calc */ if (equal (ecomm - Mcomm,Z2)) then true else false)$ /* (%i1) load(pauli1); (%o1) "c:/work5/pauli1.mac" (%i2) comm (sig[2],1); (%o2) 0 (%i3) comm (1,sig[2]); (%o3) 0 (%i4) comm_simp(comm(sig[1],sig[3]+sig[2])); (%o4) 2*%i*sig[3]-2*%i*sig[2] (%i5) comm_simp(comm(sig[2]+sig[1],sig[3])); (%o5) 2*%i*sig[1]-2*%i*sig[2] (%i6) comm_simp(comm(sig[1],sig[3]^^2+sig[2])); (%o6) 2*%i*sig[3] (%i7) comm_simp(comm(sig[1],sig[3]^^3+sig[2])); (%o7) 2*%i*sig[3]-2*%i*sig[2] (%i8) comm (sig[2],%i); (%o8) 0 (%i9) comm (%i,sig[2]); (%o9) 0 (%i10) comm (sig[2],s1); (%o10) 0 (%i11) comm (s2,sig[2]); (%o11) 0 (%i12) comm (a2,sig[2]); (%o12) comm(a2,sig[2]) (%i13) comm_simp(comm(sig[1],sig[3] + sig[2]^^2)); (%o13) -2*%i*sig[2] (%i14) comm_simp(comm(sig[1],sig[3] + sig[2]^^3)); (%o14) 2*%i*sig[3]-2*%i*sig[2] (%i15) comm_simp(comm(sig[1],sig[3]^^2 + sig[2]^^3)); (%o15) 2*%i*sig[3] (%i16) comm_simp(comm(sig[1],sig[3]^^3 + sig[2]^^3)); (%o16) 2*%i*sig[3]-2*%i*sig[2] (%i17) comm_simp(comm(sig[1]^^2,sig[3]^^3 + sig[2]^^3)); (%o17) 0 (%i18) comm_simp(comm(sig[1]^^3,sig[3]^^3 + sig[2]^^3)); (%o18) 2*%i*sig[3]-2*%i*sig[2] (%i1) load(pauli1)$ (%i2) xcomm (sig[1]^^3,sig[2]^^5); scomm = 2*%i*sig[3] ecomm = matrix([2*%i,0],[0,-2*%i]) Mcomm = matrix([2*%i,0],[0,-2*%i]) (%o2) true (%i3) xcomm (sig[1]^^3,sig[2]^^3 + sig[3]^^5); scomm = 2*%i*sig[3]-2*%i*sig[2] ecomm = matrix([2*%i,-2],[2,-2*%i]) Mcomm = matrix([2*%i,-2],[2,-2*%i]) (%o3) true */