{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lab 3: Operators\n", "An overview of operator properties" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "from numpy import sqrt,cos,sin,arange,pi\n", "from qutip import *\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "H = Qobj([[1],[0]])\n", "V = Qobj([[0],[1]])\n", "P45 = Qobj([[1/sqrt(2)],[1/sqrt(2)]])\n", "M45 = Qobj([[1/sqrt(2)],[-1/sqrt(2)]])\n", "R = Qobj([[1/sqrt(2)],[-1j/sqrt(2)]])\n", "L = Qobj([[1/sqrt(2)],[1j/sqrt(2)]])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 1: the outer product and the projection operator" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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):" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket\n", "Qobj data =\n", "[[ 1.]\n", " [ 0.]]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "H" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 1. 0.]\n", " [ 0. 0.]]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Ph = H*H.dag()\n", "Ph" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Same with the $\\hat{P}_V$ operator:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0. 0.]\n", " [ 0. 1.]]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Pv = V*V.dag()\n", "Pv" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 2: Verify Eq. 4.38 for the HV basis states. Repeat for the ±45, and LR basis" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 1. 0.]\n", " [ 0. 1.]]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "identity(2)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Ph + Pv == identity(2)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0.5 0.5]\n", " [ 0.5 0.5]]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "P45*P45.dag()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0.5 -0.5]\n", " [-0.5 0.5]]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M45*M45.dag()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 1. 0.]\n", " [ 0. 1.]]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "P45*P45.dag() + M45*M45.dag()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0.5+0.j 0.0-0.5j]\n", " [ 0.0+0.5j 0.5+0.j ]]" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L*L.dag()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 0.5+0.j 0.0+0.5j]\n", " [ 0.0-0.5j 0.5+0.j ]]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "R*R.dag()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[ 1. 0.]\n", " [ 0. 1.]]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L*L.dag() + R*R.dag()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 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." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "def Rp(theta):\n", " return Qobj([[cos(theta),-sin(theta)],[sin(theta),cos(theta)]]).tidyup()" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\n", "Qobj data =\n", "[[ 0. -1.]\n", " [ 1. 0.]]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Rp(pi/2)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "V==Rp(pi/2)*H" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Solution Goes Here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 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" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Solution Goes Here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example: the similarity transform\n", "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def sim_transform(o_basis1, o_basis2, n_basis1, n_basis2):\n", " a = n_basis1.dag()*o_basis1\n", " b = n_basis1.dag()*o_basis2\n", " c = n_basis2.dag()*o_basis1\n", " d = n_basis2.dag()*o_basis2\n", " return Qobj([[a.data[0,0],b.data[0,0]],[c.data[0,0],d.data[0,0]]])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can define a similarity transform that converts from $HV\\rightarrow \\pm 45$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Shv45 = sim_transform(H,V,P45,M45) # as found in Example 4.A.1, Eq. 4.A.10.\n", "Shv45" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Shv45 * H # compare to Eq. 4.A.12" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4) Use the similarity transform to represent $|V\\rangle$ in the ±45 basis" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 5) Represent $\\hat{P}_H$ in the ±45 basis.\n", "Check your answer against Eqns. 4.A.17 and 4.72" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 6) Represent $\\hat{P}_V$ in the ±45 basis." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 1 }