{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## QuTiP Lecture: Single-photon Interference" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Authors: Amélie Orban (Editor), Inga Schöyen, Alessandro Delmonte, Alexander Rihane. \n", "
Based on the project Simulating Single Photon Interference using QuTiP (Quantum Toolbox in Python) carried out in June 2021 at Maastricht University, Maastricht Science Programme.\n", "
Last updated: 09/11/21." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "import matplotlib.pyplot as plt\n", "import qutip\n", "from numpy import pi, exp, cos, sin, sqrt, random\n", "from qutip import Qobj, basis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Table of Contents\n", "* [Introduction](#section0)\n", "* [1. Theoretical Background](#section1)\n", "* [2. Coding the constitutive elements](#section2)\n", "* [3. Simulation of Single-Photon Interference Experiment](#section3)\n", "* [4. Variations of Single-Photon Interference Experiment](#section4)\n", "* [Conclusion and Takeaways](#section5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Introduction " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Wave-particle duality is one of the key concepts of quantum mechanics and it illustrates the fact that every quantum particle or object can be described using both particle and wave properties. Neither of these classical concepts can fully describe quantum objects on its own.\n", "\n", "In a similar manner to Thomas Young's double-slit experiment, originally carried out in 1801, the wave-particle duality of light can be observed by performing a single-photon interference experiment, or in this case, simulation. The individual *particle*-like photons interfere with themselves, which is an intrinsically *wave*-like property, thus exhibiting both particle and wave characteristics at the same time." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This lecture investigates the phenomenon of single-photon interference by creating a simulation of a quantum optical experiment in which single photons go through a polarisation interferometer.\n", "* As mentionned, the experiment to be simulated is similar to Young‘s, in that it also produces interference by allowing a photon to take two separate paths. In a classical sense, a beam of light is split into two separate waves, one of which will travel a different path length, to then be recombined into a single wave by using beam splitters and a polarization analyzer.\n", "* Varying the path lengths results in a phase shift, which creates an interference pattern.\n", "* Applying this classical understanding to the case under study, a single photon, which is an indivisible packet of light, would have to be ‘split’ into two ‘waves’ for an interference pattern to occur. Because the photons are sent through the path individually and cannot be split any further, it seems that they cannot interfere with each other. \n", "* But they do interfere! The canonical understanding of the single-photon interference is that the photon’s probability wave interferes with itself, in opposition to interference happening between two distinct states." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1. Theoretical Background " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This section presents the setup of the single-photon interference experiment from a theoretical perspective, and details the different optical elements that must be simulated. The mathematical expression of each element will also be presented, in the form of Jones matrices acting as operators on the given quantum state.\n", "\n", "The setup and corresponding theory of this single photon interference experiment closely follows the work of Mark Beck in \"Quantum Mechanics, Theory and Experiment\" (*Beck, M. (2012). Quantum mechanics, theory and experiment. Oxford University Press.*), more specifically Experiment 6 of Section 3." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Half-wave plate $\\frac{\\lambda}{2}$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A wave plate is used to modify the polarization of a wave, using the fact that its effective index of refraction depends on the polarization of the incident wave.\n", "* A wave plate has two orthogonal axes. The fast axis represents the direction with the lower index of refraction as light polarized along that direction propagates faster, and the slow axis, orthogonal to the fast axis, represents the direction with the higher index of refraction.\n", "* This difference in indices of refraction leads to the orthogonal components of the wave (polarization of a wave can always be decomposed into orthogonal components) acquiring different phase shifts when propagating through the material, resulting in an overall relative phase shift between the two components.\n", "* A wave plate makes use of this relative phase shift between the components of the wave to modify its overall polarization.\n", "\n", "In this case, a half-wave plate is used, for which the relative phase shift between the fast and slow axes corresponds to a half wavelength shift.\n", "* The fast axis of the half-wave plate is positioned in order to create a $45^\\circ$ angle with the horizontal plane. \n", "* Half of the incident wave is thus polarized along the fast axis and result in a $|+45\\rangle$ polarization state, while the other half is polarized along the slow axis into a $|-45\\rangle$ state, with a relative phase shift of $\\pi$.\n", "* The purpose of a half-wave plate is to rotate the linear polarization of some wave by an arbitrary angle (wave does *not* get split into its orthogonal components), depending on the orientation of the wave plate. \n", "\n", "The mathematical expression of a half-wave plate at $45^\\circ$ is the following:\n", "\n", "\$$\n", "J_{\\lambda/2 \\hspace{1mm} 45^\\circ} = \\left[\\begin{array}{cc} \\cos(2\\cdot45) & \\sin(2\\cdot45) \\\\ \\sin(2\\cdot45) & -\\cos(2\\cdot45) \\end{array}\\right] = \\left[\\begin{array}{cc} 0 & 1 \\\\ 1 & 0 \\end{array}\\right]\n", "\$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Polarization analyzers PA$_{HV}$ and PA$_{45}$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A polarization analyzer, also called beam displacing polarizer or polarizing beam splitter, has the property that it can both *split* a beam into two orthogonal components, and *displace* each of these components differently. \n", "* A general wave composed of orthogonal polarization components gets split into two waves travelling in different directions. When the faces of the polarization analyzer are parallel, the outgoing waves will emerge parallel, with a displacement separating them.\n", "\n", "If the polarization analyzer is positioned perpendicular to the horizontal plane, in such a way that waves propagating horizontally are normally incident, the general waves get split into vertical and horizontal components and it is referred to as a PA$_{HV}$. \n", "* In this case, the $|V\\rangle$ polarization state gets transmitted without bending, while the $|H\\rangle$ gets bent when entering and leaving the PA$_{HV}$ such as to emerge parallel to $|V\\rangle$, but displaced and phase-shifted. \n", "* This polarization analyzer can also be used to recombine orthogonal components of a beam. The process simply gets reversed. \n", "* The Jones matrix representing a PA$_{HV}$ is composed of three other Jones matrices: the horizontal polarizer, vertical polarizer and phase-shifting matrices. This combination is made such that it represents the splitting and the phase-shifting caused by this element, and is as follows: \n", "\n", "\$$\n", "J_{PA_{HV}} = J_{V} + J_{\\phi}J_{H} = \\left[\\begin{array}{cc} 0 & 0 \\\\ 0 & 1 \\end{array}\\right] + \\left[\\begin{array}{cc} e^{i \\phi} & 0 \\\\ 0 & 1 \\end{array}\\right]\\left[\\begin{array}{cc} 1 & 0 \\\\ 0 & 0 \\end{array}\\right] = \\left[\\begin{array}{cc} e^{i \\phi} & 0 \\\\ 0 & 1 \\end{array}\\right]\n", "\$$\n", "\n", "If one were to rotate a PA$_{HV}$ by $45^\\circ$, a general wave incident on such a polarization analyzer would be analyzed into $|+45\\rangle$ and $|-45\\rangle$ polarization components, making it a PA$_{45}$. \n", "* In this case, the $|+45\\rangle$ polarization state gets transmitted without bending, while the $|-45\\rangle$ gets bent when entering and leaving the PA$_{45}$ such as to emerge displaced and parallel to $|+45\\rangle$. \n", "* The Jones matrix for PA$_{45}$ is also a combination of other matrices: the linear polarizer with transmission axis at $45^\\circ$, linear polarizer with transmission axis at $-45^\\circ$ and phase-shifting matrices. The mathematical expression is thus: \n", "\n", "\$$\n", "\\begin{split}\n", "J_{PA_{45}} &= J_{+45} + J_{\\phi}J_{-45} \\\\\n", "&= \\left[\\begin{array}{cc} \\cos^2(45) & \\cos(45)\\sin(45) \\\\ \\cos(45)\\sin(45) & \\sin^2(45) \\end{array}\\right]\n", "+ \\left[\\begin{array}{cc} e^{i \\phi} & 0 \\\\ 0 & 1 \\end{array}\\right]\\left[\\begin{array}{cc} \\cos^2(-45) & \\cos(-45)\\sin(-45) \\\\ \\cos(-45)\\sin(-45) & \\sin^2(-45) \\end{array}\\right] \\\\\n", "&= \\left[\\begin{array}{cc} \\frac{1}{2}(e^{i \\phi} +1) & \\frac{1}{2}(1-e^{i \\phi}) \\\\ 0 & 1 \\end{array}\\right]\n", "\\end{split}\n", "\$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Complete Setup" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The setup of the experiment, represented in the figure below, is as follows.\n", "* A photon is prepared in the $|+45\\rangle$ state and is sent through an interferometer, composed of a PA$_{HV}$, a half-wave plate, another PA$_{HV}$, and finally a PA$_{45}$.\n", "* The first polarization analyzer PA$_{HV}$ is used to split the incident photon into two orthogonal polarization components $|H\\rangle$ and $|V\\rangle$, and displace them accordingly.\n", "* Each of the components emerges parallel to the other and then goes through the half-wave plate. Inserting the half-wave plate in the polarization interferometer allows for the equalization of the path lengths of the two arms.\n", "* As already mentioned, a half-wave plate with its fast axis rotated to $45^\\circ$ causes half of the incident wave to be polarized into a $|+45\\rangle$ state (fast axis) and the other half into a $|-45\\rangle$ state (slow axis), with a phase shift of $\\pi$. In this specific setup, this implies that the polarization of the two components gets \"switched\" from $|H\\rangle$ to $|V\\rangle$ and vice-versa as the linear polarizations are rotated by $90^\\circ$, making the overall behaviour of the two arms symmetric with equalized path lengths and no relative phase shift (for now).\n", "* The second polarization analyzer PA$_{HV}$ is then used to recombine the components.\n", "* Finally, the use of a PA$_{45}$ at the end of the interferometer allows for the splitting of the final photon into $|+45\\rangle$ and $|-45\\rangle$ polarization states, providing two different paths and two different ports for the output. In this way, it is easy to measure how the intensity of each of the outputs gets modulated.\n", "\n", "This apparatus acts as an interferometer, and the final super-positioned states should interfere producing an interference pattern and output intensities that depend on the relative phase between them (equivalently, on the path length difference).\n", "* This relative phase (initially zero) can be modified using the PA$_{HV}$'s.\n", "* One (or both) of the two polarization analyzers can be tilted in order to vary the relative phase between the two arms, as the relative phase shift is proportional to the tilt angle of the PA$_{HV}$ (because it modifies the path lengths).\n", "* When the phase is $\\phi = 0$, there should be constructive interference, with all of the output coming from the $+45^\\circ$ port, while when the phase is $\\phi = \\pi$, there should be destructive interference, with all of the output coming from the $-45^\\circ$ port.\n", "* Note that this interference is visible because of the last element, the PA$_{45}$, as it projects the two, initially orthogonal (no possibility of displaying interference), polarization states onto the $+45^\\circ$ and $-45^\\circ$ axes where they do interfere." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that a single photon is sent through these optical elements, making the process quantum mechanical in nature. This requires for an important distinction, when it comes to the splitting of the state into orthogonal components.\n", "* A classical wave is split into its orthogonal components deterministically, with the wave actually getting divided into two components, each *in proportion* to the coefficient of the corresponding polarization state in the general polarization ($\\psi = c_H |H\\rangle + c_V |V\\rangle$).\n", "* On the other hand, when it comes to single photons, as they cannot be broken down any further, they are 'split' randomly and it is not possible to determine with certainty which port any photon will emerge from.\n", "* The proportion of the basis states $|H\\rangle$ and $|V\\rangle$ in a general state $\\psi$ describes the *probability* of the photon taking that corresponding path.\n", "* Note also that the state of the photon never actually gets 'split' and it stays as one single state throughout the entire interferometer." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2. Coding the constitutive elements " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Basis vectors\n", "Code the polarization basis vectors, for the bases $H/V$ and $+/-45$. They can then be used to code any polarization state, since any state can be expressed as a linear combination of basis vectors." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# HV basis\n", "\n", "# horizontal polarization\n", "H = basis(2, 0)\n", "# vertical polarization\n", "V = basis(2, 1)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# +45/-45 basis (in terms of HV basis)\n", "\n", "# +45 polarization\n", "p45 = 1 / sqrt(2) * (H + V)\n", "# -45 polarization\n", "n45 = 1 / sqrt(2) * (H - V)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Polarization analyzer (HV) n°1\n", "It induces a phase shift on the H polarization relative to V polarization, because of the difference in the path lengths of the two arms of the interferometer. \n", "
In the case of a single photon, the state doesn't actually get split and there is only a single state throughout the apparatus, so the PA$_{HV}$ only affects the phase of the components." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\\begin{equation*}\\left(\\begin{array}{*{11}c}(0.707+0.707j) & 0.0\\\\0.0 & 1.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\n", "Qobj data =\n", "[[0.70710678+0.70710678j 0. +0.j ]\n", " [0. +0.j 1. +0.j ]]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Polarization analyzer (HV) n°1\n", "\n", "phaseshift1 = pi / 4 # CONSTANT\n", " # should depend on real size of the setup (here: arbitrarily chosen)\n", "PA_HV1 = Qobj([[exp(1j * phaseshift1), 0], [0, 1]])\n", "PA_HV1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Half-wave plate $\\frac{\\lambda}{2}$\n", "In this case, the fast axis makes an angle of $45^\\circ$ with the horizontal.\n", "
For a single photon, the effect of going through such a half-wave plate is that the $|H\\rangle$ and $|V\\rangle$ polarization components are switched." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\\begin{equation*}\\left(\\begin{array}{*{11}c}0.0 & 1.0\\\\1.0 & 0.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = True\n", "Qobj data =\n", "[[0. 1.]\n", " [1. 0.]]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Half-wave plate\n", "\n", "θ = pi / 4 # fast axis orientation\n", " # (!) numpy calculates with rad\n", "halfwave = Qobj([[cos(2 * θ), sin(2 * θ)], [sin(2 * θ), -cos(2 * θ)]])\n", "\n", "halfwave.tidyup() # removes very small elements (numerical artifacts from the finite precision of the computer)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Polarization analyzer (HV) n°2\n", "As before, it induces a phase shift on the H polarization relative to V polarization.\n", "* Initially, the value of the phase shift induced by PA$_{HV2}$ should be set to the same value as for PA$_{HV1}$. The initial state of our setup has both of the PA$_{HV}$s in the exact same position (both tilted in the same way), with the overall relative phase shift being zero.\n", "* The phase shift induced by PA$_{HV2}$ can then be changed in order to observe different levels of interference.\n", "* A difference in the phase shifts induced by the two polarization analyzers causes the *relative* phase shift between the components to change, and it is this *relative* phase shift that is responsible for the interference." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\\begin{equation*}\\left(\\begin{array}{*{11}c}(0.707+0.707j) & 0.0\\\\0.0 & 1.0\\\\\\end{array}\\right)\\end{equation*}" ], "text/plain": [ "Quantum object: dims = [[2], [2]], shape = (2, 2), type = oper, isherm = False\n", "Qobj data =\n", "[[0.70710678+0.70710678j 0. +0.j ]\n", " [0. +0.j 1. +0.j ]]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Polarization analyzer (HV) n°2\n", "\n", "phaseshift2 = pi / 4 # CHANGE TO CHANGE INTERFERENCE\n", " # should depend on real size of the setup\n", "PA_HV2 = Qobj([[exp(1j * phaseshift2), 0], [0, 1]])\n", "\n", "PA_HV2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Polarization analyzer (45)\n", "The PA$_{45}$ acts on the photon such that it has to come out as a $|+45\\rangle$ polarized photon or as a $|-45\\rangle$ polarized photon.\n", "* Based on the coefficients of each polarization basis components constituting the general polarization state, the probability of the photon getting out in that corresponding state can be computed.\n", "* It should also induce a phase shift on $|-45\\rangle$ component with respect to $|+45\\rangle$ as a result of different path lengths (as seen in the theory section), but this effect is ignored as this is the last optical element, and the goal is to determine whether the final state of the photon is $|-45\\rangle$ or $|+45\\rangle$, not which one \"gets out first\".\n", "* The role of this polarization analyzer is to determine the outcome of the experiment.\n", "* The single photon interference happens just before the photon goes through this last polarization analyzer, e.g. when the states are 'recombined' after the second PA$_{HV}$ (this is not to be interpreted too literally because, as previously mentioned, the state of the photon never actually gets split and it stays as one state throughout the apparatus), and thus phase shift does not have an importance anymore." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# Polarization analyzer (45)\n", "\n", "# linear Polarizer, transmission axis +45 wrt horizontal\n", "θ = pi / 4\n", "Pp45 = Qobj([[cos(θ)**2, cos(θ) * sin(θ)], [cos(θ) * sin(θ), sin(θ)**2]])\n", "# linear Polarizer, transmission axis -45 wrt horizontal\n", "θ = -pi / 4\n", "Pn45 = Qobj([[cos(θ)**2, cos(θ)*sin(θ)], [cos(θ)*sin(θ), sin(θ)**2]])\n", "\n", "def PA_45(vector):\n", " p45_comp = Pp45 * vector # retrieve only +45 component\n", " n45_comp = Pn45 * vector # retrieve only -45 component\n", " return p45_comp, n45_comp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3. Simulation of Single-Photon Interference Experiment " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Define initial variables:**\n", "* One has to choose the initial minimal and maximal values of the phase shift induced by PA$_{HV2}$, along with the number of steps to be effectuated between these values. These different values will be run through during the simulation and the experiment will be carried out for each of them in order to collect data to determine what the relationship is between the interference and the relative phase shift. The higher the number of steps is, the more precise the final result will be.\n", "* The number of iterations, for one value of the phase shift, also has to be defined. Since the photon getting out of the interferometer in a certain polarization state is governed by probabilities, it is important to carry out the same process numerous times to get a good sample and a good representation of the results." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "psi_0 = p45 # define the initial state (+45 vector)\n", "\n", "phaseshift2_init = pi / 4 # initial value\n", "phaseshift2_max = 8 * pi\n", "n = 100 # resolution of φ (amount of steps)\n", "step = (phaseshift2_max - phaseshift2_init)/n # interval divided by number of small steps we want\n", "N_init = 1000 # number of iterations (range(N) -> 0 to N-1, both included)\n", "\n", "# # create x- and y- coords. arrays to store the values needed to plot output graph\n", "x_coords = [] # relative phase shift\n", "y1_coords = [] # amount of photons in +45\n", "y2_coords = [] # amount of photons in -45" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Create a *for loop* to run through all of the possible values for the phase shift considered for PA$_{HV2}$:**\n", "
In this loop, the passage of the photon through the interferometer is simulated using an effective matrix. The PA$_{45}$ is used after that to compute the probability related to each of these polarization states, and eventually to get the results of the experiment.\n", "* 'Output' values are first defined to keep track of the results of the numerous iterations that are performed to measure the final state of the photon for a given phase shift. They are used to count the amount of photons that come out as $|+45\\rangle$ and the amount that come out as $|-45\\rangle$.\n", "* The phase shift is also defined and directly added to the array of x-coordinates.\n", "* With this phase shift, PA$_{HV2}$ can be defined, which allows for the definition of the final effective matrix. The effective matrix regroups all of the operators acting on the photon (in the correct order) in a single matrix.\n", "* This is then multiplied with the initial state of the photon, to get the final state that will be passed through the PA$_{45}$.\n", "* The $|+45\\rangle$ and $|-45\\rangle$ components are then retrieved and used to compute the final probabilities. To do so, the norm of the vector of each component is computed and then squared.\n", "\n", "Inside the first *for loop* is another loop performing what can be considered as the final measurement. Whether the photon comes out in a $|+45\\rangle$ or $|-45\\rangle$ polarization state is a random process that depends on the corresponding probabilities.\n", "* To simulate this, a random number is generated between 1 and 100 (100 because $100\\%$ of the photons need to come out in either one of the states).\n", "* If the number is smaller or equal to the probability (in percentage form) related to the $|+45\\rangle$ component, the photon is measured to have come out in the $|+45\\rangle$ state. Otherwise, it is measured in the $|-45\\rangle$ state.\n", "* These measurements are then accounted for and stored in the 'output' values that were previously defined.\n", "* When all of the iterations are performed, the output values are added to the arrays corresponding to different y-coordinates (one for $|+45\\rangle$ photons and one for $|-45\\rangle$ photons).\n", "* They are then reinitialized at the beginning of the first *for loop*, before the entire process starts anew for another value of the phase shift." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "for i in range(n + 1):\n", " output_p45 = 0\n", " output_n45 = 0\n", "\n", " phaseshift2 = phaseshift2_init + i * step\n", " x_coords.append((phaseshift2 - phaseshift1) / pi) # add realtive phase shift to x coords\n", " PA_HV2 = Qobj([[exp(1j * phaseshift2), 0], [0, 1]]) # create corresponding PA_HV2\n", " EffM = PA_HV2 * halfwave * PA_HV1 # define the effective matrix\n", "\n", " psi_final = EffM * psi_0 # apply the effective matrix to the initial state to get the final state\n", "\n", " psi_p45 = PA_45(psi_final)[0] # retrieve +45 and -45 components\n", " psi_n45 = PA_45(psi_final)[1]\n", "\n", " proba_p45 = round(psi_p45.norm()**2, 5) # probability is rounded up to five decimals to avoid machine precision artifacts\n", " proba_n45 = round(psi_n45.norm()**2, 5)\n", "\n", " for j in range(N_init):\n", " a = random.randint(1, 100) # generates random number between 1 and 100 (both included), 100 because 100% of the photons need to come out in either +45 or -45 state\n", " if a <= proba_p45 * 100:\n", " output_p45 = output_p45 + 1\n", " else:\n", " output_n45 = output_n45 + 1\n", "\n", " y1_coords.append(output_p45)\n", " y2_coords.append(output_n45)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Create output plot:**\n", "