{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Berechnung der Concurrence\n",
    "\n",
    "Concurrence kann nur für bi-partite Systeme berechnet werden.\n",
    "* Zwei-Qubit-Systeme\n",
    "* Systeme in der Schmidt-Normalform\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import qiskit.quantum_info as qi\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Bell-Zustand"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bell state: \n"
     ]
    },
    {
     "data": {
      "text/latex": [
       "$$\\frac{\\sqrt{2}}{2} |00\\rangle+\\frac{\\sqrt{2}}{2} |11\\rangle$$"
      ],
      "text/plain": [
       "<IPython.core.display.Latex object>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Bell-Zustand\n",
    "psi = np.array([1,0,0,1])/np.sqrt(2)\n",
    "psi_ERP = qi.Statevector(psi)\n",
    "\n",
    "print(\"Bell state: \")\n",
    "psi_ERP.draw(output='latex') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Concurrence : 1.000000\n"
     ]
    }
   ],
   "source": [
    "C_ERP = qi.concurrence(psi_ERP)\n",
    "print(\"Concurrence : {:>3f}\".format(C_ERP))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### W-Zustand in Schmidt-Normaform"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "W-Zustand als bi-partites System (A|BC) in der Schmidt-Darstellung\n"
     ]
    },
    {
     "data": {
      "text/latex": [
       "$$\\frac{\\sqrt{6}}{3} |00\\rangle+\\frac{\\sqrt{3}}{3} |11\\rangle$$"
      ],
      "text/plain": [
       "<IPython.core.display.Latex object>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# W-Zustand (in Schmidt-Normalform)\n",
    "# Wird als bi-partites System formuliert\n",
    "psi = np.array([np.sqrt(2/3),0,0,np.sqrt(1/3)])\n",
    "psi_W = qi.Statevector(psi)\n",
    "\n",
    "print(\"W-Zustand als bi-partites System (A|BC) in der Schmidt-Darstellung\")\n",
    "psi_W.draw(output='latex') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Concurrence : 0.942809\n"
     ]
    }
   ],
   "source": [
    "C_W = qi.concurrence(psi_W)\n",
    "print(\"Concurrence : {:>3f}\".format(C_W))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "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.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
