🐈 Double slit experiment
Introduction
Section titled “Introduction”In this visualization, the interference pattern is generated “statically”, i.e. by calculating the path difference between the beams originating from each source and setting the (pixel) color of the background accordingly.
The two slits are represented by the two cylinders that also now firing particles at the screen/detector in the simulation, so that the difference in the behavior of particles and waves can be clearly seen.
🎯 Visualization of a real (discrete scalar) field
🧠 Inspired by original VPython version by Let’s code physics
👉 See also his accompanying video
🐍 A 3D VPython demo is available as well, see double_slit.py
Implementation details
Section titled “Implementation details”The intensity is given by:
This is easily translated in code as follows:
const pos = new Vec3(x, y, 0);const r1 = pos.distanceTo(posSlit1);const r2 = pos.distanceTo(posSlit2);const pathDiff = Math.abs(r1 - r2);const rAverage = (r1 + r2) * 0.5;const envelope = 1 / (1 + 0.1 * rAverage);field.setValueAt(i, j, Math.pow(Math.cos(Math.PI * pathDiff / wavelength), 2) * envelope);Background information
Section titled “Background information”In 1801, Thomas Young was the first to perform an experiment that made it unequivocally clear that light is a wave, since the interference pattern he observed was exactly similar to an interference pattern that would have been produced by water waves.

Videos on the mystery of the double slit experiment
Section titled “Videos on the mystery of the double slit experiment”The following videos are recommended to learn more about the double slit experiment and its repercussions for our view on the reality of nature:
- Single Photon Interference by Veritassium, where the experiment is actually performed!
- The Quantum Experiment that Broke Reality by PBS Space Time, with a more in-depth explanation.
- Dr.Quantum — Double slit experiment, a video that is more accessible to the public.


Particle-wave duality
Section titled “Particle-wave duality”