Dagger operator bug

Hello - I believe I have found a bug in the dag() function. Trying to take the dagger of the S+ operator, I get S+ back, when it should be S-. Here is a minimum working example:

using ITensors
L_tot=10;
s = siteinds("S=1/2", L_tot)
C1 = op("S+", s[1])
dag(C1)==C1

Where the final line returns true (and should return false). I have verified that indeed, dag(C1) acts on a MPS as S+. This bug persists when replacing S+ by S-, and also when replacing S+ by Sx+im*Sy. In addition, the following returns false, when it should return true:

using ITensors
L_tot=10;
s = siteinds("S=1/2", L_tot)
C1 = op("Sy", s[1])
dag(C1)==C1

Thanks for the minimum examples to show what you were seeing. I don’t believe this is a bug, however, but the intended behavior. What I believe is going on here is that the name dag for this function in ITensor arguably is not the best name because it does not always perfectly correspond to the Hermitian conjugate of an operator.

Based on the documentation of the dag function here, what this function does is:

  1. complex conjugate the elements of an ITensor
  2. call dag on the indices of the ITensor, which if they carry arrows will reverse these arrows

For the tensors you considered above, your site indices (indices in the s array) do not carry quantum number information so do not have arrows so dag has no effect on them, and all it does is complex conjugate the tensor elements.

To actually compute the mathematical Hermitian conjugate of these operators, you’d need to also transpose the indices which would mean to exchange their prime levels (the index with 0 prime level switching to a 1 prime level and vice versa). A code to do this could be:

T_dag = dag(swapprime(T,0,1))

for some ITensor operator T.

3 Likes

Aha, thank you for the clarification. I missed the true implication of the second point in the definition, sorry to bother!

1 Like

Relatedly, you may wonder why we keep this name dag if it doesn’t always compute the Hermitian conjugate of an operator. While arguably we could change the name, there are many situations where calling dag on an ITensor does compute the Hermitian conjugate. The broader point to understand is that transposes work very differently in tensor diagrams, and hence in ITensor, than they do in standard math notation.

In tensor diagrams, the idea of a matrix transpose is superseded or replaced by the idea of just connecting the index lines in a different way (for example M v versus M^T v just means connecting the index of v to the column versus row index of M). So because there isn’t really a notion of transposing, dag just does the other aspects of taking a Hermitian conjugate which is conjugating elements and reversing index arrows. We leave it up to the user to determine how to connect the index lines properly.

1 Like

No problem, it was a good question.