Examples of calculations with spin operators
Part of package SNEG,http://auger.ijs.si/ljubljana/sneg
Rok Zitko,rok.zitko@ijs.si, Feb 2007

<< sneg`sneg`;

Off[General::spell1];
snegfermionoperators[c]
snegrealconstants[t, U, δ]

(* Two orbitals with e - e repulsion,  
      coupled by electron hopping .  This is,  in fact,  
      a two site Hubbard model. *) 
H1 = Sum[δ (number[c[i]] - 1) + 
          U/2 pow[number[c[i]] - 1, 2], {i, 2}]

    H12 = t hop[c[1], c[2]]

    H = H1 + H12;

?? spin*

basisops = {c[1], c[2]}
MatrixForm[{sx, sy, sz} = Total @ Map[spinxyz, basisops]]

komutator[sx, sy] == I sz // 
      FullSimplify

    komutator[sy, sz] == I sx // FullSimplify

    komutator[sz, sx] == I sy // FullSimplify

komutator[H, 
          sx] == 0 // FullSimplify

    komutator[H, sy] == 0 // FullSimplify

    komutator[H, sz] == 0 // FullSimplify

sp = sx + I sy // Expand

    sm = sx - I sy // Expand

    komutator[sz, sp] == sp // FullSimplify

    komutator[sz, sm] == -sm // FullSimplify

    komutator[sp, sm] == 2  sz // FullSimplify

S2 = 
      Total @ Map[pow[#, 2] &, {sx, sy, sz}] // Expand

    komutator[H, S2] == 0  //  FullSimplify

pow[S2, 2] // Expand
FullSimplify[%]