{ "metadata": { "name": "", "signature": "sha256:5db6a63df9cde699a2f6d05affe90130c8801de823e6caf99e620690139daf39" }, "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", "
• Next: ...\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "

### Contents

\n", "
\n", "
1. Imports, etc\n", "
2. References\n", "
3. 2.4.1 Pure-State Density Matrices and the Trace Operation\n", "
4. 2.4.2 Mixed-State Density Matrices\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
\n", "\n", "

### ^ Preliminaries

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%autosave 0\n", "from __future__ import division\n", "from sglib import *" ], "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": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
\n", "\n", "

### ^ References

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

### ^ 2.4.1 Pure-State Density Matrices and the Trace Operation

\n", "

\n", "Note that my only operators are matrices for now. So I won't make\n", "the operator/matrix distinction at all." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The density operator of a pure state $|\\psi\\rangle$ is:\n", "

\n", "$$\n", "(2.11) \\;\\; \\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. Below I'm writing things in the\n", "\"z\" or \"classical\" basis. So the off-diagonal terms represent the\n", "coherence or quantumness of the state in the classical basis.\n", "

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

\n", "$$\n", "(2.14) \\;\\; \\mathrm{Tr}(A) = \\sum_i\\langle\\phi_i|A|\\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 if\n", "$A$ is actually a matrix, so we're just adding up the main diagonal." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Define the outer product operation:\n", "def OP(x,y): return( x*y.transpose().conjugate())\n", "\n", "# Define the trace operation:\n", "def Tr(M, basis, V=False):\n", " if V: Print('Trace operation:')\n", " result = 0\n", " for phi in basis:\n", " phi_bra = phi.transpose().conjugate()\n", " temp1 = megasimp(M*phi)\n", " temp = megasimp(phi_bra*M*phi)\n", " temp = temp # Sympy gives a 1x1 matrix result\n", " if V: Print(r'$\\;\\;\\;\\; %s %s %s$' %(\\\n", " myltx(phi_bra),\\\n", " myltx(M),\\\n", " myltx(phi)))\n", " if V: Print(r'$\\;\\;\\;\\;\\;\\;\\;\\; = %s %s$' %(\\\n", " myltx(phi_bra),\\\n", " myltx(temp1)))\n", " if V: Print(r'$\\;\\;\\;\\;\\;\\;\\;\\; = %s$' %myltx(temp))\n", " result += temp\n", " if V: Print(r'$\\;\\;\\;\\; = %s$' %myltx(result))\n", " return(result)\n", "\n", "# Create a formatter for stuff like |00>\n", "fmt = sg_format_state(['0','1'], '').format\n", "\n", "# Create a two-bit basis\n", "b2bit = [TP(pZ,pZ), TP(pZ,mZ), TP(mZ,pZ), TP(mZ,mZ)]" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

### Demonstrate the trace operation

\n", "

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "a_11, a_12, a_21, a_22 = sy.var('a_11, a_12, a_21, a_22')\n", "A = mat(a_11, a_12, a_21, a_22)\n", "trace = Tr(A, [pZ, mZ], V=True)\n", "trace = Tr(A, [pX, mX], V=True)\n", "trace = Tr(A, [pY, mY], V=True)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

### Single bit states:

\n", "

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "psi = col(1,0)\n", "psi = col(0,1)\n", "psi = col(1/sqrt(2), 1/sqrt(2))\n", "psi = col(frac(4,5), frac(3,5))\n", "rho = OP(psi,psi)\n", "trace = Tr(rho, [pZ, mZ])\n", "Print(r'$\\psi=%s,\\;\\;\\;\\; \\rho=%s, \\;\\;\\;\\mathrm{Tr}(\\rho)=%s$'\n", " %(fmt(psi), myltx(rho), myltx(trace)))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "$\\psi=\\frac{4}{5}|0\\rangle+\\frac{3}{5}|1\\rangle,\\;\\;\\;\\; \\rho=\\left[\\begin{matrix}\\frac{16}{25} & \\frac{12}{25}\\\\\\frac{12}{25} & \\frac{9}{25}\\end{matrix}\\right], \\;\\;\\;\\mathrm{Tr}(\\rho)=1$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 4 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

### Product states:

\n", "

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "s1 = col(1,0); s2 = col(0,1) # No interference\n", "s1 = col(0,1)\n", "s1 = col(1/sqrt(2), 1/sqrt(2))\n", "#s2 = col(1/sqrt(2), 1/sqrt(2))\n", "psi = TP( s1, s2 )\n", "rho = OP(psi,psi)\n", "trace = Tr(rho, b2bit)\n", "Print(r'$\\psi=%s,\\;\\;\\;\\; \\rho=%s, \\;\\;\\;\\mathrm{Tr}(\\rho)=%s$'\n", " %(fmt(psi), myltx(rho), myltx(trace)))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "$\\psi=\\frac{1}{\\sqrt{2}}|01\\rangle+\\frac{1}{\\sqrt{2}}|11\\rangle,\\;\\;\\;\\; \\rho=\\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & \\frac{1}{2} & 0 & \\frac{1}{2}\\\\0 & 0 & 0 & 0\\\\0 & \\frac{1}{2} & 0 & \\frac{1}{2}\\end{matrix}\\right], \\;\\;\\;\\mathrm{Tr}(\\rho)=1$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 5 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

### Maximally entangled states:

\n", "

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "bell_1 = 1/sqrt(2)*TP(pZ,pZ) + 1/sqrt(2)*TP(mZ,mZ) # phi+\n", "bell_2 = 1/sqrt(2)*TP(pZ,pZ) - 1/sqrt(2)*TP(mZ,mZ) # phi-\n", "bell_3 = 1/sqrt(2)*TP(pZ,mZ) + 1/sqrt(2)*TP(mZ,pZ) # psi+ (Triplet)\n", "bell_4 = 1/sqrt(2)*TP(pZ,mZ) - 1/sqrt(2)*TP(mZ,pZ) # psi- (Singlet)\n", "bell = [bell_1, bell_2, bell_3, bell_4]\n", "for psi in bell:\n", " rho = OP(psi,psi)\n", " trace = Tr(rho, b2bit)\n", " Print(r'$\\psi=%s,\\;\\;\\;\\; \\rho=%s, \\;\\;\\;\\mathrm{Tr}(\\rho)=%s$'\n", " %(fmt(psi), myltx(rho), myltx(trace)))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "$\\psi=\\frac{1}{\\sqrt{2}}|00\\rangle+\\frac{1}{\\sqrt{2}}|11\\rangle,\\;\\;\\;\\; \\rho=\\left[\\begin{matrix}\\frac{1}{2} & 0 & 0 & \\frac{1}{2}\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\\\frac{1}{2} & 0 & 0 & \\frac{1}{2}\\end{matrix}\\right], \\;\\;\\;\\mathrm{Tr}(\\rho)=1$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "$\\psi=\\frac{1}{\\sqrt{2}}|00\\rangle-\\frac{1}{\\sqrt{2}}|11\\rangle,\\;\\;\\;\\; \\rho=\\left[\\begin{matrix}\\frac{1}{2} & 0 & 0 & - \\frac{1}{2}\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\- \\frac{1}{2} & 0 & 0 & \\frac{1}{2}\\end{matrix}\\right], \\;\\;\\;\\mathrm{Tr}(\\rho)=1$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "$\\psi=\\frac{1}{\\sqrt{2}}|01\\rangle+\\frac{1}{\\sqrt{2}}|10\\rangle,\\;\\;\\;\\; \\rho=\\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & \\frac{1}{2} & \\frac{1}{2} & 0\\\\0 & \\frac{1}{2} & \\frac{1}{2} & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right], \\;\\;\\;\\mathrm{Tr}(\\rho)=1$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] }, { "html": [ "$\\psi=\\frac{1}{\\sqrt{2}}|01\\rangle-\\frac{1}{\\sqrt{2}}|10\\rangle,\\;\\;\\;\\; \\rho=\\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & \\frac{1}{2} & - \\frac{1}{2} & 0\\\\0 & - \\frac{1}{2} & \\frac{1}{2} & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right], \\;\\;\\;\\mathrm{Tr}(\\rho)=1$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 6 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

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

### ^ 2.4.2 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:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "zero = col(1,0); one = col(0,1)\n", "rho = frac(1,2)*OP(zero,zero) + frac(1,2)*OP(one,one)\n", "string = r'$\\psi$ is either $|0\\rangle$ or $|1\\rangle,\\;\\;\\;'\n", "string += r'\\rho=%s,\\;\\;\\;'\n", "string += r'\\mathrm{Tr}(\\rho)=%s$'\n", "Print(string%(myltx(rho), myltx(trace)))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "$\\psi$ is either $|0\\rangle$ or $|1\\rangle,\\;\\;\\;\\rho=\\left[\\begin{matrix}\\frac{1}{2} & 0\\\\0 & \\frac{1}{2}\\end{matrix}\\right],\\;\\;\\;\\mathrm{Tr}(\\rho)=1$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 7 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note the difference between this case and the one where you have a\n", "50/50 chance of getting zero or one based on an equal superposition:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "psi = col(1/sqrt(2), 1/sqrt(2))\n", "rho = OP(psi,psi)\n", "Print(r'$\\psi=%s,\\;\\;\\; \\rho=%s, \\;\\;\\;\\mathrm{Tr}(\\rho)=%s$'\n", " %(fmt(psi), myltx(rho), myltx(trace)))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "$\\psi=\\frac{1}{\\sqrt{2}}|0\\rangle+\\frac{1}{\\sqrt{2}}|1\\rangle,\\;\\;\\; \\rho=\\left[\\begin{matrix}\\frac{1}{2} & \\frac{1}{2}\\\\\\frac{1}{2} & \\frac{1}{2}\\end{matrix}\\right], \\;\\;\\;\\mathrm{Tr}(\\rho)=1$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 8 }, { "cell_type": "markdown", "metadata": {}, "source": [ "In both cases, we have 1/2 measurement proabilities for each result. But\n", "in the superposition case, we also have the off-diagonal \"interference\"\n", "terms." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Suppose we look at the same case in the x basis.\n", "

\n", "$$\n", "|0\\rangle = \\frac{1}{\\sqrt{2}}|+x\\rangle+\\frac{1}{\\sqrt{2}}|-x\\rangle\n", "\\\\\n", "|1\\rangle = \\frac{1}{\\sqrt{2}}|+x\\rangle-\\frac{1}{\\sqrt{2}}|-x\\rangle\n", "$$" ] }, { "cell_type": "code", "collapsed": false, "input": [ "zero = col(1/sqrt(2), 1/sqrt(2))\n", "one = col(1/sqrt(2), -1/sqrt(2))\n", "rho = frac(1,2)*OP(zero,zero) + frac(1,2)*OP(one,one)\n", "string = r'$\\psi$ is either $|0\\rangle$ or $|1\\rangle,\\;\\;\\;'\n", "string += r'\\rho_x=%s,\\;\\;\\;'\n", "string += r'\\mathrm{Tr}(\\rho)=%s$'\n", "Print(string%(myltx(rho), myltx(trace)))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "$\\psi$ is either $|0\\rangle$ or $|1\\rangle,\\;\\;\\;\\rho_x=\\left[\\begin{matrix}\\frac{1}{2} & 0\\\\0 & \\frac{1}{2}\\end{matrix}\\right],\\;\\;\\;\\mathrm{Tr}(\\rho)=1$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 9 }, { "cell_type": "markdown", "metadata": {}, "source": [ "But the superposition: \n", "$\\frac{1}{\\sqrt{2}}|0\\rangle+\\frac{1}{\\sqrt{2}}|1\\rangle$\n", "is simply equal to the state $|+x\\rangle$." ] }, { "cell_type": "code", "collapsed": false, "input": [ "psi = col(1, 0)\n", "rho = OP(psi,psi)\n", "xfmt = sg_format_state(['+x','-x'], ',').format\n", "Print(r'$\\psi=%s,\\;\\;\\; \\rho_x=%s, \\;\\;\\;\\mathrm{Tr}(\\rho)=%s$'\n", " %(xfmt(psi), myltx(rho), myltx(trace)))" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "$\\psi=|+x\\rangle,\\;\\;\\; \\rho_x=\\left[\\begin{matrix}1 & 0\\\\0 & 0\\end{matrix}\\right], \\;\\;\\;\\mathrm{Tr}(\\rho)=1$" ], "metadata": {}, "output_type": "display_data", "text": [ "" ] } ], "prompt_number": 10 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 10 } ], "metadata": {} } ] }