{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Heisenberg Entanglement

\n",
"\n",
"(Sethna, \"Entropy, Order Parameters, and Complexity\", ex. XXX. Exercise developed in collaboration with Jaron Kent-Dobias.)\n",
"\n",
"© 2020, James Sethna, all rights reserved."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%pylab inline\n",
"from scipy import *\n",
"from scipy.linalg import eigh, logm\n",
"from scipy.optimize import curve_fit"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we introduce the quantum Heisenberg antiferromagnet, and use it\n",
"to explore how entropy, temperature, and equilibration\n",
"can emerge through the entanglement of two portions of a large system --\n",
"closely related to the *eigenstate thermalization hypothesis*.\n",
"We saw in *Entanglement of two spins* that ignoring part of a\n",
"system can take a quantum pure state into a mixture of\n",
"states on the remaining subsystem; this should remind you\n",
"of our derivation of the canonical ensemble from a microcanonical\n",
"system divided into subsystem and bath\n",
"(Section 6.1, Fig. 6.1).\n",
"This analogy becomes much more powerful with a larger system,\n",
"a one-dimensional chain of spin 1/2 particles.\n",
"\n",
"The one-dimensional Heisenberg antiferromagnet has Hamiltonian\n",
"\\begin{equation}\n",
"\\mathcal{H}_{N_\\mathrm{spins}}= \\sum_{m=1}^{{N_\\mathrm{spins}}-1} \\mathbf{S}_m \\cdot \\mathbf{S}_{m+1},\n",
"\\end{equation}\n",
"where we have set the strength of the coupling $J$ to 1 -- positive,\n",
"and hence favoring antiparallel spins.\n",
"Here the quantum spins $\\mathbf{S} = (\\sigma_X, \\sigma_Y, \\sigma_Z)$\n",
"have spin 1/2, and are written in terms of the Pauli matrices\n",
"\\begin{equation}\n",
"\\sigma_x = \\begin{pmatrix}0&1\\\\1&0\\end{pmatrix}~~~~~~\n",
"\\sigma_y = \\begin{pmatrix}0&-i\\\\ i&0\\end{pmatrix}~~~~~~\n",
"\\sigma_z = \\begin{pmatrix}1&0\\\\0&-1\\end{pmatrix}\n",
"\\end{equation}\n",
"\n",
"Let us begin with an analytical calculation of the Hamiltonian and\n",
"the eigenstates for $N_\\mathrm{spins}=2$, considered already in\n",
"*Entanglement of two spins*.\n",
"We work in the four-dimensional $\\sigma_z$ basis\n",
"\\begin{equation}\n",
"\\begin{pmatrix}\n",
"|\\uparrow_1\\rangle\\langle\\uparrow_2|\\\\\n",
"|\\uparrow_1\\rangle\\langle\\downarrow_2|\\\\\n",
"|\\downarrow_1\\rangle\\langle\\uparrow_2|\\\\\n",
"|\\downarrow_1\\rangle\\langle\\downarrow_2|\n",
"\\end{pmatrix}.\n",
"\\end{equation}\n",
"\n",
"(a) *Show analytically that\n",
"\\begin{equation}\n",
"\\mathcal{H}_2 =\n",
"\\begin{pmatrix}\n",
" 1 & 0 & 0 & 0\\\\\n",
" 0 & -1 & 2 & 0\\\\\n",
" 0 & 2 & -1 & 0\\\\\n",
" 0 & 0 & 0 & 1\n",
"\\end{pmatrix}.\n",
"\\end{equation}\n",
"Find the eigenvalues and eigenstates for this Hamiltonian. Is the\n",
"ground state the triplet or the singlet? Does this make sense for\n",
"an antiferromagnet?*\n",
"(Hint: The spin $\\mathbf{S}_1$ commutes with the kets $|\\uparrow_2\\rangle$ and\n",
"$|\\downarrow_2\\rangle$ and vice-versa.)\n",
"\n",
"Implementing this calculation elegantly on the computer demands\n",
"that we understand how the single-spin $\\sigma$ operators and the\n",
"dot product $\\mathbf{S}_m \\cdot \\mathbf{S}_{m+1}$ act on the entire $2^{N_\\mathrm{spins}}$-dimensional\n",
"Hilbert space. The fact that they commute with the parts of the\n",
"wavefunction involving other spins says that they act as identity\n",
"matrices on those parts of the Hilbert space. That is,\n",
"$\\sigma_x[1]$ for the first spin needs to be promoted to\n",
"$\\sigma_x[1] \\otimes I_{2^{N_\\mathrm{spins}-1}}$, and\n",
"$\\sigma_x[2]$ for the second needs to be turned into\n",
"$I_2 \\otimes \\sigma_x[1] \\otimes I_{2^{N_\\mathrm{spins}-2}}$, ...\n",
"\n",
"\n",
"(b) *Implement this numerically for the two-spin system. Calculate\n",
"the Heisenberg Hamiltonian, and verify the answer of part (a).*\n",
"(Hint: Many modern programming languages have support for tensor data\n",
"structures. These efficient routines will be important in later steps,\n",
"so use them here.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Pauli matrices\n",
"sigmaX = ...\n",
"sigmaY = array([[0,-1j],[1j,0]])\n",
"sigmaZ = ..."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"One subtle point. In combining an operator $L_{ij}$ acting\n",
" on subsystem $A$ with $M_{\\alpha \\beta}$ acting on subsystem $B$,\n",
" we want an operator $O$ which labels rows using $i\\alpha$ and columns with\n",
" $j\\beta$ $O_{i\\alpha\\,j\\beta}$. We can then use $O$ as a two-index matrix\n",
" to compute eigenvectors and eigenvalues.\n",
" In some implementations, this demands\n",
" that we swap the two inner axes of the naive product $L_{ij}M_{\\alpha\\beta}$."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def TensorProduct(L,M):\n",
" \"\"\"Gives tensor product of two matrices L_ij M_ab, as matrix O_(ia)(jb). Needs to swap axes.\"\"\"\n",
" totalSize = len(L)*len(M)\n",
" return einsum(\"ij,ab->iajb\",L,M).reshape(totalSize,totalSize)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def sigmaOfn(sigma,n):\n",
" \"\"\"Tensor product Pauli matrix with identity matrix to act on spin n=1,2 of two spin Hilbert space\"\"\"\n",
" if n==0:\n",
" sigma = TensorProduct(sigma,identity(2))\n",
" elif n==1:\n",
" sigma = TensorProduct(identity(2),sigma)\n",
" return sigma\n",
"\n",
"h2 = dot(sigmaOfn(sigmaX,0),...) + dot(...) + ...\n",
"\n",
"print(\"h2 =\\n\", h2, \"\\n\")\n",
"\n",
"Heisenberg2 = array([[1,0,0,0],[0,-1,2,0],[0,2,-1,0],[0,0,0,1]])\n",
"\n",
"print(\"Heisenberg2 =\\n\", Heisenberg2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this exercise, we shall discuss how pure energy eigenstates\n",
"states in a system $AB$ become mixed states when we split the system\n",
"into a subsystem $A$ and a bath $B$, and study the properties of\n",
"these mixed states. We shall index operators\n",
"acting on the subsystem $A$ with Latin letters $i$, $j$, operators on the\n",
"bath $B$ with Greek letters $\\alpha$, $\\beta$, and operators on the\n",
"total system $AB$ with capital letters $I$, $J$, or sometimes with\n",
"pairs of indices $i\\alpha$, $j\\beta$.\n",
"\n",
"\n",
"(c) *\n",
"If $\\rho_{i\\alpha,j\\beta}$ is the density matrix for the whole system $AB$,\n",
"show analytically that the sum $\\sum_\\alpha \\rho_{i\\alpha j\\alpha}$\n",
"gives the reduced density matrix for the subsystem (e.g., as\n",
"defined in 'Entanglement of two spins').\n",
"*\n",
"\n",
"We can use the two-spin problem of part (a) to preview the rest of the\n",
"exercise, in a context where you know the answer from\n",
"*Entanglement of two spins*.\n",
"Here we view the first spin as the the 'subsystem' $A$, and the\n",
"second spin as the 'bath' $B$.\n",
"\n",
"(d) *\n",
"Select the singlet eigenstate, and normalize it if necessary.\n",
"Generate the pure-state density matrix, and reshape it into the four\n",
"index tensor $\\rho_{i\\alpha,j\\beta}$. Trace over the bath as in part (c),\n",
"and verify that the reduced density matrix $\\rho^A_{ij}$ describes\n",
"an unpolarized spin. Calculate the entropy by taking the suitable matrix trace.\n",
"*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In python, the eigenvalue routine returns the eigenvectors as the columns of the array. We want the rows, so we must take the transpose. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"vals, vecsTranspose = eigh(Heisenberg2)\n",
"vecs = transpose(vecsTranspose)\n",
"print(vals)\n",
"print(vecs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"singlet = vecs[...]\n",
"singlet"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(\"Singlet state\")\n",
"rhoPure = einsum(\"i,j->ij\",singlet, conj(singlet))\n",
"print(\"rhoPure =\\n\",rhoPure)\n",
"rhoDoubleIndex = rhoPure.reshape(2,2,2,2)\n",
"print(\"\\n rhoDoubleIndex =\\n\", rhoDoubleIndex)\n",
"rhoA = einsum('iaja',rhoDoubleIndex)\n",
"print(\"\\n rhoA =\\n\", rhoA)\n",
"SA = -trace(dot(rhoA,logm(rhoA)))\n",
"print(\"\\n SA =\", SA, \"=?\",log(2.))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To generate the Heisenberg Hamiltonian for multiple spins, we can save steps\n",
"by noting that we already know the Hamiltonian for two spins from\n",
"part (a).\n",
"So the term $\\mathbf{S}_m \\cdot \\mathbf{S}_{m+1}$ in our Heisenberg Hamiltonian\n",
"becomes\n",
"\\begin{equation}\n",
"I_{2^{m-1}} \\otimes \\mathcal{H}_2 \\otimes I_{2^{N_\\mathrm{spins}-(m+1)}}\n",
"\\end{equation}\n",
"\n",
"(e) *\n",
"Use this to write a function that returns the Heisenberg Hamiltonian\n",
"$\\mathcal{H}_{N_\\mathrm{spins}}$ as a\n",
"$2^{N_\\mathrm{spins}} \\times 2^{N_\\mathrm{spins}}$ matrix. Check, for ${N_\\mathrm{spins}} = 2$\n",
"it returns $\\mathcal{H}_2$ from part (a). Check also\n",
"for ${N_\\mathrm{spins}} = 3$ its eigenvalues are $(-4, -4, 2, 2, 2, 2, 0, 0)$,\n",
"and for ${N_\\mathrm{spins}} = 4$ that its distinct eigenvalues are\n",
"$\\{-3 - 2\\sqrt{3}, -1 - 2\\sqrt{2},3,-1 + 2\\sqrt{2},-1, -3 + 2\\sqrt{3}\\}\n",
"\\approx \\{-6.46, -3.8, 3, 1.8, -1, 0.46\\}$.\n",
"*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the $C$ and Python convention where indices start with\n",
" zero, we should use\n",
" $I_{2^{m}} \\otimes \\mathcal{H}_2 \\otimes I_{2^{N_\\mathrm{spins}-(m+2)}}$.\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def Heisenberg(nS):\n",
" Ham = TensorProduct(Heisenberg2,identity(2**(nS-2)))\n",
" for m in range(1,nS-1):\n",
" Ham = Ham + TensorProduct(TensorProduct(identity(...),Heisenberg2),identity(2**(...)))\n",
" return Ham\n",
"print(Heisenberg(2))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"set_printoptions(precision=3,suppress=True)\n",
"print(eigh(Heisenberg(3))[0])\n",
"print(eigh(Heisenberg(4))[0])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We shall work with a system of $N_\\mathrm{spins} = N_{AB} = 10$ spins in the chain;\n",
"we shall primarily study a subsystem with $N_A = 4$ spins, so the bath\n",
"has $N_B = N_{AB}-N_A = 6$ spins.\n",
"We shall use an eigenstate $\\psi$ of $\\mathcal{H}_{N_{AB}}$ to calculate the\n",
"reduced density matrix $\\rho_A$ for $N_A$, to investigate the\n",
"entanglement between $A$ and the bath $B$, to calculate the entanglement\n",
"entropy, and to illustrate *eigenstate thermalization*. For the latter,\n",
"we want an energy that is lower than average, but not near zero.\n",
"\n",
"\n",
"(f) *\n",
"Create $\\mathcal{H}_{AB} = \\mathcal{H}_{10}$. Find its energy eigenvalues and\n",
"eigenstates, and (if necessary) sort them in increasing order of\n",
"their energy. Pick the energy eigenstate $\\psi$ of the full system that is\n",
"$1/4$ the way from the bottom (the $K=2^{N_{AB}-3}$ entry).\n",
"Calculate the pure density matrix $\\rho^\\mathrm{pure}$,\n",
"reshape it into the four index tensor $\\rho^\\mathrm{AB}_{i\\alpha,j\\beta}$, and\n",
"trace over the bath to give the reduced density matrix $\\rho^A_{ij}$.\n",
"Check that $\\rho^A$ has trace one (as it must), and calculate\n",
"$Tr[(\\rho^A)^2]$. Is it is a mixed state?\n",
"*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In python, the eigenvalue routine returns the eigenvectors as the columns of the array. We want the rows, so we must take the transpose. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"nAB = 10;\n",
"HamAB = Heisenberg(nAB);\n",
"EABs, eigvecsTranspose = eigh(HamAB)\n",
"psiABs = eigvecsTranspose.transpose()\n",
"K=...\n",
"psiK = psiABs[K]\n",
"EK = EABs[...]\n",
"\n",
"nA = 4\n",
"rhoPure = einsum(\"i,j->ij\",...,conj(psiK))\n",
"rhoAB = rhoPure.reshape(2**nA,2**(nAB-nA),2**nA,2**(nAB-nA))\n",
"rhoA = einsum(...,rhoAB)\n",
"\n",
"print(\"Trace rhoA\", trace(rhoA))\n",
"print(\"Trace rhoA^2\", trace(dot(rhoA,rhoA)))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The entanglement entropy between $A$ and $B$ for a pure state $\\psi$ of $AB$\n",
"is the entropy of the reduced density matrix of $A$.\n",
"\n",
"\n",
"(g) *\n",
"Calculate the entanglement entropy $S = -Tr{\\rho_A \\log \\rho_A}$.\n",
"Check that it has the same entropy as subsystem $B$.\n",
"Write a loop over $N_A$ ranging through all values from\n",
"zero to $N_{AB}$, and plot $S$ as a function of $N_A$ for our particular\n",
"eigenstate $\\psi$. Where is the entanglement entropy largest? Explain\n",
"why it goes to zero for the two endpoints.\n",
"*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"SA = ...\n",
"print(\"SA = \", SA)\n",
"rhoB = einsum(...,rhoAB)\n",
"SB = ...\n",
"print(\"SB = \", SB)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"rhos = [rhoPure.reshape(2**nA,2**(nAB-nA),2**nA,2**(nAB-nA)) for nA in range(0,nAB+1)];\n",
"rhoAs = [einsum('iaja', rho) for rho in rhos]\n",
"SAs = [... for rhoA in rhoAs]\n",
"plot(arange(0,nAB+1),real(SAs),\"bo-\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The term 'entanglement' is mutual; $A$ and $B$ are entangled, rather than\n",
"$B$ has somehow perturbed $A$. This is not an accident. As you checked\n",
"numerically, the entanglement entropies of the two subsystems should be the\n",
"same. (This can be shown using the *Schmidt decomposition*\n",
"-- an application of singular value decomposition to density\n",
"matrices in quantum mechanics).\n",
"\n",
"In statistical mechanics, a large system $AB$ in the microcanonical ensemble at energy $E$ will, when restricted to a relatively small subsystem $A$,\n",
"generate an equilibrium thermal ensemble at the corresponding temperature.\n",
"The *eigenstate thermalization hypothesis* argues that\n",
"many quantum systems this to an extreme: for any eigenstate $\\psi$ with\n",
"energy $E$, the reduced density matrix $\\rho_A$ of the subsystem will\n",
"converge to a Boltzmann equilibrium thermal ensemble\n",
"\\begin{equation}\n",
"\\rho^\\mathrm{\\beta}_{jk} = \\delta_{jk} e^{-\\beta E^A_k}/\\sum_\\ell e^{-\\beta E^A_\\ell}\n",
"\\end{equation}\n",
"as the system size goes to infinity.\n",
"\n",
"Let us calculate the probability $p_k$ that our subsystem is in eigenstate\n",
"$\\psi^A_k$, $p_k = Tr(|\\psi^A_k\\rangle\\langle\\psi^A_k| \\,\\rho_A)$.\n",
"We are simulating a rather small system, so fluctuations will be large.\n",
"\n",
"(h) *\n",
"Make a log plot of $p_k$ vs. $E^{A}_k$. Do a nonlinear fit\n",
"to the predicted form above to find $\\beta$,\n",
"and plot the result with your data.\n",
"*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"HamA=Heisenberg(nA)\n",
"EAs, psiAsTranspose =eigh(HamA)\n",
"psiAs = transpose(psiAsTranspose)\n",
"psiKetBras = [einsum(\"i,j->ij\",...,conj(psiA)) for psiA in psiAs]\n",
"ps = [trace(dot(psiKetBra,...)) for psiKetBra in psiKetBras]\n",
"fig = plot(EAs,ps,'bo')\n",
"yscale('log')\n",
"def BoltzmannProb(E,A,beta):\n",
" return A*exp(-beta*E)\n",
"A0, beta0 = curve_fit(BoltzmannProb,EAs,ps)[0]\n",
"plot(EAs, BoltzmannProb(EAs, A0, beta0))\n",
"print(beta0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In particular, the reduced density matrix is predicted to be at the temperature\n",
"of the microcanonical ensemble at the energy $E$ of the original pure state\n",
"$\\psi$.\n",
"\n",
"(i) *\n",
"Write a function $EbarAB(\\beta)$ returning the average energy\n",
"of the entire system as a function of $\\beta$. Take a sampling of\n",
"eigenstates $\\psi_K$ of the total system, fit $p_k$ vs $E^A_k$ as in\n",
"part(h), and plot $\\beta$ vs. E along with your prediction $\\beta(EbarAB)$.\n",
"Do you achieve a rough agreement?\n",
"*\n",
"\n",
"We suggest starting with only a few points, spread over the interval. For example, points starting at $K=32$ and separated by $\\Delta K=64$ will span the range avoiding the endpoints."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def beta(psi):\n",
" \"\"\"\n",
" Returns best fit beta for reduced density matrix \n",
" corresponding to the Kth eigenstate of the system\n",
" \"\"\"\n",
" rho = einsum(\"i,j->ij\",psi,conj(psi)).reshape(2**nA,2**(nAB-nA),2**nA,2**(nAB-nA))\n",
" rhoA = einsum('iaja',rho)\n",
" ps = [trace(dot(psiKetBra,rhoA)) for psiKetBra in psiKetBras]\n",
" A0, beta0 = curve_fit(BoltzmannProb,EAs,ps, maxfev=50000)[0]\n",
" return beta0\n",
"\n",
"Kmin = 2**(nAB-5)\n",
"Ks = arange(Kmin,2**nAB,2*Kmin)\n",
"betas = [beta(psiABs[K]) for K in Ks]\n",
"Es = EABs[Ks]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plot(Es,betas,\"bo\")\n",
"ylim(-2,2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def EbarAB(beta):\n",
" Z = sum(exp(-beta*EABs))\n",
" return sum(... * ...)/Z\n",
"\n",
"plot(Es, betas, \"bo\")\n",
"betasTheory = arange(-2,1.5,0.01)\n",
"EbarsTheory = [EbarAB(beta) for beta in betasTheory]\n",
"plot(EbarsTheory,betasTheory,\"r\")\n",
"ylim(-2,2)"
]
}
],
"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.5.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}