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

The Density Matrix

\n", "
\n", "

\n", "For now, I'm going work directly from Schlosshauer chapter two, adding in\n", "examples from the Cugini paper as well as my own examples." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "


\n", "

Status

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

TTD

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

Contents

\n", "
    \n", "
  1. References\n", "
  2. Imports, etc\n", "
  3. Density Matrices and the Trace Operation\n", "
  4. Calculating the probability of a state\n", "
  5. Purity\n", "
  6. Entropy\n", "
  7. Some basic examples\n", "
  8. The Partial Trace and Reduced Density Matrix\n", "
  9. Purity and Entropy as measures of entanglement\n", "
  10. Purity vs Entropy (Plot)\n", "
  11. Documentation on sglib code\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "
\n", "
\n", "

^ References

\n", "\n", "
    \n", "
  1. \n", "Schlosshauer\n", "
  2. Cugini\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "
\n", "
\n", "

^ Preliminaries

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%autosave 0\n", "%matplotlib inline\n", "from __future__ import division\n", "from sglib import *\n", "from sympy import sqrt, E, Rational, latex, Symbol\n", "L = latex # Shorthand\n", "\n", "# Zero and One states (they're also + and - z)\n", "s0 = col(1,0); s1 = col(0,1)\n", "pz = s0; mz = s1\n", "# Create a formatter for stuff like |00>\n", "fmt = sg_format_state(['0','1'], '').format\n", "zfmt = sg_format_state(['+z','-z'], '').format\n", "xfmt = sg_format_state(['+x','-x'], '').format\n", "# Create two-bit states and basis\n", "s00=TP(s0,s0); s01=TP(s0,s1); s10=TP(s1,s0); s11=TP(s1,s1)\n", "b2bit = [s00, s01, s10, s11]\n", "# Some misc definitions\n", "half = Rational(1,2) # Define 1/2\n", "alpha = Symbol('alpha') # Define some symbols\n", "beta = Symbol('beta')\n", "# The Bell states\n", "bell_1 = 1/sqrt(2)*s00 + 1/sqrt(2)*s11 # phi+\n", "bell_2 = 1/sqrt(2)*s00 - 1/sqrt(2)*s11 # phi-\n", "bell_3 = 1/sqrt(2)*s01 + 1/sqrt(2)*s10 # psi+ (Triplet)\n", "bell_4 = 1/sqrt(2)*s01 - 1/sqrt(2)*s10 # psi- (Singlet)\n", "bell = [bell_1, bell_2, bell_3, bell_4]" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "
\n", "
\n", "

^ Density Matrices and the Trace Operation

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

Pure-State Density Matrices

\n", "

\n", "The density operator of a pure state $|\\psi\\rangle$ is:\n", "

\n", "$$\n", "\\rho = |\\psi\\rangle\\langle\\psi| \n", "$$\n", "

\n", "The off-diagonal terms are the \"interference\" terms, for the basis\n", "in which the expression is written." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Mixed-State Density Matrices

\n", "

\n", "A mixed state can be viewed as a state chosen from a classical ensemble\n", "of states, consisting of states $\\{\\psi_i\\}$ for which you know the\n", "relative frequency of each state in the ensemble.\n", "

\n", "The density matrix for a mixed state is simply the weighted sum of the\n", "density matrices for the individual states:\n", "

\n", "$$\n", "(2.20) \\;\\; \\rho = \\sum_i p_i|\\psi_i\\rangle\\langle\\psi_i| \n", "$$\n", "where $p_i$ is the (classical) probability of drawing $\\psi_i$ from\n", "the ensemble.\n", "

\n", "For example, say you have a 50% chance of getting $|0\\rangle$ and a\n", "50% chance of getting $|1\\rangle$. Then we have:\n", "$$\n", "\\rho = \\frac{1}{2}|0\\rangle\\langle 0| + \\frac{1}{2}|1\\rangle\\langle 1|\n", "$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

The Trace Operation

\n", "

\n", "The trace operation is:\n", "

\n", "$$\n", "\\mathrm{Tr}(\\rho) = \\sum_i\\langle\\phi_i|\\rho|\\phi_i\\rangle\n", "$$\n", "

\n", "where $\\{\\phi_i\\}$ are a complete set of orthonormal\n", "basis vectors. The expression\n", "$\\langle\\phi_i|A|\\phi_i\\rangle$ picks out the $i$th row and column of\n", "$A$. So we're actually just adding up the main diagonal of the matrix." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Demonstration of the trace operation

