Diffraction Grating Calculator
Thousands of evenly ruled slits fan light into a rainbow of sharp orders. Enter the grating’s line density and the wavelength, and this calculator returns the angle of each bright order — and how many orders exist before the geometry runs out.
Constructive Interference, Industrialised
Each slit of a grating diffracts light in all directions, but the slits conspire: in most directions the wavelets from neighbouring slits arrive out of step and cancel, and only where the path difference between adjacent slits is a whole number of wavelengths — d sin θ = mλ — do they arrive in step and reinforce into a bright order. The equation is a census of those directions: m = 0 straight through (all colours together, the undispersed beam), then a spectrum per side per order, sharpening as the slit count grows (a real grating’s thousands of slits make each order’s lines hair-fine, which is the instrument’s celebrated resolving power). Enter the ruling and the wavelength and the calculator performs the census — the founding arithmetic of spectroscopy, the science that read the composition of the stars without leaving Earth.
Worked Example: Five Hundred Lines, Green Light
The defaults rule a standard teaching grating: 500 lines/mm gives d = 1,000,000 ÷ 500 = 2,000 nm, and for green light at 550 nm the first order sits at sin θ = 550 ÷ 2,000 = 0.275, θ = 15.96°; the second at 33.37°, the third at 55.59°, and there the census ends — mmax = ⌊d ÷ λ⌋ = 3, since a fourth order would demand sin θ > 1, the equation’s polite refusal (the same jurisdiction boundary the refraction page met at total internal reflection). Swap the wavelength for the sodium doublet’s 589 nm and the first order moves to 17.12° — a shift a spectrometer reads as chemistry. The calculator’s job is to make such readings predictable before the lamp is even lit.
Why Gratings Beat Prisms
A prism disperses by refraction — unevenly, crowding the red and stretching the blue, by amounts that depend on the glass’s private dispersion curve. A grating disperses by interference: the angles are set by geometry (this equation) nearly linearly in wavelength within an order, identical for any grating material, and the resolving power (λ ÷ Δλ = m × N, order times slits illuminated) can reach hundreds of thousands — enough to split the sodium doublet’s 0.6 nm and to measure stellar velocities by Doppler shift. The price is the orders themselves: they overlap (the second order’s violet lands on the first order’s red), so instruments add filters or a cross-dispersing prism — the prism demoted to the grating’s usher, an irony the history of optics savours. Every modern spectrograph, from the bench fluorimeter to the space telescope’s, is built around this page’s sine.
Fraunhofer’s Dark Lines
Joseph von Fraunhofer, who mapped the dark lines in the solar spectrum as a young optician, also built the first precision gratings — ruled with a diamond on glass by a machine of his own design — and used them to measure those lines’ wavelengths absolutely, turning the spectrum from a picture into a table of numbers. Every spectral line in every database descends from that upgrade: Kirchhoff and Bunsen’s element-hunting, helium’s discovery in sunlight before its discovery on Earth, and Hubble’s redshifted galaxies all read gratings’ output. The calculator’s little census of angles is the same instrument Fraunhofer pointed at the sun, minus two centuries of ruling engines — and his lines, lettered A through K in his notation, are still printed in atlases today.
The Echelle: Orders by the Dozen
Push the calculator’s logic to its extreme and you reach the echelle grating — ruled coarse (tens of lines per millimetre) but used at steep angles and in orders of fifty or a hundred, where resolving power mN becomes astronomical: an echelle spectrograph spreads its orders in a two-dimensional fan with a second, cross-dispersing element, laying a whole rainbow of hairline spectra across a CCD in one exposure. Exoplanet hunters live on these instruments, reading stellar wobbles of metres per second from line shifts this equation prices to five significant figures. The modest first-order census on this page and the echelle’s hundredth order are the same sine law, differing only in bookkeeping — which is the recurring comfort of a true formula: it scales from the school bench to the observatory without once asking permission.
Butterfly Wings and Opals
Nature files this patent too: the morpho butterfly’s impossible blue is a grating effect — ridges on its scales spaced at optical intervals, satisfying the same interference condition for blue and cancelling the rest — and the opal’s fire is a three-dimensional version, silica spheres stacked at spacings that select colours by angle. Structural colour (no pigment, only geometry) is the grating equation grown rather than ruled, and materials scientists now print such spacings deliberately for sensors and anti-counterfeit inks. A wing-ridge spacing of 200 nm corresponds, in this page’s terms, to a ruling of 5,000 lines/mm — beyond the calculator’s teaching range but not beyond its law: the sine still governs, at spacings the ruling engines of Fraunhofer could not dream of.
Related Tools
More from the Physics Calculators hub: the Index of Refraction Calculator — the prism’s physics, for contrast — and the Wave Velocity Calculator, since λ is half of every wave’s identity card.
Frequently Asked Questions
What does lines per mm really buy me?
Smaller d, hence larger angles for the same wavelength and order — more spread, and (because the orders sit further from the blaze of the zero order) cleaner spectra; and since resolving power depends on the total slits illuminated, a finer grating of the same physical width carries more slits and resolves finer detail. The costs are real too: fewer orders fit before the 90° wall (a 1200-line grating shows green light only two orders), the angles grow awkward to catch, and efficiency per order drops. Grating choice is the classic three-way negotiation among spread, resolution and orders — this calculator prices the angles so the negotiation starts from numbers, not catalogue adjectives.
Why do CDs and DVDs rainbow?
Because their track pitch is a diffraction grating you own: a CD’s tracks sit 1.6 µm apart (625 lines/mm in this page’s units), a DVD’s 0.74 µm, and white light striking them satisfies d sin θ = mλ at visibly different angles per colour — the rainbow sheen is a first-order spectrum, unauthorised but exact. Enter 625 lines/mm and 550 nm and the calculator returns 20.1° for green, matching the tilt at which a CD flashes green at your eye. Blu-ray’s 0.32 µm pitch pushes the first order past visibility for some colours — the sheen shifts accordingly, an entire storage industry’s generations legible in one equation’s output.
What is the zero order good for?
Nothing spectroscopic — it is all wavelengths superposed, the mirror-like reflection or straight-through beam — but it is the alignment reference every spectrometer is set up against (find zero, then measure orders against it), and its brightness is the efficiency the grating didn’t disperse, which is why gratings are “blazed”: their facet angles are cut to throw most of the light into one chosen working order. The calculator’s census counts every geometric order impartially; the blaze decides which of them gets the photons, an engineering layer atop the geometry that the angles here still govern absolutely.
How precise is the angle measurement in practice?
With a spectrometer’s divided circle, arc-minutes are routine — at the first order of the worked example, an arc-minute is about 0.3 nm of wavelength, which is how teaching laboratories measure the hydrogen spectrum’s lines and recover the Rydberg constant to a percent. The limits are the slit’s width (lines broaden), the grating’s ruling errors (ghost lines, a famous manufacturing demon), and the observer’s care with the zero. The equation itself has no error term: d and λ in, θ out — the experimentalist’s remaining work is metrology, which is the honest state of all mature physics.
Can a grating work in reflection?
Most laboratory gratings do exactly that — ruled or replicated on a mirror blank, used at an incidence angle the simple formula generalises to d (sin θi + sin θr) = mλ. The transmission form on this page is the textbook case (normal incidence, one angle), and its numbers transfer to reflection gratings used near normal; the observatory instruments work at steep angles with the two-angle form, echelle gratings at very high orders (m in the dozens) cross-dispersed into two-dimensional spectra. One interference condition, several geometries — the calculator covers the canonical one exactly and names the generalisation so no reader mistakes the map for the whole territory.
What is resolving power, in one example?
R = λ ÷ Δλ = mN: to split the sodium doublet (589.0 and 589.6 nm, Δλ = 0.6) requires R ≈ 980 — achieved in first order by a grating with a mere thousand slits illuminated, two millimetres of the worked example’s ruling, which is why the doublet is the undergraduate’s first triumph. A research echelle at m = 40 with 100,000 slits reaches R in the millions, resolving the thermal widths of stellar lines. The calculator’s inputs (lines/mm, and your beam’s width for N) bound R before any photon is counted — resolving power is bought in the ruling, spent in the orders, and this page prices both sides of the purchase.