In [1]:
from numpy import sin,cos,pi,sqrt
from qutip import *
In [2]:
pz = Qobj([[1],[0]])
mz = Qobj([[0],[1]])
px = Qobj([[1/sqrt(2)],[1/sqrt(2)]])
mx = Qobj([[1/sqrt(2)],[-1/sqrt(2)]])
py = Qobj([[1/sqrt(2)],[1j/sqrt(2)]])
my = Qobj([[1/sqrt(2)],[-1j/sqrt(2)]])
Sx = 1/2.0*sigmax()
Sy = 1/2.0*sigmay()
Sz = 1/2.0*sigmaz()
In [8]:
py
Out[8]:
In [3]:
((px.dag()*my).norm())**2
Out[3]:
In [4]:
Sx*Sz - Sz*Sx == -1j*Sy # remember, h = 1
Out[4]:
In [5]:
pz.dag()*Sx*pz
Out[5]:
This makes sense given that $S_x$ can be either $\frac{+\hbar}{2}$ or $\frac{-\hbar}{2}$ with equal probability. Similarly, if the state is $|\psi\rangle=|+x\rangle$.
In [6]:
px.dag()*Sx*px
Out[6]:
Again, in units of $\hbar$.
In [ ]: