{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 4 in-class problems\n", "## Using what you learned in Lab, answer questions 4.7, 4.8, 4.10, 4.11, 4.12, and 4.13" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from numpy import sqrt, pi, cos, sin\n", "from qutip import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Remember, these states are represented in the HV basis:" ] }, { "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": [ "The sim_transform function creates the matrix $\\bar{\\mathbf{S}}$ that can convert from one basis to another. As an example, it will create the tranform matrix to convert from HV to ±45 if you run:\n", "\n", " Shv45 = sim_transform(H,V,P45,M45) # creates the matrix Shv45\n", " \n", "Then you can convert a ket from HV to ±45 by applying the Shv45 matrix:\n", "\n", " Shv45*H # will convert H from the HV basis to the ±45 basis\n", " \n", "To convert operators, you have to sandwich the operator between $\\bar{\\mathbf{S}}$ and $\\bar{\\mathbf{S}}^\\dagger$:\n", "\n", " Shv45*Ph*Shv45.dag() # converts Ph from HV basis to the ±45 basis." ] }, { "cell_type": "code", "execution_count": 3, "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": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "ShvLR = sim_transform(H,V,L,R)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket\n", "Qobj data =\n", "[[ 0.70710678]\n", " [ 0.70710678]]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ShvLR*H" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket\\begin{equation*}\\left(\\begin{array}{*{11}c}-0.707j\\\\0.707j\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket\n", "Qobj data =\n", "[[ 0.-0.70710678j]\n", " [ 0.+0.70710678j]]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ShvLR*V" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4.11: Express $\\hat{R}_p(\\theta)$ in ±45 basis" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def Rp(theta):\n", " return Qobj([[cos(theta),-sin(theta)],[sin(theta),cos(theta)]]).tidyup()" ] }, { "cell_type": "code", "execution_count": 12, "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.267 & -0.964\\\\0.964 & 0.267\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\n", "Qobj data =\n", "[[ 0.26749883 -0.96355819]\n", " [ 0.96355819 0.26749883]]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Rp(1.3)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "Shv45 = sim_transform(H,V,P45,M45)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4.12: " ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "Rp45 = Shv45*Rp(pi/4)*Shv45.dag()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Rp45*Shv45*P45 == Shv45*V # convert P45 to the ±45 basis" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "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*}" ], "text/plain": [ "Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket\n", "Qobj data =\n", "[[ 0.70710678]\n", " [-0.70710678]]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Rp45* Qobj([[1],[0]])" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": true }, "outputs": [], "source": [ "ShvLR = sim_transform(H,V,L,R)" ] }, { "cell_type": "code", "execution_count": 10, "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.707-0.707j) & 0.0\\\\0.0 & (0.707+0.707j)\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\n", "Qobj data =\n", "[[ 0.70710678-0.70710678j 0.00000000+0.j ]\n", " [ 0.00000000+0.j 0.70710678+0.70710678j]]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ShvLR*Rp(pi/4)*ShvLR.dag()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "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.6.3" } }, "nbformat": 4, "nbformat_minor": 1 }