Processing math: 100%

Operator Matrix Elements Involving Two MPS

Say we have two MPS wavefunctions, |ψ and |ϕ , and that we wish to compute ϕ|OiOj|ψ for some local operators Oi and Oj . We can do this as follows:

int N = 20;
auto sites = SpinHalf(N);
auto state = InitState(sites,"Up");
auto psi = randomMPS(state);
auto phi = randomMPS(state);

int i = 4;
int j = 10;
auto op_i = op(sites,"Sz",i);
auto op_j = op(sites,"Sz",j);

auto phidag = dag(phi);

auto M = psi(1)*phidag(1);
for(auto n : range1(2,N))
    {
    M *= psi(n);
    if(n == i)
        {
        M *= op_i*prime(phidag(i),"Site");
        }
    else if(n == j)
        {
        M *= op_j*prime(phidag(j),"Site");
        }
    else
        {
        M *= phidag(n);
        }
    }
auto result = elt(M);

Note: if i or j are equal to 1, one must modify the line in the code above where M is first defined. Note: if a complex valued result is expected, change the last line to use eltC(M);.


Back to Formulas
Back to Main