phy-521/presentation/.ipynb_checkpoints/Entanglement-checkpoint.ipynb

350 lines
31 KiB
Plaintext
Raw Normal View History

2020-12-23 21:45:08 +00:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"# EPR Paradox Example\n",
"\n",
"# A neutral pi meson (pi0) decays into an electron/positron (e-/e+) \n",
"# pair.\n",
"\n",
"# pi0 --> e+ + e- (electron-positron pair)\n",
"# pi0 has angular momentum l = s = 0\n",
"\n",
"# Align electron and positron detectors in opposite directions.\n",
"\n",
"# | pi0 |\n",
"# |e- <------ ------> e+|\n",
"\n",
"# Where hbar = 1, the measurement of the spin in some direction is \n",
"# +/-1 with spin state [1 0] (up) or [0 1] (down).\n",
"\n",
"# The Pauli exclusion principle with conserved angular momentum 0\n",
"# dictates this system must be in the singlet state \n",
"# chi = [1/sqrt(2) (|up+>|down-> - |down+>|up->)].\n",
"\n",
"# In this state, if the positron is measured to have spin [1 0], the \n",
"# electron must have spin [0 1], or vice versa. There is an equal \n",
"# probability to find either state during the first measurement.\n",
"\n",
"# This view is consistent with the realist view. The realist view could \n",
"# hold that the electron and position had those angular momenta \n",
"# from creation.\n",
"\n",
"# EPR assumes influences cannot propagate faster than the speed of \n",
"# light. \"Wave function collapse\" is apparently instantaneous, however.\n",
"\n",
"\n",
"import numpy as np\n",
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.patches as mpatches\n",
"%matplotlib inline "
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEXCAYAAACu1P9TAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAHHpJREFUeJzt3XmcXGWd7/FPZZlAJsYEZgaDBvFCCIsOizDIIjQgAqMEZIIRGIcEr5gL6Au3GTalEwcUGZhhE4aLGRhFL6g4kHEQBGmILMFhuyJkuQoGEtaYQDbI1veP3yn69Mm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d62e+HEMEcwQJ4TcS/QBdvR7qyRJ/a6ewP8jceW6Jbmy+4kDubsRgb+EOBBboftWfvVyqNWr5S2h/Mp7owvPz+677975xBMbe0kYSUrOE8RlUTZQT5fO0zXq5cN9DnFBqeLvl+5M12nk1XrF65SPJbp9uvXtP/HEE3R2diZ5O//881vehoHcPm9p/+8HQhubeaP8/CeoEeRF/wl8gO6X5T2IOLW9+rueDxDXEsn/+PBw4noi+RE+txOnpueHZU6i60QtSVKT1BP41xJj52cSQydPBL5HXHfjgazOG8Q1V84hTrw6DPhRNu2K3HNdQ1xb5JaszqnEtTkupfyXciRJ/aSePvxlxDj7y4lfl18N/AfxizV53yJWIGcTewO/Jq5+90quzlIi6K8kViBLiLBv7+sbeDtqa2trdRN6tLm3T80zEP73A6GNrVLvpVdboTPrj5Ik1alSqUCNbPeiZZKUCANfkhJh4EtSIgx8SUqEgS9JiTDwJSkRBr4kJcLAl6REGPiSlAgDX5ISYeBLUiIMfElKhIEvSYkw8CUpEQa+JCXCwJekRBj4kpQIA1+SEmHgS1IiDHxJSoSBL0mJMPAlvS0MGjSIKVOmtLoZmzUDPzGzZ89m4sS
"text/plain": [
"<matplotlib.figure.Figure at 0x7f7490162da0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# If information about the measurement of the wave function propagated\n",
"# at a finite speed, the particles could conceivably be measured such\n",
"# that both are equally likely to hold either spin up or spin down.\n",
"\n",
"# What would happen if the measurements were uncorrelated?\n",
"\n",
"plt.hist(np.random.randint(0,2,1000),bins=4)\n",
"plt.hist(np.random.randint(3,5,1000),bins=4)\n",
"elepatch = mpatches.Patch(color='blue', label='e-')\n",
"pospatch = mpatches.Patch(color='orange', label='e+')\n",
"#plt.legend(handles=[elepatch,pospatch])\n",
"plt.text(0.5,565,\"e-\",size=20)\n",
"plt.text(3.5,565,\"e+\",size=20)\n",
"\n",
"plt.suptitle(\"Uncorrelated Spins\",fontsize=20)\n",
"plt.ylim([400,600])\n",
"plt.xlim([-1,5])\n",
"plt.xticks([0.125,0.85,3.125,3.85],[\"down\",\"up\",\"down\",\"up\"])\n",
"plt.tick_params(axis='both',labelsize=15)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.figure.Figure at 0x7f7490130940>"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEXCAYAAACu1P9TAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAHv9JREFUeJzt3XmYHVWZ+PFvk7DFkIWgyGoElEBQcGQcYX5CIyIybA4KQXBpcFgGR+Wn4gCyNCrKIoiKDuACbjNs4gLIImgDCgii7AQZoNmCrEkgC4SEnj/ec+261XW7773pzna+n+fpp/ueOlV1bvXtt06951Q1SJIkSZIkSZIkSZIkSZIkSVLTeoGHl3YjhkEvi/8+JgOvAucubmOG0JX287ER3o+atNLSbsAKbArwLeBuYDbwMvAEcBlwILDK0mvaCqmHCC6N9KWvZcGJRFtPbqLuOanup9Pr4Xwfi7udTqJtxw+y/WXpuEsj4jhgEfHH8HvgDOBLwHeB+1P5rUutdSumHuKYN/LG9LUsmEy0dQYwepB6rwFeAOYBE1LZcLyPycRn8AeLuZ3OtJ3jGiwfB7w5fZdWSEcTfwS9wD82qLMzcM2SalAmehg84C9rriI+J/86SJ2Ppzo/HuZ9T2Z4A36jHr60QpsMLABeAjYfom5VSmcf4HoiBTQPuBM4skHdXiKXOwY4FXg07fcB4PMN9rkHcC3wZKr7BBEo/72i7prAV4H7UltmESepnSrqdtGfq31f2ubsVLYuEYj/3KBNAFekusVj1gX8DHgo7X82cbW0f2ndyWndqq/fFer1Up37XpU4xncBc9N+rgf2rqhb29e56efzgWeB+cQV266DvMeyD6Rt/XqQOjenOu8qlPUyfO+jHPDfDJwE/Al4hviM9AJnA+uV6p5H4+O+XarTReMc/tuJ3+/Thf18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ib.figure.Figure at 0x7f74897bf128>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<matplotlib.figure.Figure at 0x7f7490130940>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# How many violations of angular momentum would be measured?\n",
"\n",
"# From running several simulations, it's evident a violation in the \n",
"# conservation of angular momentum would be measured half of the time.\n",
"# We can conclude that the information that the entangled particles are in\n",
"# orthogonal spin states is instantaneously agreed once a measurement\n",
"# is made.\n",
"\n",
"violations = 0\n",
"\n",
"for trial in range(0,1000):\n",
" elespin = np.random.randint(0,2)\n",
" posspin = np.random.randint(0,2)\n",
" if elespin == 0:\n",
" elespin = np.matrix('0 1')\n",
" else:\n",
" elespin = np.matrix('1 0')\n",
" if posspin == 0:\n",
" posspin = np.matrix('0 1')\n",
" else:\n",
" posspin = np.matrix('1 0')\n",
" \n",
" elespin.transpose()\n",
" posspin.transpose()\n",
" chi_squared = elespin*np.matrix('1; 0')*posspin*np.matrix('0; 1') - posspin*np.matrix('1; 0')*elespin*np.matrix('0; 1')\n",
" \n",
" if chi_squared == 0:\n",
" violations = violations + 1\n",
"\n",
"zeroes = np.zeros(violations,dtype=int)\n",
"ones = np.full((1000-violations),1,dtype=int)\n",
"result = np.concatenate((ones,zeroes))\n",
"\n",
"plt.ylim([400,600])\n",
"plt.xlim([-1,2])\n",
"plt.xticks([0.125,0.85],[\"violation\",\"adherence\"])\n",
"plt.tick_params(axis='both',labelsize=15)\n",
"plt.suptitle(\"Conservation Violations\",fontsize=20)\n",
"plt.hist([result],bins=4)\n",
"plt.figure()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.figure.Figure at 0x7fb39afb7128>"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Bell's Experiment took this a step further, to rule out locality \n",
"# completely. Establish the detectors to \"float\" such that they \n",
"# measure the components of the spins of the electron and positron \n",
"# along a unit vector a or b, with angles phi_a and phi_b, \n",
"# respectively. Compute a product P of the spins in units of hbar/2. \n",
"# This will give +/-1. \n",
"\n",
"# / pi0 \\\n",
"# /e- <------ ------> e+\\\n",
"\n",
"# QM predicts P(a,b) = -a dot b, the expectation value of the product \n",
"# of the spins.\n",
"\n",
"# In 1964, Bell derived the Bell inequality for a local hidden variable\n",
"# theory: abs(P(a,b) - P(a,c)) <= 1 + P(b,c)\n",
"\n",
"# For any local hidden variable theory, the Bell inequality must hold. \n",
"# It introduces a third unit vector c, which is any other unit vector \n",
"# than a or b.\n",
"\n",
"# Does the quantum mechanical prediction violate the Bell inequality?\n",
"# Testing several detector configurations in a plane, systematically \n",
"# from 0 to pi, we determine whether the QM prediction is consistent \n",
"# with a local hidden variable theory.\n",
"\n",
"violations = 0\n",
"trials = 0\n",
"for step_a in range(0,6):\n",
" for step_b in range (0,6):\n",
" phi_a = step_a/6*np.pi\n",
" phi_b = step_b/6*np.pi\n",
" phi_c = phi_a - 0.5*phi_b\n",
" P_ab = -1 * np.cos(phi_a - phi_b)\n",
" P_ac = -1 * np.cos(phi_a - phi_c)\n",
" P_bc = -1 * np.cos(phi_b - phi_c)\n",
" \n",
" bell_lhs = np.abs(P_ab - P_ac)\n",
" bell_rhs = 1 + P_bc\n",
" \n",
" if bell_lhs > bell_rhs:\n",
" violations = violations + 1\n",
" \n",
" trials = trials + 1\n",
" \n",
"zeroes = np.zeros(violations,dtype=int)\n",
"ones = np.full((trials-violations),1,dtype=int)\n",
"result = np.concatenate((ones,zeroes))\n",
"\n",
"plt.ylim([trials/2-10,trials/2+10])\n",
"plt.xlim([-1,2])\n",
"plt.xticks([0.125,0.85],[\"violation\",\"adherence\"])\n",
"plt.tick_params(axis='both',labelsize=15)\n",
"plt.suptitle(\"Hidden Locality Violations\",fontsize=20)\n",
"plt.hist([result],bins=4)\n",
"plt.figure()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.figure.Figure at 0x7fb39beac240>"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# It is seen that the QM prediction disagrees with a local hidden \n",
"# variable theory in a significant number of configurations.\n",
"\n",
"# On average, for random orientations between 0 and pi, how often? \n",
"# After running several trials, it appears to be about half of the, \n",
"# which is what one would expect from the quantum mechanical\n",
"# prediction.\n",
"\n",
"violations = 0\n",
"trials = 0\n",
"for rand_a in range(0,10):\n",
" for rand_b in range (0,10):\n",
" phi_a = np.random.rand(1)*np.pi\n",
" phi_b = np.random.rand(1)*np.pi\n",
" phi_c = phi_a - 0.5*phi_b\n",
" P_ab = -1 * np.cos(phi_a - phi_b)\n",
" P_ac = -1 * np.cos(phi_a - phi_c)\n",
" P_bc = -1 * np.cos(phi_b - phi_c)\n",
" \n",
" bell_lhs = np.abs(P_ab - P_ac)\n",
" bell_rhs = 1 + P_bc\n",
" \n",
" if bell_lhs > bell_rhs:\n",
" violations = violations + 1\n",
" \n",
" trials = trials + 1\n",
"\n",
"zeroes = np.zeros(violations,dtype=int)\n",
"ones = np.full((trials-violations),1,dtype=int)\n",
"result = np.concatenate((ones,zeroes))\n",
"\n",
"plt.ylim([trials/2-10,trials/2+10])\n",
"plt.xlim([-1,2])\n",
"plt.xticks([0.125,0.85],[\"violation\",\"adherence\"])\n",
"plt.tick_params(axis='both',labelsize=15)\n",
"plt.suptitle(\"Hidden Locality Violations\",fontsize=20)\n",
"plt.hist([result],bins=4)\n",
"plt.figure()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"# The prediction (Bell's inequality) made by assuming a local hidden\n",
"# variable is violated by a significant number of the possibile \n",
"# bborientations. This simulation cannot determine which theory is\n",
"# correct, but the QM prediction has been confirmed through experiment.\n",
"# No hidden local variable holds actionable information about the \n",
"# state. Entangled states retain their entanglement in a non-local \n",
"# nature."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}