---
title: Diffraction gratings and spectrometers
heading: Sorting light by wavelength, and how finely it can be done
eyebrow: B8 · Lesson 11 · Gratings and spectrometers
xp: 40
---

::: hook
A spectrometer spreads light into its colors so finely that it can tell the two yellow lines of sodium apart, 0.6 nm in 589, and from the lines in starlight tell what a star is made of and how fast it's moving. The device at its heart is a grating: a surface ruled with hundreds or thousands of parallel lines per millimeter. The rainbow on a CD is the same effect. Optical networks use gratings to separate 80 data channels packed 0.8 nm apart, and gratings written inside fibers sense strain and temperature along bridges and pipelines.
:::

::: play
- The pattern from $N$ slits a distance $d$ apart, for two wavelengths close together, plotted against $\sin\theta$.
- The bright lines sit where $d\sin\theta = m\lambda$. Raise $N$: they stay put but get much narrower.
- Make the two wavelengths closer until their first-order lines merge. The readout gives the smallest difference $N$ slits can separate.
:::
:::

```sim plot
view: graph
x: s = 0..0.7
y: I = 0..1
slider: N = 2..60 step 1 = 10
slider: d = 1..4 step 0.1 = 2 µm
slider: lam = 400..700 step 1 = 600 nm
slider: dl = 1..40 step 0.5 = 20 nm
plot: (sin(N*pi*d*1000*s/lam + 1e-9)/(N*sin(pi*d*1000*s/lam + 1e-9)))^2 | label: λ | samples: 3000
plot: (sin(N*pi*d*1000*s/(lam + dl) + 1e-9)/(N*sin(pi*d*1000*s/(lam + dl) + 1e-9)))^2 | label: λ + Δλ | color: ch2 | samples: 3000
readout: first-order angle, ° = asin(lam/(d*1000))*180/pi | digits: 3
readout: smallest resolvable Δλ in first order, nm = lam/N | digits: 3
```

::: predict
## A grating 10 mm wide has 1200 lines per mm. Can it separate the sodium lines at 589.0 and 589.6 nm in first order?

- [x] Easily: it can separate lines about 0.05 nm apart
- [ ] Just barely
- [ ] No: the lines are only 0.1% apart
- [ ] Only in the tenth order

::: reveal
Easily. A grating's resolving power in order $m$ is $mN$, the order times the number of lines lit. Here $N = 12{,}000$, so it separates wavelengths $589/12{,}000 = 0.05$ nm apart, a dozen times finer than the sodium pair needs.
:::
:::

::: nameit
## The grating equation

A grating with line spacing $d$ (often given as lines per millimeter, $1/d$) sends light of wavelength λ into the directions where neighboring lines' waves arrive in step:

$$d\sin\theta_m = m\lambda$$

For light arriving at angle $\theta_i$, the left side becomes $d(\sin\theta_i + \sin\theta_m)$. Order $m = 0$ is straight through, with every color together. Since $\sin\theta \le 1$, only orders up to $m \le d/\lambda$ exist.

## Dispersion

How much the angle changes with wavelength, the **angular dispersion**, follows from differentiating the grating equation:

$$\frac{d\theta}{d\lambda} = \frac{m}{d\cos\theta}$$

A spectrometer focuses each direction to a point on a detector with a lens or mirror of focal length $f$, so colors spread along the detector by $f\frac{d\theta}{d\lambda}$ per unit wavelength.

## Resolving power

With $N$ lines lit, each bright line has an angular width set by the whole grating's width, and two wavelengths are separable when one's peak falls on the other's first zero (the Rayleigh criterion from lesson 10). That gives the **resolving power**

$$R = \frac{\lambda}{\Delta\lambda} = mN$$

More lines lit, or a higher order, resolve finer detail. Spreading the colors wider with a longer focal length doesn't help if $N$ is small.

## Gratings in engineering

- **Spectrometers**, from lab instruments to the chip-sized ones in color sensors.
- **Wavelength-division multiplexing:** gratings and arrayed waveguides separate dozens of laser channels on one fiber.
- **Fiber Bragg gratings:** a periodic index change of period Λ written into a fiber's core reflects one wavelength, $\lambda_B = 2n\Lambda$. Stretching or warming the fiber shifts it, so a single fiber with many gratings is a chain of strain and temperature sensors.
:::