\n", "

\n", "Notice that trace work in any basis. As long as you use a set\n", "of orthonormal basis vectors, you'll trace out the same number.\n", "

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from sympy import var\n", "a_11, a_12, a_21, a_22 = var('a_11, a_12, a_21, a_22')\n", "A = mat(a_11, a_12, a_21, a_22)\n", "MOP = matrix_as_outer_product(A) # Just to get access to the \"demo\" Tr()\n", "from sglib import pZ, mZ, pX, mX, pY, mY\n", "trace = MOP.Tr(A, [pZ, mZ], V=True)\n", "trace = MOP.Tr(A, [pX, mX], V=True)\n", "trace = MOP.Tr(A, [pY, mY], V=True)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

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

^ Calculating the probability of a state

\n", "

\n", "Say you have a state $|\\psi\\rangle$, and it's density matrix $\\rho$.\n", "You want to know the probability that a measurement on $|\\psi\\rangle$\n", "will yield some arbitrary state $|\\phi\\rangle$. This can be calculated\n", "in the following way:\n", "$$\n", "\\mathrm{Prob}(\\phi)=\\langle \\phi|\\rho|\\phi\\rangle\n", " =\\mathrm{Tr}(|\\phi\\rangle\\langle\\phi|\\rho)\n", "$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

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

^ Purity

\n", "

\n", "Purity is a measure of how mixed the density matrix is.\n", "

\n", "$\\;\\;\\;\\;\\mathrm{purity}(\\rho) = \\mathrm{Tr}(\\rho^2)$\n", "

\n", "The maximum purity is $1$ (which will be achieved for any pure state).\n", "The minimum purity, will be one divided by the dimension of the matrix.\n", "$1/2$ for a one-bit state, $1/4$ for a two-bit state, and so on." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

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

^ Entropy

\n", "

\n", "The Entropy $S$ of of a system can be calculated by the following\n", "formula, where the $\\lambda$ are the eigenvalues of\n", "the system's density (or reduced density) matrix:\n", "

\n", "$\\;\\;\\;\\;S = - \\displaystyle\\sum_{n} \\lambda_n \\mathrm{log}(\\lambda_n) $\n", "

\n", "The entropy of any pure state will be 0. The maximum entropy\n", "(assuming you are taking the logs in base 2) will be \n", "the number of bits in the state." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

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

^ Some basic examples

\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: A one bit pure state" ] }, { "cell_type": "code", "collapsed": false, "input": [ "psi = 1/sqrt(2)*s0 + 1/sqrt(2)*s1\n", "rho = OP(psi,psi)\n", "examine_dm(rho)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: A one bit even mixture" ] }, { "cell_type": "code", "collapsed": false, "input": [ "half = Rational(1,2)\n", "rho = half*OP(s0,s0) + half*OP(s1,s1)\n", "examine_dm(rho)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: One bit, somewhat mixed" ] }, { "cell_type": "code", "collapsed": false, "input": [ "rho = .15*OP(s0,s0) + .85*OP(s1,s1)\n", "examine_dm(rho)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: Two bit pure state (Bell 1)" ] }, { "cell_type": "code", "collapsed": false, "input": [ "rho = OP(bell_1, bell_1)\n", "examine_dm(rho)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: Even mixture of all four Bell states.\n", "
\n", "This achieves the minimum purity and maximum entropy for\n", "a two bit state." ] }, { "cell_type": "code", "collapsed": false, "input": [ "rho = .25*OP(bell_1, bell_1) + .25*OP(bell_2, bell_2)\\\n", " + .25*OP(bell_3, bell_3) + .25*OP(bell_4, bell_4)\n", "examine_dm(rho)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: Partially mixed two bit state" ] }, { "cell_type": "code", "collapsed": false, "input": [ "rho = .25*OP(s00,s00)+.15*OP(s01,s01)+.05*OP(s10,s10)+.55*OP(s11,s11)\n", "print 'trace is %s'%rho.trace() # Make sure it adds up!\n", "examine_dm(rho)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: A two bit state with an even mixture of two states\n", "
has the same purity and entropy as an evenly mixed one bit state." ] }, { "cell_type": "code", "collapsed": false, "input": [ "rho = .50*OP(s00,s00)+.50*OP(s10,s10)\n", "print 'trace is %s'%rho.trace() # Make sure it adds up!\n", "examine_dm(rho)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: Calculating the probability of an arbitrary state\n", "
\n", "$\n", "\\mathrm{Prob}(\\phi)=\\langle \\phi|\\rho|\\phi\\rangle\n", " =\\mathrm{Tr}(|\\phi\\rangle\\langle\\phi|\\rho)\n", "$" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# The state we are given\n", "psi = 1/sqrt(2)*pz + 1/sqrt(2)*mz\n", "rho = OP(psi,psi)\n", "phi = col(1/sqrt(2), 1/sqrt(2)) # This is +x\n", "phi = col(1,0) # This is +z\n", "Print(r'Given: $%s=%s$' %( zfmt(psi), L(psi) ))\n", "Print(r'Find the probability of measuring $%s=%s$' %(zfmt(phi),L(phi) ))\n", "Print(r'$\\langle\\phi|\\rho|\\phi\\rangle=%s%s%s=%s$'\n", " %(L(phi.adjoint()),L(rho),L(phi), (phi.adjoint()*rho*phi)[0] ))\n", "foo = phi*phi.adjoint()*rho\n", "string = r'$\\mathrm{Tr}(|\\phi\\rangle\\langle\\phi|\\rho)'\n", "string += r'=\\mathrm{Tr}\\left(%s%s%s\\right)=\\mathrm{Tr}\\left(%s\\right)=%s$'\n", "Print(string\n", " %(L(phi),L(phi.adjoint()),L(rho),L(foo),foo.trace()),font_size=3)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

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

