Diffraction Grating Solver – Wavelength, Groove Spacing & Angle (d sinθ = mλ)

Use this free Diffraction Grating Solver to work the grating equation d sinθ = mλ in any direction — find the wavelength, the groove spacing from a lines-per-mm rating, or the diffraction angle for any order.

A diffraction grating is a surface ruled with thousands of equally spaced grooves — hundreds or thousands per millimetre — that splits light into its component wavelengths far more powerfully than a prism does. Where a prism bends each colour by a slightly different amount, a grating sends each wavelength to its own sharply defined angle, so a spectrum measured with a grating can separate wavelengths that differ by less than a tenth of a nanometre. That precision is why gratings, not prisms, sit at the heart of laboratory spectrometers, astronomical spectrographs and the instruments that identify unknown gases by their spectral fingerprints.

Everything the grating does follows from one piece of geometry. Light falling on neighbouring grooves travels slightly different distances to reach a point on a distant screen, and the difference grows with the angle. Wherever that extra path equals a whole number of wavelengths, the waves from every groove arrive in step and reinforce into a bright fringe; everywhere else they cancel. The grating equation d sinθ = mλ is simply that condition written down: groove spacing d, angle θ, order m, wavelength λ. This calculator solves it in every direction — λ from an angle, θ from a wavelength, or d itself from a measured pair.

Diffraction Grating Solver — formula and diagram

Two features make gratings so useful in practice. First, the angles depend only on d, m and λ — not on the material — so a measurement is absolute and needs no calibration against the glass the way a prism does. Second, the spreading grows with the order m: in second order the same spectrum stretches over roughly twice the angular range, separating close wavelengths that first order would blur together. The price is that fewer orders exist at all, and that orders can overlap — second-order violet lands at the same angle as third-order red, a quirk spectroscopists manage with filters.

θ white light in m = 2 m = 1 grating — grooves every d

Formula

d sinθ = mλ  •  groove spacing from the rating: d (nm) = 1,000,000 ÷ (lines per mm)

The equation rearranges for whichever quantity is unknown: λ = d sinθ ÷ m to identify an unknown wavelength from a measured angle; sinθ = mλ ÷ d to predict where a known wavelength will appear; and d = mλ ÷ sinθ to characterise an unlabelled grating from a known light source. Bright fringes appear where the extra path travelled by light from neighbouring grooves is a whole number of wavelengths. The larger the order m, the wider the spectrum is spread — but fewer orders fit before sinθ would exceed 1, which caps the maximum order at mmax = d ÷ λ (rounded down). Angles here are measured from the normal — the line perpendicular to the grating — never from the grating surface itself.

SymbolMeaningUnits
dgroove spacing — centre-to-centre distance of neighbouring groovesnm (or µm)
θdiffraction angle, measured from the normaldegrees
morder of the spectrum — 0, 1, 2, 3…— (whole number)
λwavelength of the lightnm

Why the fringes are sharp: thousands of grooves voting together

A double slit produces broad, lazy maxima because only two waves are doing the voting: drift a little away from the exact maximum angle and the two waves are only partly out of step, so the light fades gradually. A grating replaces the two voters with thousands. At the exact fringe angle every groove's wave arrives in step and the intensity is enormous; move a fraction of a degree away and, across thousands of grooves, the phase differences accumulate until for every wave there is another groove's wave exactly cancelling it. The fringe collapses to darkness almost immediately. That is the whole secret of the grating: the maxima sit at exactly the double-slit angles, d sinθ = mλ, but they are needle-sharp, and sharpness is what turns a rainbow smear into a measuring instrument.

The sharpness has a precise measure called resolving power, R = m × N, where N is the total number of grooves the light actually crosses. R says how close two wavelengths can be and still be told apart: the smallest separable difference is Δλ = λ ÷ R. A 600 lines/mm grating lit across 50 mm puts N = 30,000 grooves to work, so even in first order R = 30,000 and at 589 nm it can in principle separate lines 0.02 nm apart — thirty times finer than the famous sodium doublet needs. Widen the beam, raise the order, or rule more grooves, and the resolution climbs in direct proportion. No prism can match this, because a prism's separation is limited by how much its glass properties vary with wavelength, a far weaker lever.

m = 0 m = 1 m = 2 m = 3 each order is a full spectrum — sharp lines, wider spread as m grows

How to use

  1. Choose what to find: the wavelength from a measured angle, the angle for a known wavelength, or the groove spacing of an unknown grating.
  2. For wavelength or angle modes, enter the grating rating in lines per mm — it is printed on the grating's mount or box (300, 600 and 1200 lines/mm are the common school and laboratory values).
  3. Enter the order m (1 for the first, brightest spectrum either side of centre) and the angle or wavelength asked for.
  4. Click "Calculate". If the calculator reports that no fringe exists, mλ/d has exceeded 1: that order simply does not occur for that grating and wavelength — drop to a lower order.

Worked examples