::: example
## Where do the orders of 550 nm light land for a grating with 600 lines/mm?

::: solution
1. **Line spacing.**
   $$\begin{aligned} d &= \frac{1}{600}\ \text{mm} \\ &= 1.667\ \mu\text{m} \end{aligned}$$
2. **Angles of the orders.** Here $\lambda/d = 0.33$, so
   $$\sin\theta_m = m \times 0.33$$
   which gives 19.3° for $m = 1$, 41.3° for $m = 2$ and 81.9° for $m = 3$.
3. **No fourth order.** A fourth order would need $\sin\theta = 1.32$, so there are three orders on each side.

**Answer:** the orders land at 19.3°, 41.3° and 81.9°, three on each side.
:::
:::

::: example
## For the same grating, how much does the first-order angle change per nanometer of wavelength? And with a 300 mm focal length?

::: solution
1. **Angular dispersion in first order.**
   $$\begin{aligned} \frac{d\theta}{d\lambda} &= \frac{1}{1667\text{ nm} \times \cos 19.3°} \\ &= 6.36 \times 10^{-4}\ \text{rad/nm} \end{aligned}$$
   or 0.64 mrad/nm.
2. **On the detector.** With a 300 mm focal length,
   $$\begin{aligned} f\frac{d\theta}{d\lambda} &= 300 \times 0.000636 \\ &= 0.19\ \text{mm/nm} \end{aligned}$$

**Answer:** the angle changes by 0.64 mrad per nanometer, which spreads the colors 0.19 mm per nanometer on the detector.
:::
:::

::: example
## A CD's tracks are 1.6 µm apart and act as a reflection grating. At what angles does white light at normal incidence send violet (400 nm) and red (700 nm) in first order?

::: solution
1. **First-order angle.** At normal incidence,
   $$\sin\theta = \frac{\lambda}{d}$$
2. **Violet.**
   $$\begin{aligned} \theta &= \sin^{-1}\frac{0.4}{1.6} \\ &= 14.5° \end{aligned}$$
3. **Red.**
   $$\begin{aligned} \theta &= \sin^{-1}\frac{0.7}{1.6} \\ &= 25.9° \end{aligned}$$
4. **The rainbow.** The first-order rainbow spans about 11°, which is why a CD tilted under a lamp flashes through the colors.
5. **A DVD.** A DVD's tracks are 0.74 µm apart, more than twice as dense, so its first-order rainbow sits at much steeper angles.

**Answer:** violet leaves at 14.5° and red at 25.9°.
:::
:::

::: check
given: L = 600 | 1000 | 1200; lam = 450 | 650
answer: asin(lam*L*1e-6)*180/pi
unit: °
tolerance: 0.5%

## A grating has {L} lines/mm. At what angle does first-order {lam} nm light leave?

::: right
Right. $\sin\theta = \lambda/d$ = {answer}.
:::

::: misses
- [lam*L*1e-6*180/pi] Take the arcsine: the grating sets $\sin\theta$.
- [any] Not yet. $d = 1/L$, then $\sin\theta = \lambda/d$.
:::
:::

::: check
given: L = 150 | 300; lam = 480 | 700
answer: floor(1e6/(L*lam))
tolerance: 0.1%

## A grating with {L} lines/mm is lit with {lam} nm light at normal incidence. What is the highest order it produces?

::: right
Right. The largest whole number below $d/\lambda$: {answer}.
:::

::: misses
- [round(1e6/(L*lam))] Round down: an order needs $\sin\theta \le 1$.
- [any] Not yet. Find $d/\lambda$ and round down.
:::
:::

::: check
given: m = 2 | 3 | 4
answer: 589.3/0.6/m
tolerance: 1%

## How many grating lines must be lit to just separate the sodium lines, 589.0 and 589.6 nm, in order {m}?

::: right
Right. $N = \frac{\lambda}{m\Delta\lambda}$ = {answer}.
:::

::: misses
- [589.3/0.6] Higher orders multiply the resolving power by $m$.
- [any] Not yet. Solve $\lambda/\Delta\lambda = mN$.
:::
:::

