This simulator passes light through a diffraction grating — many closely spaced slits — and shows how it produces sharp, well-separated diffraction orders on a screen, the working principle behind spectrometers and spectroscopes.
• A ray diagram with the incoming beam, a fine multi-slit grating, and rays for each diffraction order fanning out to a screen. • Two live controls: wavelength (400-700 nm) and lines per millimeter (100-1200). • A live readout for the grating spacing d and the first-order diffraction angle θ₁. • Three preset gratings: coarse (100 lines/mm), typical (500 lines/mm), and fine (1200 lines/mm).
d sinθₘ = mλ describes the angles at which constructive interference occurs for a grating with slit spacing d, for integer diffraction order m (0, ±1, ±2, and so on). The central m=0 order is always undeviated white light (all wavelengths overlap there); higher orders separate different wavelengths at different angles, spreading a spectrum.
A double slit produces broad, gradually-fading interference fringes because only two wave sources are combining. A grating with hundreds or thousands of slits per millimeter combines light from many more sources at once — at any angle except the exact constructive-interference condition, the contributions from all those slits cancel almost completely, producing very sharp, narrow bright lines instead of broad fringes. This is exactly what makes gratings useful for precisely measuring wavelengths in spectrometers.
d sinθₘ = mλ, where d is the spacing between adjacent slits, θₘ is the angle to the m-th order maximum, and λ is the wavelength.
A grating combines light from many more slits than a double slit. Away from the exact constructive-interference angle, contributions from all those extra slits cancel out almost completely, narrowing the bright bands into sharp lines.
Finer gratings (smaller slit spacing d) push diffraction angles larger for a given order. Beyond a certain point, the grating equation has no valid solution (sinθ would exceed 1) and that order simply does not appear.
Because the diffraction angle for a given order depends on wavelength (d sinθₘ = mλ), different colors bend to different angles for the same order, spreading white light into a spectrum — though by a completely different physical mechanism than a prism's dispersion.