Lab 3: Operators

An overview of operator properties


In [1]:
import matplotlib.pyplot as plt
from numpy import sqrt,cos,sin,arange,pi
from qutip import *
%matplotlib inline

In [2]:
H = Qobj([[1],[0]])
V = Qobj([[0],[1]])
P45 = Qobj([[1/sqrt(2)],[1/sqrt(2)]])
M45 = Qobj([[1/sqrt(2)],[-1/sqrt(2)]])
R = Qobj([[1/sqrt(2)],[-1j/sqrt(2)]])
L = Qobj([[1/sqrt(2)],[1j/sqrt(2)]])

Example 1: the outer product and the projection operator

We already have the $|H\rangle$ state represented as a vector in the HV basis, so the $\hat{P}_H$ operator is the outer product $|H\rangle\langle H|$ (a ket then a bra):


In [3]:
H


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

In [4]:
Ph = H*H.dag()
Ph


Out[4]:
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 & 0.0\\\end{array}\right)\end{equation*}

Same with the $\hat{P}_V$ operator:


In [5]:
Pv = V*V.dag()
Pv


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

Example 2: Verify Eq. 4.38 for the HV basis states. Repeat for the ±45, and LR basis


In [8]:
identity(2)


Out[8]:
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 [9]:
Ph + Pv == identity(2)


Out[9]:
True

In [10]:
P45*P45.dag()


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

In [11]:
M45*M45.dag()


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

In [7]:
P45*P45.dag() + M45*M45.dag()


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

In [13]:
L*L.dag()


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

In [14]:
R*R.dag()


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

In [15]:
L*L.dag() + R*R.dag()


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

Example 3: Represent the $\hat{R}_p(\theta)$ operator in the HV basis and verify your representation by operating on $|H\rangle$ and $|V\rangle$ states. Use the following template function definition.


In [16]:
def Rp(theta):
    return Qobj([[cos(theta),-sin(theta)],[sin(theta),cos(theta)]]).tidyup()

In [17]:
Rp(pi/2)


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

In [20]:
V==Rp(pi/2)*H


Out[20]:
True

In [23]:
# Solution Goes Here
H==Rp(-pi/2)*V


Out[23]:
True

1) Using the $\hat{R}_p(\theta)$ operator, verify the operator properties described in Sections 4.1 and 4.2. Specifically, verify Eqns. 4.6, 4.7, 4.16, 4.18, 4.22, and 4.27


In [24]:
# Solution Goes Here
# 4.6
(Rp(pi/2) + Rp(pi/3)) * P45 == Rp(pi/2)*P45 + Rp(pi/3)*P45


Out[24]:
True

In [25]:
#4.7
Rp(pi/3)*(P45 + H) == Rp(pi/3)*P45 + Rp(pi/3)*H


Out[25]:
True

In [29]:
#4.16
H.dag()*Rp(pi/4).dag() == P45.dag()


Out[29]:
True

In [34]:
#4.18
dag(Rp(pi/3)*Rp(pi/4)) == (Rp(pi/3)*Rp(pi/4)).dag() == Rp(pi/4).dag()*Rp(pi/3).dag()


Out[34]:
True

In [35]:
#4.22
Rp(pi/3).dag() * Rp(pi/3) == identity(2)


Out[35]:
True

In [36]:
#4.27
Rp(pi/3).dag() == Rp(-pi/3)


Out[36]:
True

Example: the similarity transform

The following defines a function that creates a similarity transform matrix. It takes the two old basis vectors and the two new basis vectors as arguments. To apply the transform, simply multiply the matrix onto the state vector or ooperator matrix. Following the examples below, explore this transform.


In [37]:
def sim_transform(o_basis1, o_basis2, n_basis1, n_basis2):
    a = n_basis1.dag()*o_basis1
    b = n_basis1.dag()*o_basis2
    c = n_basis2.dag()*o_basis1
    d = n_basis2.dag()*o_basis2
    return Qobj([[a.data[0,0],b.data[0,0]],[c.data[0,0],d.data[0,0]]])

We can define a similarity transform that converts from $HV\rightarrow \pm 45$


In [38]:
Shv45 = sim_transform(H,V,P45,M45)  # as found in Example 4.A.1, Eq. 4.A.10.
Shv45


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

In [39]:
Shv45 * H  # compare to Eq. 4.A.12


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

4) Use the similarity transform to represent $|V\rangle$ in the ±45 basis


In [43]:
Shv45 * V


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

5) Represent $\hat{P}_H$ in the ±45 basis.

Check your answer against Eqns. 4.A.17 and 4.72


In [41]:
Shv45 * Ph * Shv45.dag()


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

6) Represent $\hat{P}_V$ in the ±45 basis.


In [42]:
Shv45 * Pv * Shv45.dag()


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

In [ ]: