<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Computational Physics Notes</title>
<link>https://areanraines.com/</link>
<atom:link href="https://areanraines.com/index.xml" rel="self" type="application/rss+xml"/>
<description>Worked derivations, intuition, and reproducible code.</description>
<generator>quarto-1.10.18</generator>
<lastBuildDate>Fri, 24 Jul 2026 00:00:00 GMT</lastBuildDate>
<item>
  <title>Odds that you’re the one</title>
  <dc:creator>Kyle Arean-Raines</dc:creator>
  <link>https://areanraines.com/posts/ayto/</link>
  <description><![CDATA[ 




<section id="odds-that-youre-the-one" class="level1">
<h1>Odds that you’re the one</h1>
<p>A few years ago I was introduced to the reality dating show <a href="https://en.wikipedia.org/wiki/Are_You_the_One">Are You The One</a>. Aside from being drama-filled, quality television, it also had an interesting probability component.</p>
<p>I decided to do some calculations, and eventually posed a problem on <code>r/mathriddles</code>, the text of which I’ll quote here:</p>
<blockquote class="blockquote">
<p>There are 10 male contestants and 10 female contestants. Prior to the start of the show, a “matching algorithm” pairs people according to supposed compatibility. There are 10 such matches, each a man matched with a woman, and none of the contestants know which pairings are “correct” according to the algorithm.</p>
<p>Every episode there is a matching ceremony where everyone matches up with someone of the opposite gender. After everyone finds a partner, the number of correct matches is revealed [à la Mastermind]. However, which matches are correct remains a mystery. There are 10 such ceremonies, and if the contestants can get all 10 matches correct by the tenth ceremony they win a prize.</p>
<p>There is another way they can glean information, called the Truth Booth, which greatly increases their odds. But I’ll leave this part out for the sake of this problem.</p>
<p>Onto the problem:</p>
<p><strong>The first matching ceremony just yielded N correct matches. In the absence of any additional information, and using an optimal strategy (they’re trying to win), what is the probability that they will get all 10 correct on the following try?</strong></p>
</blockquote>
<p>If you’re familiar with probability theory, particularly combinations and permutations with fixed points, you may be able to solve this. It’s pretty tricky! I had to look something up to get the final result.</p>
<p>Here’s a hint. Given a sequence of <img src="https://latex.codecogs.com/png.latex?n"> objects, the total number of ways you can permute them where none of the objects were in their initial position - defined as <img src="https://latex.codecogs.com/png.latex?D_n"> - is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AD_n%20=%20%5Cleft%5B%5Cfrac%7Bn!%7D%7Be%7D%5Cright%5D%0A"></p>
<p>where the brackets denote the closest integer to the inner term, <img src="https://latex.codecogs.com/png.latex?n!/e">. Yes that’s <img src="https://latex.codecogs.com/png.latex?e"> as in Euler’s number! It appears in so many different fields, and here it is in probability theory.</p>
<section id="step-1" class="level2">
<h2 class="anchored" data-anchor-id="step-1">Step 1</h2>
<p>We’ll now work toward calculating the probability of getting none of the matches correct.</p>
<p>Imagine you line up all 10 women, each facing forward. Next choose some random ordering for the men. Each man will face one of the women, with some small probability that it’s their match. The point here is that we can encode a pairing of 10 couples by a single sequence if we fix the position of each woman for the whole calculation. So Susie is always first in line, then Esther, then Ethyl, then Methyl, etc. Shuffling (permuting) just the men can give all possible pairings. How many are there?</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://areanraines.com/diagrams/ayto/pairing-permutation.svg" class="img-fluid figure-img"></p>
<figcaption>Pairing permutation with 2 correct out of 10</figcaption>
</figure>
</div>
<p>It’s the number of ways to permute 10 objects, or <img src="https://latex.codecogs.com/png.latex?10!"> (factorial: 10 times 9 times 8… all the way to 1). Only one of these permutations contains all the correct matches. So the probability of getting it right with a random ordering is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cfrac%7B1%7D%7B10!%7D%20=%20%5Cfrac%7B1%7D%7B3628800%7D%20%5Capprox%200.0000003%0A"></p>
<p>giving a 0.00003% chance. That’s vanishingly small!</p>
<p>Exercise for the reader: can you get 9 out of 10 couples right? Why or why not?</p>
</section>
<section id="step-2" class="level2">
<h2 class="anchored" data-anchor-id="step-2">Step 2</h2>
<p>Using the formula from before, the number of ways to get none of the matches correct is the number of permutations with none of them in their original (correct) spots:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AN(0)%20=%20D_%7B10%7D%20=%20%5Cleft%5B%5Cfrac%7B10!%7D%7Be%7D%5Cright%5D%20=%201334961%0A"></p>
<p>So the probability of getting none right is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap(0)%20=%20%5Cfrac%7BN(0)%7D%7B10!%7D%20=%20%5Cfrac%7B%5Cleft%5B%5Cfrac%7B10!%7D%7Be%7D%5Cright%5D%7D%7B10!%7D%20%5Capprox%20.368%20=%2036.8%5C%25%0A"></p>
<p>So you have a roughly 37% chance of getting none right, which means a 63% chance of at least one match! Kind of surprising that you’re more likely to get a match than not.</p>
</section>
<section id="step-3" class="level2">
<h2 class="anchored" data-anchor-id="step-3">Step 3</h2>
<p>The next step is to calculate the probability of getting exactly N matches right. Starting with the number of ways to get exactly one couple right, it’s the number of ways to choose 1 couple among the 10 (there are 10 such ways) multiplied by <img src="https://latex.codecogs.com/png.latex?D_9"> (9 couples left over, all must be incorrectly matched). Thus,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap(1)%20=%20%7B10%20%5Cchoose%201%7D%20%5Cfrac%7B%5Cleft%5B%5Cfrac%7B9!%7D%7Be%7D%5Cright%5D%7D%7B10!%7D%20%5Capprox%20.368%20=%2036.8%5C%25%0A"></p>
<p>That’s the same answer we got above, to every digit that matters! Weird - so the probability of getting one match is (almost exactly) the same as the probability of getting no matches. In fact they’re not <em>quite</em> equal - using the exact series for <img src="https://latex.codecogs.com/png.latex?D_n">, they differ by precisely <img src="https://latex.codecogs.com/png.latex?%5Cfrac%7B1%7D%7B10!%7D%20%5Capprox%200.0000003">, invisible at this precision - and <strong>the result barely depends on the size of the group.</strong> Both probabilities converge to <img src="https://latex.codecogs.com/png.latex?e%5E%7B-1%7D"> as the group size grows, and they get there so fast that the answer would look identical even if there were 100 people being matched up.</p>
</section>
<section id="step-4" class="level2">
<h2 class="anchored" data-anchor-id="step-4">Step 4</h2>
<p>Finally, we put it all together by generalizing - if we got <img src="https://latex.codecogs.com/png.latex?N"> correct matches the previous round, we’ll want to take a guess at which <img src="https://latex.codecogs.com/png.latex?N"> were correct and fix <img src="https://latex.codecogs.com/png.latex?N"> couples for the next guess. The number of ways to choose <img src="https://latex.codecogs.com/png.latex?N"> from a group of 10 couples then permute the rest with no correct matches is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AN(%5Cmathrm%7BN%7D)%20=%20%7B10%20%5Cchoose%20N%7D%5Cleft%5B%5Cfrac%7B(10%20-%20N)!%7D%7Be%7D%5Cright%5D%0A"></p>
<p>Given that we observed <img src="https://latex.codecogs.com/png.latex?N"> correct, the true matching is equally likely to be any one of these <img src="https://latex.codecogs.com/png.latex?%7B10%20%5Cchoose%20N%7D%5Cleft%5B%5Cfrac%7B(10%20-%20N)!%7D%7Be%7D%5Cright%5D"> permutations - we have no way to tell them apart. So the best we can do on the next guess is pick one of them, which means the probability of getting all of them correct after fixing <img src="https://latex.codecogs.com/png.latex?N"> couples is just one divided by how many candidates are still in play:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap(10%20%7C%20N)%20=%20%5Cfrac%7B1%7D%7B%20%7B10%20%5Cchoose%20N%7D%5Cleft%5B%5Cfrac%7B(10%20-%20N)!%7D%7Be%7D%5Cright%5D%20%7D%0A"></p>
</section>
<section id="step-5" class="level2">
<h2 class="anchored" data-anchor-id="step-5">Step 5</h2>
<p>Finally-finally, we’ll do some plots, first of the probabilities for getting all 10 right given <img src="https://latex.codecogs.com/png.latex?N"> correct matches; then the probabilities of getting all correct as a function of the size of the group.</p>
<div id="cell-fig-schematic" class="cell" data-execution_count="1">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> ayto</span>
<span id="cb1-3"></span>
<span id="cb1-4">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.2</span>))</span>
<span id="cb1-5">ayto.plot_probability_versus_n_correct(ax)</span>
<span id="cb1-6">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="fig-schematic" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-schematic-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://areanraines.com/posts/ayto/index_files/figure-html/fig-schematic-output-1.svg" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-schematic-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Probability of getting all correct after N correct in the previous round.
</figcaption>
</figure>
</div>
</div>
</div>
<div id="cell-fig-schematic-2" class="cell" data-execution_count="2">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb2-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> ayto</span>
<span id="cb2-3"></span>
<span id="cb2-4">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.2</span>))</span>
<span id="cb2-5">ayto.plot_probability_of_all_versus_n(ax)</span>
<span id="cb2-6">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="fig-schematic-2" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-schematic-2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://areanraines.com/posts/ayto/index_files/figure-html/fig-schematic-2-output-1.svg" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-schematic-2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: Probability of getting all correct for a group of size N.
</figcaption>
</figure>
</div>
</div>
</div>
<p>The full source for this series is on <a href="https://github.com/kareanra/physics-blog">GitHub</a>. The derivations, code, and prose are all mine. However, I did consult Claude to proofread and for help setting up the project and rendering equations.</p>


<!-- -->

</section>
</section>

 ]]></description>
  <category>probability</category>
  <category>combinatorics</category>
  <category>reality TV</category>
  <guid>https://areanraines.com/posts/ayto/</guid>
  <pubDate>Fri, 24 Jul 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Doppler cooling: using lasers to cool atoms</title>
  <dc:creator>Kyle Arean-Raines</dc:creator>
  <link>https://areanraines.com/posts/laser-cooling/</link>
  <description><![CDATA[ 




<section id="doppler-cooling" class="level1">
<h1>Doppler cooling</h1>
<section id="part-1-the-background" class="level2">
<h2 class="anchored" data-anchor-id="part-1-the-background">Part 1: the background</h2>
<p>When you think about lasers irradiating a surface or object, typically you expect that the object will heat up. This is a reasonable assumption for most cases. However, there is also a way to cool atoms close to absolute zero using one or more lasers. I’ll first give a super quick primer on atomic transitions and the Doppler effect, then we’ll dive into the cooling method and explain why it works.</p>
<section id="atomic-transitions-and-photon-absorption" class="level3">
<h3 class="anchored" data-anchor-id="atomic-transitions-and-photon-absorption">Atomic transitions and photon absorption</h3>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://areanraines.com/diagrams/laser-cooling/doppler-cooling-energy-levels.svg" class="img-fluid figure-img"></p>
<figcaption>Atomic energy levels, absorption, and emission</figcaption>
</figure>
</div>
<p>Atoms have various intrinsic energy levels that their electrons can occupy. These form a discrete ladder of levels, and electrons can jump up or down a rung. Atoms in general can absorb a photon of a certain frequency, provided the photon’s frequency matches the energy difference between two of the atomic energy levels. The photon absorption transfers its momentum to the atom. If the photon was traveling in the same direction as the atom, the atom gains momentum and travels faster. Since temperature is - roughly and simplistically speaking - a measure of the speed of an atom, if the photon was traveling in the same direction as the atom it will increase the “temperature” of the atom. The atom will eventually and spontaneously re-emit a photon in a random direction. The emitted photon will provide a kick in the opposite direction of the photon emission (conservation of momentum). So if the photon emits “backward” with respect to the atom, the kick will increase the speed and temperature of the atom further.</p>
<p>The opposite goes for the case where there’s a head-on collision between the photon and the atom. This will happen if the photon and atom are initially traveling in opposite directions. This will <em>decrease</em> the speed and temperature of the atom. So if we want to cool a group of atoms zipping around in space we’ll want those head-on collisions to occur more frequently. How can we make that happen?</p>
</section>
<section id="the-doppler-effect" class="level3">
<h3 class="anchored" data-anchor-id="the-doppler-effect">The Doppler effect</h3>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://areanraines.com/diagrams/laser-cooling/doppler-effect-wavefronts.svg" class="img-fluid figure-img"></p>
<figcaption>Doppler effect</figcaption>
</figure>
</div>
<p>The Doppler effect as applied to light waves and photons is a phenomenon that occurs from the point of view of an “observer” observing light traveling through space. If the light is traveling toward the observer, the observer will perceive an upward frequency shift as the wavefronts bunch up.</p>
<p>The opposite will occur if the light is moving away - the perceived frequency is lower (redshift). So… how can we exploit this and the above to cool a collection of atoms?</p>
</section>
<section id="putting-it-all-together" class="level3">
<h3 class="anchored" data-anchor-id="putting-it-all-together">Putting it all together</h3>
<p>If we have a laser that is shining light on the atoms from one direction, if we exactly match an atomic transition, we might be equally likely to speed up atoms (moving away from the laser) as slowing them down. Thus, no net cooling effect.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://areanraines.com/diagrams/laser-cooling/red-detuning-resonance.svg" class="img-fluid figure-img"></p>
<figcaption>Laser detuning</figcaption>
</figure>
</div>
<p>On the other hand, what if we tune the laser’s frequency (photons’ frequencies) to be a bit <em>below</em> the atom’s transition energy (spacing between atomic energy levels)? In that case, it’s far more likely for atoms traveling toward the laser light source to absorb the photon and get slowed down. This will serve to cool the atom. This happens due to the Doppler effect - atoms traveling toward the light source see a blueshifted photon frequency, which shifts the photon’s frequency up to match the atomic transition. The photons traveling in the opposite direction will see a redshifted photon, and therefore the frequency will be even lower than the atomic spacing → no absorption occurs.</p>
<p>Eventually the atoms will be traveling much more slowly and so the laser’s frequency will need to be tuned down even further, as the Doppler effect is less pronounced as the atoms get slower and cooler. If you keep tuning the laser down, you can get those atoms extremely cold, and extremely close to absolute zero temperature. In the next post I’ll walk through the math, which will only require high school-level geometry.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://areanraines.com/diagrams/laser-cooling/doppler-cooling-cycle.svg" class="img-fluid figure-img"></p>
<figcaption>Doppler cooling cycle</figcaption>
</figure>
</div>
<p>This can be extended to multiple lasers pointing in different, opposite and orthogonal directions. That way atoms moving away from one laser will be likely to absorb a photon from an opposite-pointing laser.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://areanraines.com/diagrams/laser-cooling/optical-molasses.svg" class="img-fluid figure-img"></p>
<figcaption>Optical molasses</figcaption>
</figure>
</div>
<p>The full source for this series is on <a href="https://github.com/kareanra/physics-blog">GitHub</a>. The derivations, code, and prose are all mine. However, I did consult Claude to proofread and for help setting up the project and rendering equations.</p>


<!-- -->

</section>
</section>
</section>

 ]]></description>
  <category>lasers</category>
  <category>doppler effect</category>
  <category>atomic physics</category>
  <guid>https://areanraines.com/posts/laser-cooling/</guid>
  <pubDate>Sun, 19 Jul 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>The double slit experiment, part 2: the math</title>
  <dc:creator>Kyle Arean-Raines</dc:creator>
  <link>https://areanraines.com/posts/double-slit-part2/</link>
  <description><![CDATA[ 




<section id="the-quantum-double-slit-experiment" class="level1">
<h1>The quantum double-slit experiment</h1>
<section id="part-2-the-math" class="level2">
<h2 class="anchored" data-anchor-id="part-2-the-math">Part 2: the math</h2>
<p>Now let’s get our hands dirty with some math and code. Again, this is pretty advanced stuff, so feel free to skip to the diagrams showing the interference results.</p>
<p>Prerequisites: differential equations, Fourier transforms, Gaussian integrals, vector calculus, and perhaps some basic physics.</p>
<p>Though two of three grad courses I took on quantum mechanics referenced this experiment, the treatment was mostly qualitative, even though rigorous mathematical machinery was subsequently developed throughout the course. Further, we didn’t do much until Quantum II involving path integrals, which is an alternative way of formulating quantum that typically isn’t taught in introductory classes on the subject. But this double-slit problem is actually relatively tractable using this alternative framework. We’ll get to that after walking through some derivations using the Schrödinger approach.</p>
<section id="solution-using-the-schrödinger-equation" class="level3">
<h3 class="anchored" data-anchor-id="solution-using-the-schrödinger-equation">Solution using the Schrödinger equation</h3>
<p>The Schrödinger equation is a second-order partial differential equation that describes the time evolution of a quantum system. In classical mechanics, using the Euler-Lagrange equations gives you a deterministic trajectory of a particle or system through space and time. If you know the initial state of the system at a given time, you can calculate the system state at any subsequent time, provided you know the form of the Lagrangian (energy “function” for the environment the system is in).</p>
<p>In quantum mechanics, there is no such determinism. It is the probabilities of the state being in a state at a given time that evolve according to the equations of “motion.” So here’s the famous Schrödinger equation, (technically speaking, the position- or space-representation of the general equation):</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ai%20%5Chbar%20%7B%5Cfrac%20%7B%5Cpartial%5E2%20%5CPsi(%5Cmathbf%7Br%7D,%20t)%7D%7B%5Cpartial%20t%5E2%7D%7D%20=%20%5Cfrac%7B-%5Chbar%5E2%7D%7B2m%7D%20%5Cnabla%5E2%20%5CPsi(%5Cmathbf%7Br%7D,%20t)%20+%20V%20(%5Cmathbf%7Br%7D,%20t)%20%20%5CPsi(%5Cmathbf%7Br%7D,%20t)%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?%5CPsi"> is the wavefunction, which varies in space and time and <img src="https://latex.codecogs.com/png.latex?V(%5Cmathbf%7Br%7D,%20t)"> is the potential energy. The wavefunction describes the probability of finding a particle at a given point in space at a given time.</p>
<section id="the-setup" class="level4">
<h4 class="anchored" data-anchor-id="the-setup">The setup</h4>
<p>Now let’s make this concrete with our experiment. A free electron leaves the origin traveling in <img src="https://latex.codecogs.com/png.latex?+x"> toward a screen a distance <img src="https://latex.codecogs.com/png.latex?L_1"> away. The screen has two slits: the top slit spans <img src="https://latex.codecogs.com/png.latex?y%20%5Cin%20%5B+a/2,%5C,%20+a/2+b%5D"> and the bottom slit <img src="https://latex.codecogs.com/png.latex?y%20%5Cin%20%5B-a/2-b,%5C,%20-a/2%5D">, so the central barrier between them has height <img src="https://latex.codecogs.com/png.latex?a"> and each opening has height <img src="https://latex.codecogs.com/png.latex?b">.</p>
<div id="cell-fig-schematic" class="cell" data-execution_count="1">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> dslit</span>
<span id="cb1-3"></span>
<span id="cb1-4">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.2</span>))</span>
<span id="cb1-5">dslit.draw_schematic(ax)</span>
<span id="cb1-6">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="fig-schematic" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-schematic-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://areanraines.com/posts/double-slit-part2/index_files/figure-html/fig-schematic-output-1.svg" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-schematic-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Geometry. A Gaussian beam leaves the source and drifts a distance <img src="https://latex.codecogs.com/png.latex?L_1"> to a screen with two slits of height <img src="https://latex.codecogs.com/png.latex?b"> separated by <img src="https://latex.codecogs.com/png.latex?a">.
</figcaption>
</figure>
</div>
</div>
</div>
</section>
<section id="the-derivation" class="level4">
<h4 class="anchored" data-anchor-id="the-derivation">The derivation</h4>
<p>Here we let the transmitted wave keep going to a detection screen a distance <img src="https://latex.codecogs.com/png.latex?L_2"> beyond the slits and derive the interference pattern in closed form. The trick is to model each slit as a Gaussian aperture: a Gaussian packet times a Gaussian slit is still Gaussian, and free evolution maps Gaussians to Gaussians, so every step stays analytic and no grid is needed.</p>
<p>Throughout, <img src="https://latex.codecogs.com/png.latex?y"> is the transverse coordinate and the along-axis drift just supplies a clock: the packet reaches the slits at <img src="https://latex.codecogs.com/png.latex?t_1%20=%20L_1/v"> and the screen at <img src="https://latex.codecogs.com/png.latex?t_2%20=%20L_2/v">, with <img src="https://latex.codecogs.com/png.latex?v%20=%20%5Chbar%20k_0/m">. The incident state is the standard free Gaussian wave packet of Cohen-Tannoudji (Complement <img src="https://latex.codecogs.com/png.latex?G_I">).</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-1-contents" aria-controls="callout-1" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>The complex Gaussian integral
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-1" class="callout-1-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>Every evolution step below is a single application of the complex Gaussian integral</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cint_%7B-%5Cinfty%7D%5E%7B%5Cinfty%7D%20e%5E%7B-A%20y%5E2%20+%20B%20y%20+%20C%7D%5C,dy%0A=%20%5Csqrt%7B%5Cfrac%7B%5Cpi%7D%7BA%7D%7D%5C;%5Cexp%5C!%5Cleft%5B%5Cfrac%7BB%5E2%7D%7B4A%7D%20+%20C%5Cright%5D,%0A%5Cqquad%20%5Coperatorname%7BRe%7D%20A%20%3E%200,%0A"></p>
<p>which stays valid by analytic continuation when <img src="https://latex.codecogs.com/png.latex?A"> is complex with positive real part.</p>
</div>
</div>
</div>
<section id="the-incident-packet" class="level5">
<h5 class="anchored" data-anchor-id="the-incident-packet">The incident packet</h5>
<p>Start with a Gaussian wave packet along <img src="https://latex.codecogs.com/png.latex?y">, following the convention found in many graduate texts (see e.g.&nbsp;Cohen-Tannoudji, Sakurai).</p>
<p><span id="eq-psi0"><img src="https://latex.codecogs.com/png.latex?%0A%5Cpsi(y,0)%20=%20%5Cleft(%5Cfrac%7B1%7D%7B2%5Cpi%5Csigma_0%5E2%7D%5Cright)%5E%7B1/4%7D%20e%5E%7B-y%5E2/4%5Csigma_0%5E2%7D,%0A%5Cqquad%0A%7C%5Cpsi(y,0)%7C%5E2%20=%20%5Cfrac%7B1%7D%7B%5Csqrt%7B2%5Cpi%7D%5C,%5Csigma_0%7D%5C,%20e%5E%7B-y%5E2/2%5Csigma_0%5E2%7D,%0A%5Ctag%7B1%7D"></span></p>
</section>
<section id="free-evolution-to-the-slit-plane" class="level5">
<h5 class="anchored" data-anchor-id="free-evolution-to-the-slit-plane">Free evolution to the slit plane</h5>
<p>Convolve Equation&nbsp;1 with the free-particle kernel over <img src="https://latex.codecogs.com/png.latex?t_1">, writing <img src="https://latex.codecogs.com/png.latex?s%20%5Cequiv%20i%20m%20/%202%5Chbar%20t_1">:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cpsi(y,t_1)%20=%20N_0%20%5Csqrt%7B%5Cfrac%7Bm%7D%7B2%5Cpi%20i%5Chbar%20t_1%7D%7D%0A%5Cint%20dy'%5C,%20%5Cexp%5C!%5Cleft%5B%5C,%20s(y%20-%20y')%5E2%20-%20%5Cfrac%7By'%5E2%7D%7B4%5Csigma_0%5E2%7D%5C,%5Cright%5D.%0A"></p>
<p>Collecting the <img src="https://latex.codecogs.com/png.latex?y'"> terms gives <img src="https://latex.codecogs.com/png.latex?A%20=%20%5Ctfrac%7B1%7D%7B4%5Csigma_0%5E2%7D%20-%20s">, <img src="https://latex.codecogs.com/png.latex?B%20=%20-2sy">, and <img src="https://latex.codecogs.com/png.latex?C%20=%20sy%5E2">. The integral identity, together with <img src="https://latex.codecogs.com/png.latex?1/s%20=%20-2i%5Chbar%20t_1/m">, collapses the exponent to <img src="https://latex.codecogs.com/png.latex?-y%5E2/4%5Calpha_1"> and the prefactor to <img src="https://latex.codecogs.com/png.latex?%5Csqrt%7B%5Csigma_0%5E2/%5Calpha_1%7D">, with</p>
<p><span id="eq-alpha1"><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%5C;%5Calpha_1%20=%20%5Csigma_0%5E2%20+%20%5Cfrac%7Bi%5Chbar%20t_1%7D%7B2m%7D%5C;%7D%0A%5Cqquad%0A%5Cpsi(y,t_1)%20=%20N_1%5C,%20e%5E%7B-y%5E2/4%5Calpha_1%7D,%0A%5Cquad%20N_1%20=%20N_0%5Csqrt%7B%5Cfrac%7B%5Csigma_0%5E2%7D%7B%5Calpha_1%7D%7D.%0A%5Ctag%7B2%7D"></span></p>
<p>This is the Cohen-Tannoudji spreading packet: the modulus of Equation&nbsp;2 gives <img src="https://latex.codecogs.com/png.latex?%5CDelta%20y(t_1)%20=%20%5Csigma_0%5Csqrt%7B1%20+%20(%5Chbar%20t_1/2m%5Csigma_0%5E2)%5E2%7D">. Both the analytic track here and the hard-slit numeric track saved for later start from this arrived packet.</p>
</section>
<section id="the-gaussian-slits" class="level5">
<h5 class="anchored" data-anchor-id="the-gaussian-slits">The Gaussian slits</h5>
<p>For the sake of reaching a closed form solution: model the two openings as Gaussian apertures centered at <img src="https://latex.codecogs.com/png.latex?y_%5Cpm%20=%20%5Cpm%20y_s">, with <img src="https://latex.codecogs.com/png.latex?y_s%20=%20(a+b)/2"> and width <img src="https://latex.codecogs.com/png.latex?%5Cbeta%20=%20b/%5Csqrt%7B2%5Cpi%7D"> (chosen so a uniformly illuminated Gaussian slit transmits the same flux as a hard slit of height <img src="https://latex.codecogs.com/png.latex?b">):</p>
<p><span id="eq-transmission"><img src="https://latex.codecogs.com/png.latex?%0AT(y)%20=%20%5Csum_%7Bj=%5Cpm%7D%20e%5E%7B-(y%20-%20j%20y_s)%5E2%20/%202%5Cbeta%5E2%7D,%0A%5Cqquad%0A%5Cphi(y)%20=%20%5Cpsi(y,t_1)%5C,T(y).%0A%5Ctag%7B3%7D"></span></p>
<p>Expanding the square in the slit-<img src="https://latex.codecogs.com/png.latex?j"> term of Equation&nbsp;3 writes its exponent as a single quadratic <img src="https://latex.codecogs.com/png.latex?-a_c%20y%5E2%20+%20b_j%20y%20+%20c_0"> with</p>
<p><span id="eq-combine"><img src="https://latex.codecogs.com/png.latex?%0Aa_c%20=%20%5Cfrac%7B1%7D%7B4%5Calpha_1%7D%20+%20%5Cfrac%7B1%7D%7B2%5Cbeta%5E2%7D,%0A%5Cqquad%0Ab_j%20=%20%5Cfrac%7Bj%5C,y_s%7D%7B%5Cbeta%5E2%7D,%0A%5Cqquad%0Ac_0%20=%20-%5Cfrac%7By_s%5E2%7D%7B2%5Cbeta%5E2%7D.%0A%5Ctag%7B4%7D"></span></p>
</section>
<section id="evolution-to-the-screen" class="level5">
<h5 class="anchored" data-anchor-id="evolution-to-the-screen">Evolution to the screen</h5>
<p>Convolve <img src="https://latex.codecogs.com/png.latex?%5Cphi"> with the free kernel over <img src="https://latex.codecogs.com/png.latex?t_2">, writing <img src="https://latex.codecogs.com/png.latex?%5Clambda_2%20%5Cequiv%20i%20m%20/%202%5Chbar%20t_2">:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cpsi_%7BD,j%7D(y_D)%20=%20N_1%20%5Csqrt%7B%5Cfrac%7Bm%7D%7B2%5Cpi%20i%5Chbar%20t_2%7D%7D%0A%5Cint%20dy%5C;%20e%5E%7B%5Clambda_2%20(y_D%20-%20y)%5E2%7D%5C,%20e%5E%7B-a_c%20y%5E2%20+%20b_j%20y%20+%20c_0%7D.%0A"></p>
<p>The <img src="https://latex.codecogs.com/png.latex?y">-integrand is again <img src="https://latex.codecogs.com/png.latex?-p%5C,y%5E2%20+%20q_j%20y%20+%20r"> with</p>
<p><span id="eq-pqr"><img src="https://latex.codecogs.com/png.latex?%0Ap%20=%20a_c%20-%20%5Clambda_2,%20%5Cqquad%0Aq_j%20=%20b_j%20-%202%5Clambda_2%20y_D,%20%5Cqquad%0Ar%20=%20%5Clambda_2%20y_D%5E2%20+%20c_0%20.%0A%5Ctag%7B5%7D"></span></p>
<p>Since <img src="https://latex.codecogs.com/png.latex?%5Clambda_2"> is pure imaginary, <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BRe%7D%20p%20=%20%5Coperatorname%7BRe%7D(1/4%5Calpha_1)%20+%201/2%5Cbeta%5E2%20%3E%200"> and the integral converges. Applying the identity,</p>
<p><span id="eq-psiDj"><img src="https://latex.codecogs.com/png.latex?%0A%5Cpsi_%7BD,j%7D(y_D)%20=%0A%5Cunderbrace%7BN_1%20%5Csqrt%7B%5Cfrac%7Bm%7D%7B2%5Cpi%20i%5Chbar%20t_2%7D%7D%5Csqrt%7B%5Cfrac%7B%5Cpi%7D%7Bp%7D%7D%5C,%20e%5E%7Bc_0%7D%7D_%7B%5Ctext%7Bcommon%20to%20both%20slits%7D%7D%0A%5C;%5Cexp%5C!%5Cleft%5B%5Cfrac%7Bq_j%5E2%7D%7B4p%7D%20+%20%5Clambda_2%20y_D%5E2%5Cright%5D,%0A%5Ctag%7B6%7D"></span></p>
</section>
<section id="summing-the-slits-envelope-times-fringes" class="level5">
<h5 class="anchored" data-anchor-id="summing-the-slits-envelope-times-fringes">Summing the slits: envelope times fringes</h5>
<p>The screen amplitude is <img src="https://latex.codecogs.com/png.latex?%5Cpsi_D%20=%20%5Cpsi_%7BD,+%7D%20+%20%5Cpsi_%7BD,-%7D">. Expand <img src="https://latex.codecogs.com/png.latex?q_j%5E2%20=%20b_j%5E2%20-%204%5Clambda_2%20y_D%20b_j%20+%204%5Clambda_2%5E2%20y_D%5E2">. The <img src="https://latex.codecogs.com/png.latex?b_j%5E2"> piece is the same for both slits (it depends on <img src="https://latex.codecogs.com/png.latex?j%5E2">), and only the middle term carries the sign of <img src="https://latex.codecogs.com/png.latex?j">. Defining the single complex constant</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Ckappa%20%5Cequiv%20%5Cfrac%7B%5Clambda_2%5C,%20y_s%7D%7B%5Cbeta%5E2%5C,%20p%7D,%0A%5Cqquad%5Ctext%7Bso%20that%7D%5Cqquad%0A%5Cfrac%7B%5Clambda_2%20y_D%5C,%20b_j%7D%7Bp%7D%20=%20j%5C,%5Ckappa%5C,%20y_D,%0A"></p>
<p>the two slits sum to a hyperbolic cosine, <img src="https://latex.codecogs.com/png.latex?%5Cpsi_D(y_D)%20=%202%5C,%5Cmathcal%7BN%7D(y_D)%5Ccosh(%5Ckappa%20y_D)">, where <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7BN%7D"> gathers the common (non-<img src="https://latex.codecogs.com/png.latex?j">) factors. Taking the modulus squared and writing <img src="https://latex.codecogs.com/png.latex?%5Ckappa%20=%20%5Ckappa_r%20+%20i%5Ckappa_i">, the identity <img src="https://latex.codecogs.com/png.latex?%7C%5Ccosh(u%20+%20iv)%7C%5E2%20=%20%5Ctfrac12(%5Ccosh%202u%20+%20%5Ccos%202v)"> gives</p>
<p><span id="eq-intensity"><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%5C;I(y_D)%20=%20E(y_D)%5Ccdot%20%5Cfrac%7B%5Ccosh(2%5Ckappa_r%20y_D)%20+%20%5Ccos(2%5Ckappa_i%20y_D)%7D%7B2%7D%5C;%7D%0A%5Ctag%7B7%7D"></span></p>
<p>The <img src="https://latex.codecogs.com/png.latex?%5Ccos(2%5Ckappa_i%20y_D)"> term is the interference; the <img src="https://latex.codecogs.com/png.latex?%5Ccosh"> term and <img src="https://latex.codecogs.com/png.latex?E"> together form the single-slit envelope.</p>
</section>
<section id="the-pattern" class="level5">
<h5 class="anchored" data-anchor-id="the-pattern">The pattern</h5>
<p>Evaluating Equation&nbsp;7 on a grid gives the closed-form pattern below. The fringe spacing measured from the peaks matches <strong>?@eq-spacing</strong>.</p>
<div id="cell-fig-screen-analytic" class="cell" data-execution_count="2">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb2-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb2-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> dslit</span>
<span id="cb2-4"></span>
<span id="cb2-5">yD <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linspace(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">60e-6</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">60e-6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4000</span>)</span>
<span id="cb2-6">psi_p, psi_m <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> dslit.per_slit_analytic(yD)</span>
<span id="cb2-7">I <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> dslit.screen_intensity(psi_p, psi_m, mu<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.0</span>)</span>
<span id="cb2-8">I <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> I <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> I.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>()</span>
<span id="cb2-9">fr, env <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> dslit.fringe_spacing()</span>
<span id="cb2-10"></span>
<span id="cb2-11">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>))</span>
<span id="cb2-12">ax.plot(yD <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e6</span>, I, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#185FA5"</span>, lw<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>)</span>
<span id="cb2-13">ax.set_xlabel(<span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">r"</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">$</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">y_D</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">$</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;"> on detection screen </span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">[$</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">\m</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">u$m]</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb2-14">ax.set_ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normalized intensity"</span>)</span>
<span id="cb2-15">ax.set_title(<span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">r"Gaussian-slit fringes, </span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">$\D</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">elta = </span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">lambda L_2/</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">(</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">a</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">b</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">$</span><span class="vs" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb2-16">             <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f" = </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>fr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e6</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.2f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> µm"</span>)</span>
<span id="cb2-17">plt.show()</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-display">
<div id="fig-screen-analytic" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-screen-analytic-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://areanraines.com/posts/double-slit-part2/index_files/figure-html/fig-screen-analytic-output-1.svg" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-screen-analytic-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: Closed-form Gaussian-slit intensity on the detection screen. Equally spaced fringes sit under a smooth Gaussian envelope.
</figcaption>
</figure>
</div>
</div>
</div>
<div id="spacing-check" class="cell" data-execution_count="3">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> scipy.signal <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> find_peaks</span>
<span id="cb3-2"></span>
<span id="cb3-3">peaks, _ <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> find_peaks(I, height<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>)</span>
<span id="cb3-4">measured <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.median(np.diff(np.sort(yD[peaks])))</span>
<span id="cb3-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f"predicted  lambda*L2/(a+b) = </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>fr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e6</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.3f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> um"</span>)</span>
<span id="cb3-6"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f"measured   peak spacing    = </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>measured<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e6</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.3f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> um"</span>)</span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>predicted  lambda*L2/(a+b) = 6.464 um
measured   peak spacing    = 6.452 um</code></pre>
</div>
</div>
</section>
</section>
</section>
</section>
<section id="up-next" class="level2">
<h2 class="anchored" data-anchor-id="up-next">Up next</h2>
<p>We now have a beam that reaches the slits, and the fraction that gets through. In Part 3 we will solve the problem for two slits numerically, dropping the assumption of Gaussian-shaped slits. There is no analytical solution to this next problem.</p>
<p>The full source for this series is on <a href="https://github.com/kareanra/physics-blog">GitHub</a>. The derivations, code, and prose are all mine. However, I did consult Claude to proofread and for help setting up the project and rendering equations.</p>


<!-- -->

</section>
</section>

 ]]></description>
  <category>quantum mechanics</category>
  <category>Schrödinger equation</category>
  <category>Gaussian integrals</category>
  <category>python</category>
  <guid>https://areanraines.com/posts/double-slit-part2/</guid>
  <pubDate>Thu, 16 Jul 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>The double slit experiment, part 1: the background</title>
  <dc:creator>Kyle Arean-Raines</dc:creator>
  <link>https://areanraines.com/posts/double-slit-part1/</link>
  <description><![CDATA[ 




<section id="the-quantum-double-slit-experiment" class="level1">
<h1>The quantum double-slit experiment</h1>
<p>In this series we’ll eventually be using numerical and analytical methods for simulating and solving for the result of the famous quantum mechanical <a href="https://en.wikipedia.org/wiki/Double-slit_experiment">double-slit experiment</a>, performed with an electron and solved in a variety of different ways.</p>
<p>I like this problem a lot, as it illustrates some really interesting quantum phenomena (wave-particle duality, superposition, interference, uncertainty, measurement), and you can layer on the complexity, as we’ll do here in discrete and progressive steps.</p>
<p>I’ve separated this series into different posts for a reason: Part 1 has basic prerequisites and the others require a significant background in math or physics concepts that are taught at the upper-undergraduate or graduate level.</p>
<section id="part-1-the-background" class="level2">
<h2 class="anchored" data-anchor-id="part-1-the-background">Part 1: the background</h2>
<p>This first part is very light on the math. We’ll try to build an intuition for the experiment using analogies with light, then we’ll look at electrons. My hope is that you’ll come away with some understanding of wave-particle duality and “the observer effect” in quantum mechanics.</p>
<section id="classical-picture-light" class="level3">
<h3 class="anchored" data-anchor-id="classical-picture-light">Classical picture: light</h3>
<p>Many of you may know that light has both particle- and wave-like properties. A photon is an “atom” of light, an indivisible and smallest packet of light that exhibits particle-like behavior. However, light at a macroscopic level - and that which we encounter in our daily life - behaves as a wave. And waves exhibit two phenomena that are critical to understanding the double-slit experiment: <em>diffraction</em> and <em>interference</em>.</p>
<section id="diffraction" class="level4">
<h4 class="anchored" data-anchor-id="diffraction">Diffraction</h4>
<p>If you shine a laser from a distance onto a piece of paper with a tiny little pinhole in the middle, most of the light will be absorbed or reflected by the surface of the paper, and some will make it through the hole. If you have a second piece of paper behind the first (call it the “detector screen”), you’ll see that the transmitted light that goes through the hole spreads out a little bit. The dot on the paper on the detector screen will be slightly wider then the initial, incoming beam. The highest intensity of light on the detector will be in the center of the dot. As you work your way outward from the center, the intensity decreases until it dies off. This spreading out is known as diffraction, and is due to light bending around the sides of the hole.</p>
</section>
<section id="interference" class="level4">
<h4 class="anchored" data-anchor-id="interference">Interference</h4>
<p>Waves are basically just oscillations of <em>something</em>, ups and downs in a repeating pattern. The peaks and troughs of light correspond to peaks and troughs of electric and magnetic fields, but that’s out of scope for this post. All you need to know is that two beams of light that overlap will, generally, <em>interfere</em>. Roughly, when a peak overlaps with a peak, the intensity of the light increases. Same with a trough overlapping a trough. But when a peak and a trough overlap, they cancel each other out and you get no light at all.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://areanraines.com/diagrams/double-slit-part1/wave-interference.svg" class="img-fluid figure-img"></p>
<figcaption>Constructive and destructive interference.</figcaption>
</figure>
</div>
</section>
<section id="classical-double-slit" class="level4">
<h4 class="anchored" data-anchor-id="classical-double-slit">Classical double-slit</h4>
<p>Combining the above two concepts, take a look at the following diagram and first see if you can reason about the result on your own.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://areanraines.com/diagrams/double-slit-part1/double-slit-interference.svg" class="img-fluid figure-img"></p>
<figcaption>Waves spreading out and overlapping after passing through two slits.</figcaption>
</figure>
</div>
<p>Diffraction causes the bending of the light going through each slit, and interference causes the regions of high and low intensity on the detector screen. The end result is these “fringes” you see on the detector screen. The fringes themselves are physically where the waves of diffracted (spread-out) light overlapped and interfered <em>constructively</em>. The regions in between are where no light arrived because the waves interfered <em>destructively</em> and canceled out.</p>
</section>
</section>
<section id="quantum-picture-also-with-light" class="level3">
<h3 class="anchored" data-anchor-id="quantum-picture-also-with-light">Quantum picture: also with light</h3>
<p>Let’s now focus on the particle-like properties of light. The particle behavior of light, by the way, is inherently “quantum.” No classical theory can explain phenomena like the photoelectric effect or other experiments where photons’ particle-like behaviors dominate. So just remember this: light’s “quantumness” is roughly indicated by how much it’s behaving like a particle. For matter - including the electrons we’ll be dealing with - the opposite is true: the wave behavior only comes on when quantum effects dominate.</p>
<p>Aside: this second statement is crucial to understanding the profundity of the results we’re going to see. Because it turns out that the quantumness disappears whenever you try to figure out the particle’s state (“observe” it).</p>
<p>Let’s make our detector screen a theoretical, 2-dimensional screen that can detect where a single photon lands. When the light is on full blast like in the above experiment, the detector will detect a large number of photons over a given (short) timespan. The resulting pattern will exhibit wave interference, as we described before: you’ll see fringes with bright areas and dark areas. This is fully classical so far. Waves diffract when they hit the slits, and interfere when they recombine.</p>
<p>However, now dial down the light intensity to be sufficiently low that single photons arrive sequentially at the detector screen, passing through either the top or bottom slit (or… both or neither, as we’ll see). Okay, so admittedly this is really a <em>semi-classical</em> picture since we’re dealing with individual photons. But hear me out. Classically, we would expect the screen to have two blotches where the photons hit the screen, each directly, line-of-sight behind one of the slits. We wouldn’t expect interference, since each photon passes through sequentially with no overlap.</p>
<p>BUT, we in fact <em>do</em> see the interference fringes on the screen, provided we don’t set up a way to detect which slit each photon went through. I’ll get to the mathematics and maybe even philosophy of what happens when the observer (us) detects which slit the photon passed through. But for now, take it as a given that this is the case.</p>
<p>Let’s stop for a moment and appreciate how crazy this is: individual photons shot at the screen, one by one and, result in that interference pattern. If the photon went through a slit, there’s no second photon to overlap or recombine with. How is it possible for there to be interference? As we’ll eventually see, the photon essentially went through <em>both</em> slits simultaneously, and interfered with <em>itself</em> before hitting the detector. But wait, there’s more! If you somehow determine whether each photon went through the top or bottom slit, the pattern disappears, and we get that classical two-smudge pattern!</p>
<p><em>Note: if we’re being pedantic, we might say that the path the light took is indeterminate if you don’t measure it, and that it’s the trajectories or possible paths that interfere. I, for one, don’t think this makes things any less magical. But I also think my previous description is better for our layperson understanding of this</em>.</p>
</section>
<section id="quantum-picture-electrons" class="level3">
<h3 class="anchored" data-anchor-id="quantum-picture-electrons">Quantum picture: electrons</h3>
<p>Let’s now turn to the actual experiment of interest: a double-slit setup with an electron beam instead of a light beam. Now prior to quantum theory, there were two disparate theories to describe particles and waves. These are (somewhat loosely) the fields of classical mechanics and wave mechanics. Whether you’re dealing with sound wave propagation, light, or a spreading circular wave in water, you use a different set of equations than if you’re looking at particles with mass. The equations of motion in both cases give you the state of the system at some time <img src="https://latex.codecogs.com/png.latex?t"> in the future, provided you know the initial state of your particle(s) or wave(s).</p>
<p>This is adequate for almost everything we interact with in our daily lives. Single electrons, however, are so tiny and interact so differently with each other and light or matter that we need quantum theory to calculate their trajectories and interactions.</p>
<p>And so when we fire electrons at the screen, we might know what to expect: fringes on the detector if quantumness was preserved, or smudges with no fringes if the quantumness disappeared. This is indeed the case! If we don’t observe which slit the electron went through, we see fringes. If we somehow figure out the trajectory and which slit the electron passed through, the quantumness and fringes disappear!</p>
</section>
</section>
<section id="the-nature-of-measurement-and-uncertainty" class="level2">
<h2 class="anchored" data-anchor-id="the-nature-of-measurement-and-uncertainty">The nature of measurement and uncertainty</h2>
<p>As I said before, wave-like properties of all matter are inherently quantum mechanical. Quantum theory predicted this, and there’s no way to explain the double-slit experiment in terms of classical particles or trajectories. The interference pattern, being the fingerprint of wave-like behavior, is therefore also an indication of “quantumness.” And that’s the thing we see disappearing when we make an “observation.”</p>
<p>What constitutes a measurement or observation? This is tricky. You could think of it in this context as altering the trajectory physically by e.g.&nbsp;blocking the lower slit. Or light from a microscope shining on the electron at all times throughout its journey. But more interesting is the case of designing an extremely sensitive apparatus to detect which slit the electron went through without significantly altering its trajectory. Since electrons carry charge, this might be an instrument placed right after the slits and closer to the top slit that detects the strength of its electric field to determine the slit it went through. But the details and mechanism don’t actually matter. <strong>There is no way to design an instrument that can detect which slit the electron went through in this experiment and preserve its quantumness.</strong> And there’s even a way of quantifying how “strong” or “weak” a measurement is, and it’s inversely related to the quantum decoherence - that is, the weaker the measurement, the more the quantumness is preserved.</p>
<p>So the main takeaway here is that if we know which slit the electron traveled through, it will behave like a particle. If we don’t, it will behave like a wave.</p>
<p>For the interested reader, there’s actually a much stronger statement here: the <em>very ability</em> even in principle to know what a particle’s trajectory is or was alters that trajectory. And there’s truly no way to “cheat” and skirt this universal principle, even by being extremely clever with our experimental setup. It’s simply not possible to preserve the “quantumness” and have the information we’re seeking. I find this profound and fascinating.</p>
<p>To drive the point home I’ll borrow a thought experiment from Richard Feynman’s lecture notes on quantum mechanics. Feel free to skip this next section if it isn’t of interest, or is too much to grasp. It does require some prior physics knowledge.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-1-contents" aria-controls="callout-1" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Feynman’s scattering crystal
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-1" class="callout-1-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>Here I will quote Feynman rather than paraphrasing. After all, I could never do it justice with my own description. For reference, I’m quoting from his third section of <a href="https://www.feynmanlectures.caltech.edu/III_03.html">Caltech lecture notes</a>.</p>
<blockquote class="blockquote">
<p>Our next example is a phenomenon in which we have to analyze the interference of probability amplitudes somewhat carefully. We look at the process of the scattering of neutrons from a crystal. Suppose we have a crystal which has a lot of atoms with nuclei at their centers, arranged in a periodic array, and a neutron beam that comes from far away. We can label the various nuclei in the crystal by an index i , where i runs over the integers 1 , 2 , 3 , …, N , with N equal to the total number of atoms. We have here a large number of apparently indistinguishable routes. They are indistinguishable because a low-energy neutron is scattered from a nucleus without knocking the atom out of its place in the crystal—no “record” is left of the scattering.</p>
<p>[Skipping some math here]</p>
<p>Because we are adding amplitudes of scattering from atoms with different space positions, the amplitudes will have different phases giving the characteristic interference pattern…</p>
<p>The neutron intensity as a function of angle in such an experiment is indeed often found to show tremendous variations, with very sharp interference peaks and almost nothing in between—as shown [here]</p>
<p><img src="https://areanraines.com/diagrams/double-slit-part1/feynman-crystal-scattering.svgz" id="fig-scattering" class="img-fluid" alt="Fig. 3–6(a)">. However, for certain kinds of crystals it does not work this way, and there is—along with the interference peaks discussed above—a general background of scattering in all directions. We must try to understand the apparently mysterious reasons for this. Well, we have not considered one important property of the neutron. It has a spin of one-half, and so there are two conditions in which it can be: either spin “up”… or spin “down.” If the nuclei of the crystal have no spin, the neutron spin doesn’t have any effect. But when the nuclei of the crystal also have a spin, say a spin of one-half, you will observe the background of smeared-out scattering described above. The explanation is as follows.</p>
<p>If the neutron has one direction of spin and the atomic nucleus has the same spin, then no change of spin can occur in the scattering process. If the neutron and atomic nucleus have opposite spin, then scattering can occur by two processes, one in which the spins are unchanged and another in which the spin directions are exchanged. This rule for no net change of the sum of the spins is analogous to our classical law of conservation of angular momentum. We can begin to understand the phenomenon if we assume that all the scattering nuclei are set up with spins in one direction. A neutron with the same spin will scatter with the expected sharp interference distribution. What about one with opposite spin? If it scatters without spin flip, then nothing is changed from the above; but if the two spins flip over in the scattering, we could, in principle, find out which nucleus had done the scattering, since it would be the only one with spin turned over. Well, if we can tell which atom did the scattering, what have the other atoms got to do with it? Nothing, of course. The scattering is exactly the same as that from a single atom.</p>
</blockquote>
</div>
</div>
</div>
<p>If you have an appetite for math and want to peak under the cosmic hood, feel free to continue with this series. If not, thanks for stopping by! I hope you feel a little more informed and maybe a little excited about the universe.</p>
</section>
<section id="up-next" class="level2">
<h2 class="anchored" data-anchor-id="up-next">Up next</h2>
<p>In <a href="../../posts/double-slit-part2/index.html">Part 2</a> we’ll put this intuition into math: solving the Schrödinger equation for a Gaussian electron wave packet passing through two Gaussian-aperture slits, and deriving the resulting interference pattern in closed form.</p>
<p>The full source for this series is on <a href="https://github.com/kareanra/physics-blog">GitHub</a>. The derivations, code, and prose are all mine. However, I did consult Claude to proofread and for help setting up the project and rendering equations.</p>


<!-- -->

</section>
</section>

 ]]></description>
  <category>quantum mechanics</category>
  <category>wave-particle duality</category>
  <category>interference</category>
  <guid>https://areanraines.com/posts/double-slit-part1/</guid>
  <pubDate>Fri, 10 Jul 2026 00:00:00 GMT</pubDate>
</item>
</channel>
</rss>
