{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lab 4 - Measurements\n", "First our standard definitions:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "from numpy import sqrt,pi,cos,sin,arange,random\n", "from qutip import *" ] }, { "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": "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": "markdown", "metadata": {}, "source": [ "### Q: Define the $\\hat{\\mathscr{P}}_{HV}$ operator" ] }, { "cell_type": "code", "execution_count": 3, "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": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Phv = H*H.dag() - V*V.dag()\n", "Phv" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q: What is the expectation value $\\langle \\hat{\\mathscr{P}}_{HV}\\rangle$ for state $|\\psi\\rangle = \\frac{1}{\\sqrt{5}}|H\\rangle + \\frac{2}{\\sqrt{5}}|V\\rangle$? Interpret this result given the amplitudes in the state." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "psi = 1/sqrt(5)*H + 2/sqrt(5)*V" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra\\begin{equation*}\\left(\\begin{array}{*{11}c}-0.600\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra\n", "Qobj data =\n", "[[-0.6]]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "psi.dag()*Phv*psi" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q: What is the variance of $\\mathscr{P}_{HV}$?" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra\\begin{equation*}\\left(\\begin{array}{*{11}c}1.000\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[1], [1]], shape = (1, 1), type = bra\n", "Qobj data =\n", "[[1.]]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "psi.dag()*Phv*Phv*psi" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.64" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1- (-0.6)**2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example: Use the random function to generate a mock data set for the state $|\\psi\\rangle$.\n", " random.choice([1,-1],size=10,p=[0.2,0.8])\n", "gives a list of 10 numbers, either 1 or -1 with the associated probability p:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "data = random.choice([1, -1],size=1000000,p=[0.2,0.8])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q: Verify the mean and variance of the mock data set match your QM predictions. How big does the set need to be for you to get ±5% agreement?" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-0.598926" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.mean()" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.6412876465239998" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.var()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q: Answer problems 5.11, 5.12, 5.13, 5.14 from the textbook. These are an opportunity to practice with a new operator $\\hat{\\mathscr{P}}_{C}$" ] }, { "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 }