^ The Partial Trace and Reduced Density Matrix

\n", "

\n", "(1) $\\rho_{AB} = \\rho_A \\otimes \\rho_B$. \n", "

\n", "$\\;\\;\\;\\;$ In other words:\n", "$|a_1 b_1\\rangle \\langle a_2 b_2| \n", "= |a_1\\rangle \\langle a_2| \\otimes |b_1\\rangle \\langle b_2|$\n", "

\n", "(2) The trace of an outer product equals the (reversed) inner product\n", "

\n", "$\\;\\;\\;\\;\\;\\mathrm{Tr}(|x\\rangle\\langle y|) = \\langle y|x\\rangle$\n", "

\n", "\n", "(3) The Partial Trace operation, where we \"trace out\" bit B is:\n", "

\n", "$\\;\\;\\;\\;\\;\\mathrm{Tr_B}(|a_1 b_1\\rangle\\langle a_2 b_2|)\n", "\\\\\\;\\;\\;\\;\\;\\;\\;\n", " = \\mathrm{Tr_B}(|a_1\\rangle\\langle a_2|\\otimes|b_1\\rangle\\langle b_2|)\n", "\\\\\\;\\;\\;\\;\\;\\;\\;\n", "= |a_1\\rangle\\langle a_2|\\mathrm{Tr_B}(|b_1\\rangle\\langle b_2|)\n", "\\\\\\;\\;\\;\\;\\;\\;\\;\n", "= |a_1\\rangle\\langle a_2|\\langle b_2|b_1\\rangle\n", "$\n", "

\n", "(4) The Reduced Density Matrix, $\\rho_A$ is the\n", "matrix where we have \"traced out\" bit B:\n", "

\n", "$\\;\\;\\;\\;\\;\\rho_A = \\mathrm{Tr_B}(\\rho_{AB})$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

A couple of detailed examples

\n", "

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "one = 1/sqrt(2)*s0 + 1/sqrt(2)*s1\n", "two = sqrt(3)/2*s0 + Rational(1,2)*s1\n", "state = TP(two, one)\n", "Print(r'State = $%s$' %fmt(state, which_ltx='sympy'))\n", "rho = OP(state, state)\n", "Print(r'Density matrix is: $\\rho=%s$' %latex(rho))\n", "MOP = matrix_as_outer_product(rho)\n", "Print(r'In \"outer product form\":')\n", "Print(r'$\\rho=%s$' %MOP.latex())\n", "MOP.partial_trace(1)\n", "Print('After tracing out the second bit:')\n", "Print(r'$\\rho=%s$' %MOP.latex())\n", "Print('And in matrix form:')\n", "Print(r'$\\rho=%s$' %latex(MOP.M))" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "state = 1/sqrt(2)*s00 + half*s01 + half*s11\n", "Print(r'State = $%s$' %fmt(state, which_ltx='mine'))\n", "rho = OP(state, state)\n", "Print(r'Density matrix is: $\\rho=%s$' %latex(rho))\n", "MOP = matrix_as_outer_product(rho)\n", "Print(r'In \"outer product form\":')\n", "Print(r'$\\rho=%s$' %MOP.latex())\n", "MOP.partial_trace(1)\n", "Print('After tracing out the second bit:')\n", "Print(r'$\\rho=%s$' %MOP.latex())\n", "Print('And in matrix form:')\n", "Print(r'$\\rho=%s$' %latex(MOP.M))" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

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

