Lab 8 - Simple Harmonic Oscillator states
Problems from Chapter 12
from numpy import sqrt
from qutip import *Define the standard operators¶
N = 10 # pick a size for our state-space
a = destroy(N)
n = a.dag()*aProblem 12.1:¶
a*a.dag() - a.dag()*aProblem 12.2:¶
n*a.dag() - a.dag()*nn*a.dag() - a.dag()*n == a.dag()Problem 12.3 (use n=2 as a test-case):¶
To define use the basis(N,n) command where N is the dimension of the vector, and n is the quantum number.
psi = basis(N,2)psia.dag()*psia.dag()*basis(N,2) == sqrt(3)*basis(N,3)Problem 12.5 and 12.6:¶
These are simple, just view the matrix representation of the operators
aa.dag()Problem 12.7:¶
First, define and operators
X = 1/2 * (a + a.dag())
P = 1/2j * (a - a.dag())psi = 1/sqrt(2)*(basis(N,1)+basis(N,2))
ex = psi.dag()*X*psi # or expect(X, psi)
exq = psi.dag()*X*X*psi # expect(X*X, psi)
ep = psi.dag()*P*psi # expect(P, psi)
epq = psi.dag()*P*P*psi # or expect(P*P, psi)deltaX = sqrt(exq - ex**2)
deltaP = sqrt(epq - ep**2)deltaX * deltaP * 2 # compare to uncertainty relation (ΔxΔp >= 1/2)
# the factor of two is to convert from the unitless version of the operatorAlternatively, we can find the indeterminacy bound for ΔX and ΔP (the unitless operators):
1/2*(psi.dag()*commutator(X,P)*psi)Which is also satisfied by the calculated value (1.41 > 0.25)
Problem 12.8:¶
psi = 1/sqrt(2)*(basis(N,2)+basis(N,4))
ex = expect(X, psi)
exq = expect(X*X, psi)
ep = expect(P, psi)
epq = expect(P*P, psi)deltaX = sqrt(exq - ex**2)
deltaP = sqrt(epq - ep**2)deltaX * deltaP * 2 # to compare to book solution which uses the full x and p operators with units