Diffraction through a grating sends bright fringes only where waves from every slit arrive in step — d·sinθ = nλ. Drag the sliders below to change the wavelength, line density, slit count and screen distance, and watch the ray fan and the on-screen intensity pattern respond live.
The wavelength slider is the equation working in plain sight: since d·sinθ = nλ pins each bright order to its angle, dragging toward red pushes every order outward and dragging toward violet pulls the whole fan back in. The colour of the rays and the intensity trace follows the slider, so you can literally watch a longer wavelength demand a bigger angle.
The line density slider changes d itself: more lines per millimetre means a smaller slit spacing, and the readout updates d = 1/N as you drag. The orders spread wider apart — and, at the same time, fewer of them survive, because an order only exists while nλ/d ≤ 1. The readouts show the trade live: the first-order angle climbs while the highest visible order falls. You can confirm nmax = floor(d/λ) yourself against the fringe count, or hand the same numbers to the diffraction grating calculator for the full worked steps.
The number of slits is the subtle one, and it corrects the classic misconception directly: this sim's bright fringes are the maxima of the grating equation, not the single-slit minima, and adding slits does not move them at all. What changes is their sharpness — the bottom panel's peaks grow taller and needle-thin as N rises, because more slits cancel the light more completely between the maxima. That sharpening is the whole reason real gratings carry thousands of lines.
Finally, the screen distance turns angles into positions: each fringe lands at y = D·tanθ, so doubling D doubles the spacing on the screen without touching a single angle. It is the same geometry a spectrometer uses to convert an angle measurement into a wavelength — light whose speed in vacuum is the fixed speed of light, whatever its colour.
Drag the four sliders and watch both panels respond: the wavelength slider moves every bright order, the line-density slider sets the slit spacing d, the slit-count slider sharpens the fringes, and the screen-distance slider spreads them across the screen. The readouts always show d, the first-order angle, the highest visible order and the total fringe count.
Because the grating equation d sin(angle) = n(wavelength) fixes each order's angle, and a longer wavelength needs a larger sine to keep the equation balanced. Slide from violet 380 nm toward red 700 nm and every order marches outward — the same reason a grating fans white light into a spectrum with red bent furthest.
Only the sharpness. The bright maxima sit wherever d sin(angle) = n(wavelength), which does not involve the slit count — but with more slits the waves cancel more completely everywhere else, so each fringe becomes taller and narrower. That is exactly why real gratings rule thousands of lines: needle-sharp fringes make precise wavelength measurements possible.
Grating (multi-slit) diffraction. The bright peaks here are the maxima of d sin(angle) = n(wavelength). A single slit obeys the similar-looking a sin(angle) = m(wavelength), but that formula locates the dark minima of its pattern, not bright fringes — mixing the two is the classic diffraction mistake.
Count n_max = floor(d/wavelength) on each side of the central maximum, giving 2·n_max + 1 fringes in total. With 500 lines/mm (d = 2.00 micrometres) and 550 nm light, d/wavelength = 3.6, so three orders fit each side — seven bright fringes. Raise the line density and watch the count fall as the pattern spreads.