A quantum wave packet passes through two slits and interferes with itself.
This solves the time-dependent Schrodinger equation on a grid. An electron starts as a wave packet, moves toward a wall with two slits, and passes through both at once. On the far side the two waves interfere, and detections build up on a screen into bright and dark fringes. Brightness shows probability and hue shows the phase of the wave.
Try it. Click to fire a new electron from the pointer, or press Space. Press 1 or 2 for one or two slits, and C to clear the screen.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a quantum double slit simulation with JavaScript and the HTML canvas element by solving the time-dependent Schrodinger equation on a grid. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Use a grid of about 300 by 200 cells and store the wave function as two Float32Arrays, the real part R and the imaginary part I. Use units where hbar = m = 1 and the cell size is 1.
- Start a Gaussian wave packet on the left moving right: amplitude exp(-(dx^2 + dy^2) / (2 sigma^2)) times cos(k x) for R and sin(k x) for I (wavelength about 6 cells).
- Advance it with Visscher's leapfrog scheme: R += dt * H I, then I -= dt * H R, where H psi = -0.5 times the 5-point Laplacian of psi. Use dt = 0.3.
- Add a wall a third of the way across: cells where R and I are forced to zero, with two narrow gaps.
- Draw each cell with brightness from the amplitude sqrt(R^2 + I^2) and hue from the phase atan2(I, R).
Once that works, make it beautiful and physical:
- Add absorbing borders: multiply R and I by a factor slightly below 1 near the edges so waves do not bounce back.
- Give the far side of the wall its own brightness scale so the faint transmitted wave shows.
- Put a detector screen on the right. Every step, read |psi|^2 along its column and draw random detection dots from that distribution, a few at a time, so the interference fringes build up dot by dot. Fire a new electron every couple of seconds.
- Press 1 or 2 to switch between one and two slits.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as a which-path detector that destroys the fringes, tunneling through a thin barrier, or a split-operator solver using an FFT.