Dear All,
I am trying the following code in qutip 4.7.0 --
from qutip import *
import numpy as np
rho = basis(2, 1) * basis(2, 1).dag()
x = (create(2) + destroy(2)) / np.sqrt(2)
print(expect(x, rho))
print(expect(x * x, rho))
The first print gives the expected result <x> = 0, but the second print <x^2> = 0.5, which is *wring*. It should be 1.5.
Essentially I am calculating <x> and <x^2>, with x = (a^{\dagger} + a) / \sqrt{2}, with \rho=|1\rangle \langle1|.
Is this a known bug? Or am I making a mistake somewhere?