{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e5e44fb3",
   "metadata": {},
   "source": [
    "## Ejemplo 5.4: Varios estados compuestos importantes"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "71cd75b7",
   "metadata": {},
   "source": [
    "$\\newcommand{\\ket}[1]{|{#1}\\rangle}\\newcommand{\\bra}[1]{\\langle{#1}|}$Definimos varios estados compuestos importantes que usaremos durante el curso:\n",
    "\n",
    "1. Estado máximamente mezclado:\n",
    "\\begin{align*}        \n",
    "  \\delta &= \\frac{1}{4} \\left[\\begin{smallmatrix}\n",
    "                 1 & 0 & 0 & 0\\\\\n",
    "                 0 & 1 & 0 & 0\\\\\n",
    "                 0 & 0 & 1 & 0\\\\\n",
    "                 0 & 0 & 0 & 1 \\end{smallmatrix}\\right]\n",
    "\\end{align*}\n",
    "Los sub-sistemas que componen este estado son independientes entre sí, ya que\n",
    "\\begin{align*}        \n",
    "  \\delta &= \\frac{1}{2} \\left[\\begin{matrix}\n",
    "                 1 & 0\\\\\n",
    "                 0 & 1 \\end{matrix}\\right]\n",
    "                 \\otimes\n",
    "           \\frac{1}{2} \\left[\\begin{matrix}\n",
    "                 1 & 0\\\\\n",
    "                 0 & 1 \\end{matrix}\\right]\n",
    "\\end{align*}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e51496e6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "delta_1 =\n",
      " [[0.25 0.   0.   0.  ]\n",
      " [0.   0.25 0.   0.  ]\n",
      " [0.   0.   0.25 0.  ]\n",
      " [0.   0.   0.   0.25]]\n",
      "\n",
      "rho = \n",
      " [[0.5 0. ]\n",
      " [0.  0.5]] \n",
      "sigma = \n",
      " [[0.5 0. ]\n",
      " [0.  0.5]] \n",
      "delta_1 = kron(rho, sigma) =\n",
      " [[0.25 0.   0.   0.  ]\n",
      " [0.   0.25 0.   0.  ]\n",
      " [0.   0.   0.25 0.  ]\n",
      " [0.   0.   0.   0.25]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "delta_1 = np.array([[1/4, 0, 0, 0], [0, 1/4, 0, 0], [0, 0, 1/4, 0], [0, 0, 0, 1/4]])\n",
    "print(\"delta_1 =\\n\", str(delta_1))\n",
    "\n",
    "# Pero también:\n",
    "rho    = np.array([[1/2, 0], [0, 1/2]])\n",
    "sigma  = np.array([[1/2, 0], [0, 1/2]])\n",
    "delta_1 = np.kron(rho, sigma)\n",
    "print(\"\\nrho = \\n\", rho, \"\\nsigma = \\n\", sigma, \"\\ndelta_1 = kron(rho, sigma) =\\n\", str(delta_1))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7625c52a",
   "metadata": {},
   "source": [
    "2. Estado con correlación máxima: \n",
    "          \\begin{align*}        \n",
    "              \\delta &= \\frac{1}{2} \\left[\\begin{smallmatrix}\n",
    "                 1 & 0 & 0 & 0\\\\\n",
    "                 0 & 0 & 0 & 0\\\\\n",
    "                 0 & 0 & 0 & 0\\\\\n",
    "                 0 & 0 & 0 & 1 \\end{smallmatrix}\\right]\n",
    "          \\end{align*}\n",
    "Los sub-sistemas que componen este estado presentan una cierta correlación, pero no están entrelazados entre sí. Esto se puede ver con la siguiente descomposición:\n",
    "\\begin{align*}        \n",
    " \\delta &=  \\frac{1}{2} \\left[\\begin{matrix}\n",
    "                 1 & 0\\\\ 0 & 0 \\end{matrix}\\right]\n",
    "            \\otimes \\left[\\begin{matrix}\n",
    "                 1 & 0\\\\ 0 & 0 \\end{matrix}\\right]        \n",
    "        +  \\frac{1}{2} \\left[\\begin{matrix}\n",
    "                 0 & 0\\\\ 0 & 1 \\end{matrix}\\right]\n",
    "            \\otimes \\left[\\begin{matrix}\n",
    "                 0 & 0\\\\ 0 & 1 \\end{matrix}\\right]\n",
    "          \\end{align*}\n",
    "por lo que se trata de un estado separable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "746f0b09",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "delta_2 =\n",
      " [[0.5 0.  0.  0. ]\n",
      " [0.  0.  0.  0. ]\n",
      " [0.  0.  0.  0. ]\n",
      " [0.  0.  0.  0.5]]\n",
      "\n",
      "Pi0 = \n",
      " [[1 0]\n",
      " [0 0]] \n",
      "Pi1 = \n",
      " [[0 0]\n",
      " [0 1]] \n",
      "delta_2 = 1/2*kron(Pi0,Pi0) + 1/2*kron(Pi1,Pi1) =\n",
      " [[0.5 0.  0.  0. ]\n",
      " [0.  0.  0.  0. ]\n",
      " [0.  0.  0.  0. ]\n",
      " [0.  0.  0.  0.5]]\n"
     ]
    }
   ],
   "source": [
    "delta_2 = np.array([[1/2, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1/2]])\n",
    "print(\"delta_2 =\\n\", str(delta_2))\n",
    "\n",
    "\n",
    "# Pero tambien:\n",
    "Pi0    = np.array([[1, 0], [0, 0]])\n",
    "Pi1    = np.array([[0, 0], [0, 1]])\n",
    "delta_2 = 1/2*np.kron(Pi0,Pi0) + 1/2*np.kron(Pi1,Pi1)\n",
    "print(\"\\nPi0 = \\n\", Pi0, \"\\nPi1 = \\n\", Pi1, \"\\ndelta_2 = 1/2*kron(Pi0,Pi0) + 1/2*kron(Pi1,Pi1) =\\n\", str(delta_2))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "971bc395",
   "metadata": {},
   "source": [
    "3. Estado máximamente entrelazado:\n",
    "           \\begin{align*}        \n",
    "              \\delta &= \\frac{1}{2} \\left[\\begin{smallmatrix}\n",
    "                 1 & 0 & 0 & 1\\\\\n",
    "                 0 & 0 & 0 & 0\\\\\n",
    "                 0 & 0 & 0 & 0\\\\\n",
    "                 1 & 0 & 0 & 1 \\end{smallmatrix}\\right]\n",
    "           \\end{align*}\n",
    "Este estado se corresponde a un estado puro, ya que\n",
    "           \\begin{align*}        \n",
    "              \\delta &= \\ket{\\psi}\\bra{\\psi}\n",
    "           \\end{align*}\n",
    "           donde $\\ket{\\psi} = \\frac{1}{\\sqrt{2}} \\bigl(\\ket{0} \\otimes \\ket{0} + \\ket{1} \\otimes \\ket{1} \\bigr)$,\n",
    "           y no se puede descomponer como un estado independiente o mixto. Por tanto concluimos que éste es un estado entrelazado."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "c14c2ac3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "delta_3 =\n",
      " [[0.5 0.  0.  0.5]\n",
      " [0.  0.  0.  0. ]\n",
      " [0.  0.  0.  0. ]\n",
      " [0.5 0.  0.  0.5]]\n",
      "\n",
      "ket_psi = \n",
      " [[0.70710678]\n",
      " [0.        ]\n",
      " [0.        ]\n",
      " [0.70710678]] \n",
      "delta_3 = ket_psi * ket_psi.H =\n",
      " [[0.5 0.  0.  0.5]\n",
      " [0.  0.  0.  0. ]\n",
      " [0.  0.  0.  0. ]\n",
      " [0.5 0.  0.  0.5]]\n"
     ]
    }
   ],
   "source": [
    "delta_3 = np.array([[1/2, 0, 0, 1/2], [0, 0, 0, 0], [0, 0, 0, 0], [1/2, 0, 0, 1/2]])\n",
    "print(\"delta_3 =\\n\", str(delta_3))\n",
    "\n",
    "# Pero también:\n",
    "ket0 = np.array([[1], [0]])\n",
    "ket1 = np.array([[0], [1]])\n",
    "ket_psi = 1/np.sqrt(2) * (np.kron(ket0, ket0) + np.kron(ket1, ket1))\n",
    "delta_3 = ket_psi @ ket_psi.conj().T\n",
    "print(\"\\nket_psi = \\n\", ket_psi, \"\\ndelta_3 = ket_psi * ket_psi.H =\\n\", str(delta_3))"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Raw Cell Format",
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