Example 1 — the standard laboratory grating. A 600 lines/mm grating has d = 1,000,000 ÷ 600 = 1666.67 nm. For λ = 550 nm in first order (m = 1): sinθ = 550 ÷ 1666.67 = 0.33, so θ = 19.27°. Checking the other way: at θ = 20°, λ = 1666.67 × sin20° = 570.03 nm. The finest detail: since sinθ cannot exceed 1, the highest order this grating shows for 550 nm light is m = 1666.67 ÷ 550 = 3.

Example 2 — resolving the sodium doublet. Sodium light is really two yellow lines, 589.0 and 589.6 nm. With the 600 lines/mm grating in second order, sinθ = 2 × 589 ÷ 1666.67 = 0.7068, giving θ = 44.98°, and the twin line sits 0.058° further out — a small but easily measured gap on a spectrometer scale. The resolving power needed is only R = 589 ÷ 0.6 ≈ 982, which a beam covering just 1.64 mm of this grating (982 grooves) already provides in first order.

Example 3 — a coarse grating spreads less. A 300 lines/mm grating has d = 3333.33 nm. Green light of 500 nm appears at sinθ = 0.15, θ = 8.63° in first order, at 17.46° in second order and at 26.74° in third — six orders exist in total for this wavelength (3333.33 ÷ 500 = 6). Coarse gratings give many dim, narrowly spread orders; fine gratings give few, wide, bright ones.

Example 4 — the rainbow on a CD. A CD's track spiral is a grating with spacing 1.6 µm = 1600 nm. Red light of 650 nm diffracts in first order at sinθ = 650 ÷ 1600 = 0.406, θ = 23.97° — the angle at which a CD flashes red. A DVD's tighter tracks (740 nm spacing) throw the same red to 61.45°, while a Blu-ray disc's 320 nm spacing is finer than any visible wavelength, so at normal incidence it produces no diffracted order at all: the colours you see on discs appear at oblique angles, where the geometry changes.

Example 5 — identifying an unknown gas. A discharge lamp's green line is measured at θ = 40.94° in first order through a 1200 lines/mm grating (d = 833.33 nm). Then λ = 833.33 × sin40.94° = 546.1 nm — the signature green line of mercury vapour. This is exactly how unknown gases are identified: measure angles, compute wavelengths, and match the pattern against known fingerprints. Note this grating shows only one order for this line (833.33 ÷ 546.1 = 1).

Example 6 — angular dispersion. How fast the spectrum spreads is given by dθ/dλ = m ÷ (d cosθ). For the 600 lines/mm grating at 550 nm in first order this is 0.0364° per nanometre, so the sodium doublet's 0.6 nm gap opens only 0.022° in first order — but in second order the dispersion rises to 0.0972°/nm and the gap widens to 0.058°. Working in higher orders is the spectroscopist's zoom lens, bought at the price of dimmer spectra and overlapping orders.

Diffraction gratings in real life

Astronomy. Every modern telescope spectrograph is grating-based. Spreading starlight into a high-order spectrum reveals the star's composition, temperature, rotation and radial velocity — the exoplanet-hunting spectrographs that detect a star wobbling by less than a walking pace rely on gratings resolving one part in 100,000.

Chemical fingerprinting. Flame tests and discharge lamps identify elements by their line spectra. A grating spectrometer turns the pretty colours into precise wavelengths — 546.1 nm means mercury, 589 nm means sodium — used in everything from water-quality testing to forensic analysis.

Telecommunications. Fibre networks pack dozens of wavelength channels down one fibre (dense wavelength-division multiplexing). Grating-based demultiplexers at the receiving end fan the channels back out by angle, each to its own detector.

Pulse compression in lasers. Chirped-pulse amplification — the technique behind the most intense laser pulses ever made, recognised by the 2018 Nobel Prize — stretches and recompresses laser pulses with pairs of diffraction gratings.

Everyday rainbows. CDs, DVDs, holograms on bank cards and the iridescent films on soap bubbles' engineered cousins all exploit grating or thin-film geometry. The CD example above shows the numbers are the same ones this calculator solves.

X-ray and neutron science. At wavelengths too short for ruled grooves, nature provides the grating: crystal lattices themselves. X-ray crystallography — the method that revealed DNA's double helix — is the grating equation applied to atomic spacings.

m = 1 spectrum m = 2 — same colours, stretched wider higher order = more spread, finer detail, dimmer light

Overlapping orders and how spectroscopists cope

The grating equation has an ambiguity built into it: the product mλ is all that matters. Second-order violet at 400 nm (mλ = 800) lands at exactly the same angle as first-order infrared at 800 nm, and third-order ultraviolet at 300 nm (mλ = 900) overlaps second-order blue-green at 450 nm. A raw grating spectrum is therefore a pile-up of several spectra sharing the same angles. Instruments untangle them with order-sorting filters — a red filter that blocks the ultraviolet before it can masquerade as red, for instance — or with a second, weak disperser at right angles (cross-dispersion), which fans the orders into separate rows on the detector like the rungs of a ladder. The echelle spectrographs on large telescopes work deliberately at orders m = 30–100, where resolving power is immense, and rely entirely on cross-dispersion to keep the ladder readable. When you use this calculator, remember that every angle it gives is shared by all the (m, λ) pairs with the same product — a feature for the expert, a trap for the unwary.

