{ "metadata": { "name": "", "signature": "sha256:1fe7f7e969c4e9eb629d36f4470f81baa10f4992dc3d4bc039fc99bb09056ba4" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "
\n", "

Quantum Teleportation

\n", "
\n", "\n", "WARNING: This is not the same teleportation notebook as the one in the quantum\n", "theory directory.\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "

Contents

\n", "
    \n", "
  1. General Status and Notes
  2. \n", "
  3. Imports, Subroutines, and other Preliminaries
  4. \n", "
  5. The Actual Algorithm
  6. \n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "

^ Status

\n", "\n", "\n", "

Things to do

\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "

^ Preliminaries

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%autosave 0\n", "%matplotlib inline\n", "from sglib import *\n", "set_font_size(3)\n", "from sympy.physics.quantum.qubit import matrix_to_qubit\n", "from sympy.physics.quantum.qubit import qubit_to_matrix, Qubit\n", "def mtq(bits):\n", " return(latex(matrix_to_qubit(bits).simplify()))" ], "language": "python", "metadata": {}, "outputs": [ { "javascript": [ "IPython.notebook.set_autosave_interval(0)" ], "metadata": {}, "output_type": "display_data" }, { "output_type": "stream", "stream": "stdout", "text": [ "Autosave disabled\n" ] } ], "prompt_number": 29 }, { "cell_type": "code", "collapsed": false, "input": [ "# Define the single bit Identity, Not, and Hadamard Operators\n", "I = Matrix([[1,0],[0,1]])\n", "X = Matrix([[0,1],[1,0]])\n", "Z = Matrix([[1,0],[0,-1]])\n", "H = 1/sqrt(2)*Matrix([[1,1],[1,-1]])\n", "\n", "# Define the 2bit CNOT, which I just call \"C2\"\n", "C2 = Matrix([[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]])\n", "\n", "# C3 is a three bit operator that actually does a CNOT\n", "# on the first two bits, and leaves the third bit alone\n", "C3 = TP(C2,I)\n", "\n", "# H3 is a three bit operator that actually does a Hadamard\n", "# on the first bit only, leaving the other two bits alone.\n", "H3 = TP(TP(H,I),I)\n", "\n", "# Take a look at them all\n", "Print('C2 = $%s$'%myltx(C2), font_size=2)\n", "print\n", "Print('C3 = $%s$'%myltx(C3), font_size=2)\n", "print\n", "Print('H3 = $%s$'%myltx(H3), font_size=2)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "C2 = $\\left[\\begin{matrix}1 & 0 & 0 & 0\\\\0 & 1 & 0 & 0\\\\0 & 0 & 0 & 1\\\\0 & 0 & 1 & 0\\end{matrix}\\right]$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\n" ] }, { "html": [ "C3 = $\\left[\\begin{matrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\\\\0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\\\0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\end{matrix}\\right]$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\n" ] }, { "html": [ "H3 = $\\frac{1}{\\sqrt{2}}\\left[\\begin{matrix}1 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\\\0 & 1 & 0 & 0 & 0 & 1 & 0 & 0\\\\0 & 0 & 1 & 0 & 0 & 0 & 1 & 0\\\\0 & 0 & 0 & 1 & 0 & 0 & 0 & 1\\\\1 & 0 & 0 & 0 & -1 & 0 & 0 & 0\\\\0 & 1 & 0 & 0 & 0 & -1 & 0 & 0\\\\0 & 0 & 1 & 0 & 0 & 0 & -1 & 0\\\\0 & 0 & 0 & 1 & 0 & 0 & 0 & -1\\end{matrix}\\right]$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 30 }, { "cell_type": "code", "collapsed": false, "input": [ "# In general, I haven't figured out how you're actually supposed to\n", "# do operations on Sympy \"Qubits\" so I'm keeping my state in Vectors\n", "# (which are actually Sympy one-column matrices). Then I can represent\n", "# the operations as matrices and just do normal matrix multiplication\n", "# to do the operations.\n", "\n", "# So here is a classical zero (q0) and one (q1)\n", "q0 = Matrix([[1],[0]]); q1 = Matrix([[0],[1]])" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 31 }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "

^ The Algorithm

\n", "
    \n", "
  1. Alice has a bit to transmit and Alice and Bob have an\n", " entangled pair.\n", "
    Bit 1 is the state to be transmitted, bits 2 and 3 are Alice and Bob's entangled bits.\n", "
  2. Alice does a CNOT on her two bits
  3. \n", "
  4. Alice does a Hadamard on the bit to be transmitted
  5. \n", "
  6. Alice measures her two bits in the classical basis
  7. \n", "
  8. Bob uses the classical measurement to operate on his bit
  9. \n", "
" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Set up the three intitial qubits. Right now I just start\n", "# off with Alice and Bob's pair already entangled.\n", "q00=TP(q0,q0); q01=TP(q0,q1); q10=TP(q1,q0); q11=TP(q1,q1)\n", "a=sy.Symbol('a'); b=sy.Symbol('b')\n", "bit1=a*q0+b*q1\n", "Print('Step 1')\n", "Print('The bit Alice wants to transmit: $%s$'%mtq(bit1))\n", "bits2and3 = 1/sqrt(2)*(q00 + q11)\n", "Print('The bits Alice and Bob share: $%s$'%mtq(bits2and3))\n", "bits_t0 = TP(bit1,bits2and3)\n", "Print('All three bits: $%s$'%mtq(bits_t0))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "Step 1" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "The bit Alice wants to transmit: $a {\\left|0\\right\\rangle } + b {\\left|1\\right\\rangle }$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "The bits Alice and Bob share: $\\frac{\\sqrt{2}}{2} \\left({\\left|00\\right\\rangle } + {\\left|11\\right\\rangle }\\right)$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "All three bits: $\\frac{\\sqrt{2}}{2} \\left(a {\\left|000\\right\\rangle } + a {\\left|011\\right\\rangle } + b {\\left|100\\right\\rangle } + b {\\left|111\\right\\rangle }\\right)$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 32 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here Alice's applies the CNOT and the the Hadamard" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Alice applies the CNOT and Hadamard\n", "Print('Step 2')\n", "bits_t1 = C3*bits_t0\n", "Print('Alice applies the cnot, resulting in:')\n", "Print('$%s$'%mtq(bits_t1))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "Step 2" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "Alice applies the cnot, resulting in:" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "$\\frac{\\sqrt{2}}{2} \\left(a {\\left|000\\right\\rangle } + a {\\left|011\\right\\rangle } + b {\\left|101\\right\\rangle } + b {\\left|110\\right\\rangle }\\right)$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 33 }, { "cell_type": "code", "collapsed": false, "input": [ "Print('Step 3')\n", "bits_t2 = H3*bits_t1\n", "Print('Alice applies the Hadamard, resulting in:')\n", "Print('$%s$'%mtq(bits_t2))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "Step 3" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "Alice applies the Hadamard, resulting in:" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "$\\frac{1}{2} \\left(a {\\left|000\\right\\rangle } + a {\\left|011\\right\\rangle } + a {\\left|100\\right\\rangle } + a {\\left|111\\right\\rangle } + b {\\left|001\\right\\rangle } + b {\\left|010\\right\\rangle } - b {\\left|101\\right\\rangle } - b {\\left|110\\right\\rangle }\\right)$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 34 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now I'll express the same three bits in an alternate way, to show that they come out right. The expression here does appear to match expression (1.33) through (1.36) at the bottom of\n", "Nielsen and Chuang page 27." ] }, { "cell_type": "code", "collapsed": false, "input": [ "one = TP(Qubit('00'), a*Qubit('0')+b*Qubit('1'))\n", "two = TP(Qubit('01'), a*Qubit('1')+b*Qubit('0'))\n", "three = TP(Qubit('10'), a*Qubit('0')-b*Qubit('1'))\n", "four = TP(Qubit('11'), a*Qubit('1')-b*Qubit('0'))\n", "alt = Rational(1,2)*(one+two+three+four)\n", "Print('(Still on step 3)')\n", "Print('The same bits can be expressed in (partially) factored form as:')\n", "Print('$%s$'%latex(alt))\n", "Print('The above should match (1.33) through (1.36) at the bottom of Nielsen and Chuang page 27.')" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "(Still on step 3)" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "The same bits can be expressed in (partially) factored form as:" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "$\\frac{1}{2} \\left({{\\left|00\\right\\rangle }}\\otimes \\left({a {\\left|0\\right\\rangle } + b {\\left|1\\right\\rangle }}\\right) + {{\\left|01\\right\\rangle }}\\otimes \\left({a {\\left|1\\right\\rangle } + b {\\left|0\\right\\rangle }}\\right) + {{\\left|10\\right\\rangle }}\\otimes \\left({a {\\left|0\\right\\rangle } - b {\\left|1\\right\\rangle }}\\right) + {{\\left|11\\right\\rangle }}\\otimes \\left({a {\\left|1\\right\\rangle } - b {\\left|0\\right\\rangle }}\\right)\\right)$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "The above should match (1.33) through (1.36) at the bottom of Nielsen and Chuang page 27." ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 35 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Step 4: Alice measures her two bits in the classical basis\n", "and sends the results (a classical two bit number) to Bob.\n", "Looking at the \"factored\" form of the bits above, you can see\n", "how the state of Bob's bit depends on Alice's result.\n", "For example, if Alices measures $|00\\rangle$ then Bob's state is\n", "$a|0\\rangle + b|1\\rangle$ and so on." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Step 5:\n", "Bob can now set the state of his bit based on the two classical bits he receives\n", "from Alice by doing one of the following operations:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "if00 = a*q0+b*q1 # (No operation needed)\n", "if01 = X*(a*q1+b*q0)\n", "if10 = Z*(a*q0-b*q1)\n", "if11 = Z*X*(a*q1-b*q0)\n", "if00, if01, if10, if11" ], "language": "python", "metadata": {}, "outputs": [ { "latex": [ "$$\\begin{pmatrix}\\left[\\begin{matrix}a\\\\b\\end{matrix}\\right], & \\left[\\begin{matrix}a\\\\b\\end{matrix}\\right], & \\left[\\begin{matrix}a\\\\b\\end{matrix}\\right], & \\left[\\begin{matrix}a\\\\b\\end{matrix}\\right]\\end{pmatrix}$$" ], "metadata": {}, "output_type": "pyout", "png": "iVBORw0KGgoAAAANSUhEUgAAAPMAAAAyBAMAAAB7bPAdAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAiUSZq1TvELvdZiIy\nds1Wk1T5AAAD/UlEQVRYCcWYz2sTQRTHX1O7m7S1CXgSlObkxUN7Ubxo47VQ2lNBFBrUQv0BBiwi\nIiQg9KgBBU9ijnqxOfQP2IuKWLD+OCoGLHgSVNCCPxq/772ZbVKY7QhlM9Dpm5l832ff/NqZJULq\nKxJdaX+DBbvdLovRnQXtdkFqRts/u1u05ClX74tbHvbBnF99LhXh6tPyVktsBWdWK1K4uTobV3YY\nnn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HLWm\nHbTuqL3k6l1GTtYMROmi5Ssh0RDf19NF61dCUE+ljjb9jW8opbSjfsTBSppC7vlVmXb3ozT1F1P+\nFC9r6h86Vdws91lvwgAAAABJRU5ErkJggg==\n", "prompt_number": 36, "text": [ "\u239b\u23a1a\u23a4, \u23a1a\u23a4, \u23a1a\u23a4, \u23a1a\u23a4\u239e\n", "\u239c\u23a2 \u23a5 \u23a2 \u23a5 \u23a2 \u23a5 \u23a2 \u23a5\u239f\n", "\u239d\u23a3b\u23a6 \u23a3b\u23a6 \u23a3b\u23a6 \u23a3b\u23a6\u23a0" ] } ], "prompt_number": 36 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 36 } ], "metadata": {} } ] }