^ Using purity and entropy as measures of entanglement

\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example 1: Take a maximally entangled state\n", "

\n", "It is not a mixture. So the purity should be maximum and the\n", "entropy minimum." ] }, { "cell_type": "code", "collapsed": false, "input": [ "Print(r'$\\psi = %s$'%fmt(bell_1))\n", "rho_maxE = OP(bell_1, bell_1)\n", "examine_dm(rho_maxE)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Find the reduced density for the first bit\n", "

\n", "Since the entanglement was maximal, either individual bit should\n", "contain no information about the outcome. This looks just like\n", "a maximally mixed state. Both the purity and entropy should reflect\n", "this (minimum purity, maximum entropy)." ] }, { "cell_type": "code", "collapsed": false, "input": [ "rho = matrix_as_outer_product(rho_maxE)\n", "rho.partial_trace(1)\n", "examine_dm(rho.M)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The reduced density for the second bit should be just like the first" ] }, { "cell_type": "code", "collapsed": false, "input": [ "rho = matrix_as_outer_product(rho_maxE)\n", "rho.partial_trace(0)\n", "examine_dm(rho.M)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example 2: Reproduce Cugini page 13 classical mixture (base e)\n", "

\n", "This is really just a test that my code works for base $e$." ] }, { "cell_type": "code", "collapsed": false, "input": [ "rho = mat(.5,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,.5)\n", "S = Entropy(rho, base=E)\n", "Print(r'$\\rho = %s, \\;\\; S = %s$' %(latex(rho), float(S)))" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example 3: A non-maximally entangled 2 bit state\n", "

