matrixrepresentationvc

◼ matrixrepresentationvc[op, basis] computes the matrix representation of the operator op in the basis of occupation number vectors basis.
◼ matrixrepresentationvcsparse[op, basis] computes the (sparse) matrix representation of the operator op in the basis of occupation number vectors basis.
◼ matrixrepresentationvcfast[op, basis] computes the matrix representation of the operator op in the basis of occupation number vectors basis using an improved approach.
◼ matrixrepresentationop[op, basis] computes the matrix representation of the operator op in the basis of creation operators basis.
◼ matrixrepresentationvc[op, basisL, basisR] returns the matrix representation of the operator op in the case of different basis sets of occupation number vectors for left-multiplication (bra) and right-multiplication (ket).
◼ matrixrepresentationop[op, basisL, basisR] returns the matrix representation of the operator op in the case of different basis sets of creation operators for left-multiplication (bra) and right-multiplication (ket).
◼ makematricesbzvc[op, bzvc] and makematricesbzop[op, bzop] produce a table of operator matrices for all invariant subspaces in basis bzvc or bzop.

◼ See also: braket, ap, vc, vacuum, makebasis.

Further examples

Load sneg and declare c to be a fermionic operator

<< sneg`sneg`;
snegfermionoperators[c];
snegrealconstants[U, t, ϵ];

Two-site Hubbard Hamiltonian

n = 2;
H = hamiltonian[Hubbard, c[], n, U, t, ϵ]

Construct a basis with well defined (Q, (Subscript[S, z])) quantum numbers

ops = Table[c[i], {i, n}];
makebasis[ops];
bz = qszbasisvc[ops];
MatrixForm[bz]

Construct the Hamiltonian matrices in all subspaces.

matvc = 
        Map[{First[#], 
              matrixrepresentationvc[
                H, #[[2]] ]} &, 
          bz];
MatrixForm@
      Map[{First[#], 
            MatrixForm[#[[2]]]} &, 
        matvc]

Switch to creation number representation of the basis states

bzop = bzvc2bzop[bz];
MatrixForm[bzop]

Check that the same Hamiltonian matrices are also obtained  in the creation operator representation

matop = 
        Map[{First[#], 
              matrixrepresentationop[
                H, #[[2]] ]} &, 
          bzop];
MatrixForm@
      Map[{First[#], 
            MatrixForm[#[[2]]]} &, 
        matop]
matop == matvc

More complex example: five site Hubbard model

n = 5;
H = 
        hamiltonian[Hubbard, c[], n, U, 
          t, ϵ];
H = 
        H /. {ϵ -> 0, U -> 1, 
            t -> -0.2};
ops = Table[c[i], {i, n}];
makebasis[ops];
bz = qszbasisvc[ops];
bz1 = Select[bz, #[[1]] == {0, 1/2} &][[1, 
            2]];
Print["Matrix dimension: ", 
        Length[bz1]];
Timing[mat = 
          matrixrepresentationvc[H, bz1];]
Timing[matfast = 
          matrixrepresentationvcfast[H, bz1];]
Timing[matsparse = 
          matrixrepresentationvcsparse[H, bz1];]
mat == matfast
mat == matsparse

Plot the structure of the Hamiltonian matrix and compute the lowest five eigenvalues using the Arnoldi (Lanczos) method

ArrayPlot[mat];
Timing[
      Eigenvalues[mat, 5, 
        Method -> {"Arnoldi", Shift -> -0.5}]]