๐ 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โ