# Computing the spin-spin correlation function between site b and b+2.

+1 vote

Hi,
I am modifying the code provided by the following link in order to calculate the spin-spin correlation function between site b and b+2.
http://itensor.org/docs.cgi?page=formulas/measure_mps
However, my naive modification (attached below) with replacing b+1 by b+2 does not work.
Could you help me to solve this problem? Thanks!

    psi.position(b);

ITensor bondket = psi.A(b)*psi.A(b+2);
ITensor bondbra = dag(prime(bondket,Site));

ITensor zzop = sites.op("Sz",b)*sites.op("Sz",b+2);
ITensor pmop = 0.5*sites.op("S+",b)*sites.op("S-",b+2);
ITensor mpop = 0.5*sites.op("S-",b)*sites.op("S+",b+2);


+1 vote
edited

Hello,
I believe the above method works only for a correlation between two adjacent sites. I would use the following method to calculate the correlation between any two sites:

http://itensor.org/docs.cgi?page=tutorials/correlations

Regards,
Niraj

commented by (70.1k points)
Good answer, Niraj. Also here is a "code formula" about two-point correlation functions as well
http://itensor.org/docs.cgi?page=formulas/correlator_mps
commented by (160 points)
Dear Niraj and Miles,
I have solve the problem, thanks a lot!