Quick reference: common gratings

Rating (lines/mm)Groove spacing dHighest order at 550 nm
10010,000 nm (10 µm)18
3003,333 nm6
6001,667 nm3
1200833 nm1
1800556 nm1
2400417 nm0 — too fine for 550 nm

Read the table as a design trade-off: fine gratings spread a spectrum dramatically but run out of orders, and below d = λ they cannot diffract that wavelength at all. The 600 lines/mm grating is the laboratory workhorse precisely because it balances three usable orders against a comfortable spread for the whole visible range.

One practical habit separates clean measurements from confusing ones: always record which order you are observing alongside the angle. A line at 19.27° from a 600 lines/mm grating is 550 nm in first order, but the same angle in second order would mean 275 nm ultraviolet — the calculator will happily solve either, and only your notebook knows which spectrum you actually saw.

Common mistakes

  • Measuring θ from the grating surface instead of the normal. The equation uses the angle from the perpendicular. A fringe "30° from the surface" is at 60° in the equation — swapping them changes sinθ from 0.5 to 0.87 and ruins the wavelength.
  • Using the lines-per-mm rating as d. The rating is the reciprocal of the spacing. For 600 lines/mm, d is 1,000,000 ÷ 600 = 1666.67 nm, not 600 of anything. Every order-of-magnitude disaster in grating work starts here.
  • Mixing nanometres and micrometres. d often comes out in micrometres (1.667 µm) while λ is quoted in nanometres (550 nm). Convert both to the same unit before dividing, or the sine comes out a thousand times too big or small.
  • Assuming every order exists. If mλ/d exceeds 1 there is no fringe at that order — the calculator says so, and it is geometry talking, not an error. Check mmax = d/λ before planning a measurement.
  • Forgetting the zeroth order. At m = 0 all wavelengths overlap at θ = 0 in an undispersed white image. Students sometimes measure from this bright central image to the wrong spectrum, or mistake it for a first-order line.

FAQ

Why do higher orders spread colours more?
From sinθ = mλ/d, doubling m doubles the sine for every wavelength, so the whole spectrum stretches over a wider range of angles. That is why spectrometers often work in second or third order for finer detail.

What limits the highest order I can see?
Since sinθ cannot exceed 1, the maximum order is m = d/λ (rounded down). For a 600 lines/mm grating and 550 nm light that is m = 3.

How is a grating different from a double slit?
A grating has thousands of grooves instead of two slits. The bright fringes sit at the same angles as the double-slit maxima, but they are far sharper and brighter because so many waves reinforce there.

What does the zeroth order look like?
An undispersed image of the light source in its original colour — white for white light — straight ahead at θ = 0. All wavelengths satisfy d sinθ = mλ trivially when m = 0, so no spectrum forms; the zeroth order is bright but analytically useless, and good gratings are blazed to steal its light for the useful orders.

What is a blazed grating?
One whose grooves are cut with a sawtooth profile that tilts each groove's face, concentrating the diffracted light into a chosen order and wavelength range instead of spreading it evenly. Most research gratings are blazed; a grating's efficiency curve peaks near its blaze wavelength.

Can a grating measure wavelengths longer than its groove spacing?
Yes, provided d exceeds λ so that at least the first order exists — a 100 lines/mm grating (d = 10 µm) works well into the infrared. But for λ greater than d there is no diffracted order at all, only the zeroth.

Why are grating spectra brighter on one side than the other?
Real grooves are not symmetric slits; their profile and the direction of illumination throw more light into the +m orders than the −m orders (or vice versa). The angles are identical on both sides — only the brightness differs.

How accurate can a grating wavelength measurement be?
With a good spectrometer, angles can be read to a few thousandths of a degree, giving wavelengths to about 0.01 nm — good enough to split the sodium doublet (0.6 nm apart) sixty times over and to detect the tiny shifts astronomers use to measure stellar motions.

What is the difference between a transmission and a reflection grating?
Geometry only. A transmission grating diffracts light passing through it; a reflection grating — the commoner laboratory type, including replica gratings on plastic film and the surface of a CD — diffracts light bouncing off it. The same equation, d sinθ = mλ, governs both in the standard near-normal arrangements.

Why do spectrometers use a slit as well as a grating?
The grating sets the angles, but the image it forms is an image of whatever light entered. A narrow entrance slit gives each wavelength a thin, sharp line to measure; without it, the coloured images of a wide source overlap and the resolution the grating paid for is wasted.

David Okafor

David Okafor

Physics Writer · Waves & Light

David Okafor creates and reviews our waves, sound and optics calculators at CalcVIP. Every calculator is checked against hand-worked examples before it is published, so the formula, the diagram and the answer all agree.

View full profile & all calculators by Okafor →