## Learn to Use ITensor

main / formulas / correlator_mps

# Measure a correlator from an MPS wavefunction

See this in a diagrammatic form here.

### Sample code:

//Given an MPS or IQMPS called "psi",
//constructed from a SiteSet "sites"

//Replace "Op1" and "Op2" with the actual names
//of the operators you want to measure
auto op_i = sites.op("Op1",i);
auto op_j = sites.op("Op2",j);

//below we will assume j > i

//'gauge' the MPS to site i
//any 'position' between i and j, inclusive, would work here
psi.position(i);

//psi.Anc(1) *= psi.A(0); //Uncomment if doing iDMRG calculation

auto C = psi.A(i)*op_i*dag(prime(psi.A(i),Site,ir));
for(int k = i+1; k < j; ++k)
{
C *= psi.A(k);
}
C *= psi.A(j);
C *= op_j;

• auto is a C++11 keyword that tells the compiler to automatically deduce the correct type from the expression on the right-hand side
• C is the tensor holding our partial result for the correlator