In [1]:
from qutip import *
from numpy import sqrt

In [2]:
H = basis(2,0)
V = basis(2,1)
p45 = 1/sqrt(2)*(H + V)
m45 = 1/sqrt(2)*(H - V)
R = 1/sqrt(2)*(H - 1j*V)
L = 1/sqrt(2)*(H + 1j*V)

In [3]:
hh = tensor(H,H)
hv = tensor(H,V)
vh = tensor(V,H)
vv = tensor(V,V)

In [7]:
vv


Out[7]:
Quantum object: dims = [[2, 2], [1, 1]], shape = (4, 1), type = ket\begin{equation*}\left(\begin{array}{*{11}c}0.0\\0.0\\0.0\\1.0\\\end{array}\right)\end{equation*}

In [8]:
# Show these are all orthogonal:
hh.dag()*hv


Out[8]:
Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra\begin{equation*}\left(\begin{array}{*{11}c}0.0\\\end{array}\right)\end{equation*}

In [7]:
vh.dag()*hv


Out[7]:
Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra\begin{equation*}\left(\begin{array}{*{11}c}0.0\\\end{array}\right)\end{equation*}

In [9]:
qeye(2)


Out[9]:
Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\begin{equation*}\left(\begin{array}{*{11}c}1.0 & 0.0\\0.0 & 1.0\\\end{array}\right)\end{equation*}

In [20]:
# Example 8.1
Phv = H*H.dag() - V*V.dag() # polarization measurement
ps_hv = tensor(Phv,qeye(2))
pi_hv = tensor(qeye(2),Phv)
psi_hv = tensor(Phv,Phv)

print(ps_hv*tensor(V,p45) == -tensor(V,p45))

print(pi_hv*tensor(V,p45) == tensor(V,m45))

print(psi_hv*tensor(V,p45) == -tensor(V,m45))


True
True
True

In [23]:
# Example 8.2
Pvh = tensor(V,H)*tensor(V,H).dag()
expect(Pvh,tensor(R,p45))


Out[23]:
0.2499999999999999

In [26]:
# Example 8.3
Phi = tensor(qeye(2),H)*tensor(qeye(2),H).dag()
expect(Phi,tensor(R,p45))


Out[26]:
0.4999999999999998

In [27]:
# Example 8.4
state = tensor(R,p45)
expect(Pvh,state) / expect(Phi,state)


Out[27]:
0.5

Entangled states


In [37]:
phip = 1/sqrt(2)*(tensor(H,H) + tensor(V,V))
Phs = tensor(H,qeye(2))*tensor(H,qeye(2)).dag() 
Phi = tensor(qeye(2),H)*tensor(qeye(2),H).dag()
Phshi = tensor(H,H)*tensor(H,H).dag()

expect(Phshi,phip)/ expect(Phi,phip)


Out[37]:
1.0

In [43]:
P_45s45i = tensor(p45,p45)*tensor(p45,p45).dag()
P_45i = tensor(qeye(2),p45)*tensor(qeye(2),p45).dag()

In [44]:
expect(P_45s45i,phip)/expect(P_45i,phip)


Out[44]:
0.9999999999999997

In [ ]: