{ "metadata": { "name": "", "signature": "sha256:e4f19468784b96ac885a971128b889df7c3e21da66440bbbeadaa932d9286552" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\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", "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": [ "
\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": [ "
\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": [ "
\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", "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 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", "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", ""
]
},
{
"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", "(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": [ "
" ] }, { "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", "" ] }, { "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", "