# problem with contracting the indices in a ITensor

Hi!

I have two states created with the same Site properties, e.g. \psi1 and \psi2. I want to calculate <psi_1|V|psi_2> where V is a local operator.

1. question: the easiest way seems to be using the overlap function. However if I use ITensor objects, would my code be much faster?

2. question: I tried to implement an ITensor way:

   psi1.position(j);
ket = psi1.A(j);
Print(ket);

psi2.position(j);    // THIS DOESN'T SET THE LINK NUMBERS SAME WITH PSI_1

ket2=psi2.A(j);
bra=dag(prime(ket2,Site));

Print(bra);
Wmat=(bra*W*ket).real();


I'm setting the psi_1 to the site where my local operator is defined and my local operator:

      ITensor W = sites.op("Sz",j);


I was doing the same thing to the other state, \psi_2, but I realized that it does not work, their link numbers do not match, hence my code gets stuck in the execution. Here one question I have: why is this the case? I'm giving both the states same site to initialize their gauges, but they do not end up having the same link numbers.

So then I tried to replace the link numbers with the delta function. I first create the bra vector and then pass the rightLink index of psi1 to rightLink index of psi2. Same for left indices. However the expectation values that I'm generating this way and from the overlap function do not match.

Am I changing the indices in a wrong way? I printed out the ITensor indices as well. They seemed to have the right numbers, in fact my code gets executed. However the overlap function result physically makes more sense.

Any help appreciated! Thanks!

Best,
Ceren

+1 vote
selected by

Also note that you could use the overlap function for this case, but it accepts input like overlap(MPS,MPO,MPS), so requires that you write your local operator as an MPO. This would also be a reasonable thing to do, and nearly as efficient as writing it by hand (depending on how you represent the operator as an MPO).