\n", "The \"intermediate\" values of purity and entropy are a reflection\n", "of \"some amount\" of entanglement." ] }, { "cell_type": "code", "collapsed": false, "input": [ "r3 = 1/sqrt(3)\n", "psi = r3*s00 + r3*s01 + r3*s10\n", "Print(r'$\\psi = %s$'%fmt(psi))\n", "rho = OP(psi,psi)\n", "examine_dm(rho)\n", "# Then do the reduced density for both bit. Should be the same.\n", "rho_op = matrix_as_outer_product(rho)\n", "rho_op.partial_trace(1)\n", "examine_dm(rho_op.M)\n", "rho_op = matrix_as_outer_product(rho)\n", "rho_op.partial_trace(0)\n", "examine_dm(rho_op.M)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example 4: No measurable correlations, yet entangled.\n", "
\n", "Note the minus on the last term!\n", "

\n", "The minimal purity and maximal entropy of one of the bits verifies\n", "that this state is maximally entangled." ] }, { "cell_type": "code", "collapsed": false, "input": [ "psi = half*s00 + half*s01 + half*s10 - half*s11\n", "Print(r'$\\psi = %s$'%fmt(psi))\n", "rho = OP(psi,psi)\n", "S = Entropy(rho)\n", "Print(r'$\\rho = %s, \\;\\; S = %s$' %(latex(rho), latex(S)))\n", "# Then do the reduced density for bit zero\n", "rho_op = matrix_as_outer_product(rho)\n", "rho_op.partial_trace(1)\n", "examine_dm(rho_op.M)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now just change the sign on the last term\n", "

\n", "Giving the product state: $\\left(\\frac{1}{\\sqrt{2}}|0\\rangle \n", "\\frac{1}{\\sqrt{2}}|1\\rangle\\right)\n", "\\otimes \\left(\\frac{1}{\\sqrt{2}}|0\\rangle\n", "\\frac{1}{\\sqrt{2}}|1\\rangle\\right)$\n", "

\n", "And we get maximum purity, minimum entropy." ] }, { "cell_type": "code", "collapsed": false, "input": [ "psi = half*s00 + half*s01 + half*s10 + half*s11\n", "Print(r'$\\psi = %s$'%fmt(psi))\n", "rho = OP(psi,psi)\n", "S = Entropy(rho)\n", "Print(r'$\\rho = %s, \\;\\; S = %s$' %(latex(rho), latex(S)))\n", "# Then do the reduced density for bit one\n", "rho_op = matrix_as_outer_product(rho)\n", "rho_op.partial_trace(1)\n", "examine_dm(rho_op.M)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

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

^ Plot of Purity vs Entropy

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "P = [] # Purity values\n", "S = [] # Entropy values\n", "M = [] # Percentage of -z mixed in\n", "for percent_mZ in range(51):\n", " frac_mZ = percent_mZ/100.0\n", " rho = (1-frac_mZ)*OP(pZ, pZ) + frac_mZ*OP(mZ,mZ)\n", " M += [ percent_mZ, ]\n", " P += [ Purity(rho), ]\n", " S += [ Entropy(rho), ]\n", "pyplot.plot(M, P, label=\"Purity\", color=\"green\");\n", "pyplot.plot(M, S, label=\"Entropy\", color=\"red\");\n", "pyplot.legend(loc='best');\n", "pyplot.title('One bit purity/entropy vs percent mixed');" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "
\n", "

^ Documentation on sglib code

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "psi = alpha*s0 - beta*s1\n", "Print(r'$\\psi=%s$' %myltx(psi))\n", "rho = OP(psi,psi)\n", "Print(r'$\\rho=%s$' %myltx(rho))\n", "MOP = matrix_as_outer_product(rho)\n", "Print(r'$%s$' %MOP.latex())\n", "Print(r'$\\rho=%s$' %latex(MOP.M))" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "M = mat(1,2,3,4,5,6,7,8,\n", " 1,2,3,4,5,6,7,8,\n", " 1,2,3,4,5,6,7,8,\n", " 1,2,3,4,5,6,7,8,\n", " 1,2,3,4,5,6,7,8,\n", " 1,2,3,4,5,6,7,8,\n", " 1,2,3,4,5,6,7,8,\n", " 1,2,3,4,5,6,7,8)\n", "#M = mat(-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,-16)\n", "MOP = matrix_as_outer_product(M)\n", "Print('The original matrix:')\n", "Print(r'$%s$' %MOP.latex())\n", "Print('Partial Trace of bit 0:')\n", "MOP.partial_trace(0)\n", "Print(r'$%s$' %MOP.latex())\n", "Print('Another partial trace of bit 0:')\n", "MOP.partial_trace(0)\n", "Print(r'$%s$' %MOP.latex())" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "#\n", "# How about matrices with symbolic values?\n", "#\n", "\n", "psi = TP(1/sqrt(2)*s0 + 1/sqrt(2)*s1, col(alpha, beta))\n", "Print(r'$\\psi=%s$'%latex(psi))\n", "Print(r'$\\psi=%s$'%fmt(psi))\n", "M = OP(psi,psi)\n", "Print(r'$\\rho = %s$' %latex(M))\n", "MOP = matrix_as_outer_product(M)\n", "Print(r'$%s$'%MOP.latex())\n", "MOP.partial_trace(0)\n", "Print('Tracing out bit zero:')\n", "Print(r'$%s$'%MOP.latex())" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "#\n", "# Now the teleportation state\n", "#\n", "\n", "psi = half*TP(s00, col(alpha,beta))\\\n", " + half*TP(s01, col(beta,alpha))\\\n", " + half*TP(s10, col(alpha,-beta))\\\n", " + half*TP(s11, col(-beta,alpha))\n", "Print(r'$\\psi=%s$'%fmt(psi)) # THIS IS A PROBLEM !!!\n", "Print(r'$\\psi=%s$'%latex(psi))\n", "M = OP(psi,psi)\n", "Print(r'$\\rho = %s$' %latex(M))\n", "MOP = matrix_as_outer_product(M)\n", "Print(r'$%s$'%MOP.latex())\n", "MOP.partial_trace(0)\n", "Print('Tracing out Alice\\'s first bit:')\n", "Print(r'$%s$'%MOP.latex())\n", "MOP.partial_trace(0)\n", "Print('Tracing out Alice\\'s second bit:')\n", "Print(r'$%s$'%MOP.latex())\n", "Print('And the reduced density matrix for Bob is:')\n", "Print(r'$\\rho_B = %s$' %latex(MOP.M))" ], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }