Problems from Chapter 12
from numpy import sqrt
from qutip import *
N = 10 # pick a size for our state-space
a = destroy(N)
n = a.dag()*a
a*a.dag() - a.dag()*a
n*a.dag() - a.dag()*n
n*a.dag() - a.dag()*n == a.dag()
True
To define $|2\rangle$ use the basis(N,n)
command where N
is the dimension of the vector, and n
is the quantum number.
psi = basis(N,2)
These are simple, just view the matrix representation of the operators
First, define $\hat{X}$ and $\hat{P}$ operators
X=
P=
psi = 1/sqrt(2)*(basis(N,1)+basis(N,2))
psi = 1/sqrt(2)*(basis(N,2)+basis(N,4))