Erroneous result with position squared expectation value with Fock states

13 views
Skip to first unread message

Soumyabrata Paul

unread,
Nov 8, 2022, 3:48:18 PM11/8/22
to QuTiP: Quantum Toolbox in Python
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?

Soumyabrata Paul

unread,
Nov 8, 2022, 5:36:27 PM11/8/22
to QuTiP: Quantum Toolbox in Python
Dear All,

The error is in the construction of <x^{2}>. It was my mistake. Please ignore the earlier email.
Reply all
Reply to author
Forward
0 new messages