::: check
given: L = 600 | 1200; lam = 450 | 550
answer: L*1e-3/cos(asin(lam*L*1e-6))
unit: mrad/nm
tolerance: 0.5%

## A grating with {L} lines/mm diffracts {lam} nm light in first order. What is its angular dispersion there?

::: right
Right. $\frac{1}{d\cos\theta}$ = {answer}.
:::

::: misses
- [L*1e-3] Include $\cos\theta$: the dispersion grows at steep angles.
- [any] Not yet. Differentiate $d\sin\theta = \lambda$.
:::
:::

::: check
given: lam = 532 | 633; th = 20 | 35
answer: lam/sin(th°)/1000
unit: µm
tolerance: 0.5%

## A {lam} nm laser makes its first-order spot at {th}° from straight through. What is the grating's line spacing?

::: right
Right. $d = \lambda/\sin\theta$ = {answer}.
:::

::: misses
- [lam/cos(th°)/1000] The grating equation uses $\sin\theta$.
- [any] Not yet. Solve $d\sin\theta = \lambda$.
:::
:::

::: check
given: P = 520 | 530 | 545
answer: 2*1.447*P
unit: nm
tolerance: 0.5%

## A fiber Bragg grating has a period of {P} nm in a core of index 1.447. What wavelength does it reflect?

::: right
Right. $\lambda_B = 2n\Lambda$ = {answer}.
:::

::: misses
- [1.447*P] It's $2n\Lambda$: the reflections from neighboring periods must arrive in step after a round trip.
- [any] Not yet. $\lambda_B = 2n\Lambda$.
:::
:::

::: check
kind: parts
given: N = 300 | 600 | 1200; l = 450 | 650

## A grating has {N} lines per millimeter and is lit at normal incidence with {l} nm light.

::: part
answer: asin(l*1e-9*N*1e3)*180/pi
unit: °
tolerance: 0.5%

### At what angle is the first order?

::: misses
- [any] $\sin\theta = \frac{\lambda}{d}$ with $d = \frac1N$.
:::
:::

::: part
answer: floor(1/(l*1e-9*N*1e3))
tolerance: 0.5%

### What is the highest order that appears?

::: misses
- [any] $\sin\theta$ can't exceed 1: $m \le \frac{d}{\lambda}$.
:::
:::
:::

::: check
kind: derivation
vars: d = 0.0000008..0.000005, l = 0.0000004..0.0000007, m = 1..2, W = 0.001..0.05

## A grating of spacing d and width W.

::: step
answer: asin(m*l/d)

### At what angle is order m of wavelength λ (write l)?
:::

::: step
answer: m*W/d

### What is its resolving power $\frac{\lambda}{\Delta\lambda}$ in order m?
:::

::: right
Right. The resolving power is the order times the number of lines lit, $\frac Wd$.
:::
:::

::: explain
## Why does a grating with many lines give much sharper bright lines than two slits at the same spacing?

::: model
At an exact bright direction, every line's wave arrives in step, whether there are two lines or a thousand. Move slightly off that direction and with two slits the waves drift out of step only slowly, so the brightness falls off gently. With a thousand lines, a tiny change in angle puts the waves from the far edge of the grating half a wavelength out of step with those in the middle, and the contributions from across the grating cancel. The peak's width shrinks in proportion to the number of lines.
:::
:::

::: practice

::: check
given: L = 150 | 300 | 600 | 1200 | 1800 | 2400
answer: 1000/L
unit: µm
tolerance: 0.5%

## What is the line spacing of a grating with {L} lines/mm?

::: misses
- [any] $d = 1/L$.
:::
:::

::: check
given: N = 1000 | 5000; m = 1 | 2
answer: m*N
tolerance: 0.5%

## What is the resolving power of a grating with {N} lines lit, in order {m}?

::: misses
- [any] $R = mN$.
:::
:::

::: check
given: lam = 500 | 1550; R = 1000 | 20000
answer: lam/R
unit: nm
tolerance: 0.5%

## A spectrometer has resolving power {R}. What is the smallest wavelength difference it separates at {lam} nm?

::: misses
- [any] $\Delta\lambda = \lambda/R$.
:::
:::
:::
