Diffraction Grating Calculator
Enter the grating line density, light wavelength and diffraction order to find the angle of the maximum.
What this calculator returns
The output is the diffraction angle θ in degrees for one chosen order n. At the defaults — a grating of 600 lines/mm, light at 500 nm and first order — the angle is 17.46°. If nλ is larger than the line spacing, no maximum exists at that order and the result is undefined.
Getting the line spacing right first
The equation works in metres, but gratings are sold in lines per millimetre. Convert before you start: d = 1 ÷ (lines per mm × 1000). A 600 line/mm grating has 600,000 lines per metre, so d = 1 ÷ 600,000 = 1.6667 × 10−6 m, or 1666.7 nm.
That spacing is only about three times the wavelength of green light, which is why such a grating spreads visible light across wide angles. A coarser 100 line/mm grating has d = 10,000 nm and produces maxima packed close to the straight-through direction.
A useful sanity check before you compute anything: d should always be a few hundred to a few thousand nanometres for visible-light work. If your spacing comes out below 300 nm, no visible order can exist; if it comes out above 20,000 nm, the maxima will be almost impossible to separate by eye.
Worked example at the defaults
With N = 600 lines/mm, λ = 500 nm = 500 × 10−9 m and n = 1: sinθ = nλ ÷ d = (1 × 500 × 10−9) ÷ (1.6667 × 10−6) = 0.300. Then θ = arcsin(0.300) = 17.46°, which is what the calculator prints.
The second order doubles the numerator, so sinθ = 0.600 and θ = 36.87°. The third gives 0.900 and 64.16°. The fourth would need sinθ = 1.200, which no angle can satisfy, so the pattern stops at three orders on each side.
Orders for 600 lines/mm at 500 nm
| Order n | sinθ | Angle θ | Notes |
|---|---|---|---|
| 0 | 0 | 0° | Straight-through beam |
| 1 | 0.300 | 17.46° | Default result |
| 2 | 0.600 | 36.87° | Weaker, more spread out |
| 3 | 0.900 | 64.16° | Grazing, low intensity |
| 4 | 1.200 | none | Physically impossible |
Why higher orders vanish
The maximum order is the largest integer below d ÷ λ. Here 1666.7 ÷ 500 = 3.33, so orders 0 to 3 exist and order 4 does not. Push the wavelength to 600 nm and the ratio drops to 2.78, leaving only two orders; drop to 400 nm and 4.17 allows four.
How far apart the colours land
| Wavelength | sinθ (n = 1) | Angle |
|---|---|---|
| 400 nm (violet) | 0.240 | 13.89° |
| 500 nm (green) | 0.300 | 17.46° |
| 600 nm (orange) | 0.360 | 21.10° |
| 700 nm (red) | 0.420 | 24.83° |
The red end lands about 11° further out than the violet end in first order, which is the visible rainbow a grating throws on a wall. In second order the same 300 nm span stretches across roughly 28°, and third order spreads it wider still but at much lower brightness.
Angular dispersion
The rate of change near the first-order maximum is dθ/dλ = n ÷ (d cosθ). With cos(17.46°) = 0.954, that is 1 ÷ (1.6667 × 10−6 × 0.954) = 6.3 × 105 rad/m, or about 0.036° per nm. A 100 nm band therefore spreads over 3.6°, matching the 13.89° to 17.46° step in the table.
What moves the angle
- Wavelength: longer light bends further, red further than blue at every order.
- Line density: doubling to 1200 lines/mm halves d to 833.3 nm and pushes first order from 17.46° to 36.87°.
- Order: each step up multiplies sinθ by the same factor, so order 2 sits near 36.87° rather than double 17.46°.
- Grating constant: a coarse 300 line/mm grating halves the angle to 8.63° for the same 500 nm light.
- Index of the surrounding medium: immersing the grating in liquid shortens the effective wavelength and shrinks every angle.
Check the 300 line/mm case: d = 3333.3 nm, sinθ = 500 ÷ 3333.3 = 0.150, and arcsin(0.150) = 8.63°. Halving the line density halves sinθ, but because arcsin is nonlinear the angle does not simply halve from 17.46°.
Mistakes that break the result
The first is unit mixing. Entering d in nanometres while λ is in metres gives an error of 109. Keep both in metres, or both in nanometres, and the ratio is safe because it is dimensionless.
The second is confusing lines per mm with lines per metre. A 600 line/mm grating is 600,000 lines/m, not 600. Using 600 directly makes d 1000 times too large and collapses every angle toward zero.
The third is expecting a result at high order for coarse light. If the calculator returns nothing, the order simply does not exist for that spacing and wavelength; reduce n or use a finer grating rather than adjusting the wavelength to force a number.
Resolving power
A grating separates two close wavelengths by R = nN, where N is the total number of illuminated lines. A 25 mm wide patch of a 600 line/mm grating has 15,000 lines, so first order resolves R = 15,000 and second order 30,000. At 500 nm that first-order figure means a smallest resolvable gap of 500 ÷ 15,000 = 0.033 nm.
- 600 lines/mm gives d = 1666.7 nm, about 3.3 wavelengths of 500 nm light.
- 1200 lines/mm halves d to 833.3 nm and leaves only one visible order at 500 nm.
- 300 lines/mm doubles d to 3333.3 nm and moves first order in to 8.63°.
Frequently asked questions
What is the diffraction grating equation?
It is d sinθ = nλ: spacing times the sine of the angle equals order times wavelength. For d = 1666.7 nm, λ = 500 nm and n = 1, sinθ = 0.300 and θ = 17.46°.
How do I find the line spacing d?
Take the reciprocal of the line density in lines per metre. A 600 line/mm grating has 600,000 lines/m, so d = 1 ÷ 600,000 = 1.6667 × 10−6 m.
Why does my grating show only three orders?
The highest order is the integer below d ÷ λ. At 1666.7 nm spacing and 500 nm light, 1666.7 ÷ 500 = 3.33, so orders 0 through 3 exist and order 4 cannot.
Why is red diffracted more than blue?
Angle rises with wavelength. At 600 lines/mm in first order, 400 nm lands at 13.89° and 700 nm at 24.83°, a gap of nearly 11°.
What happens if I double the lines per mm?
Halving d doubles sinθ. Going from 600 to 1200 lines/mm moves 500 nm first order from 17.46° to 36.87°, and cuts the number of visible orders from three to one.
Can the angle exceed 90 degrees?
No. When nλ ÷ d is greater than 1 there is no real angle, and the calculator returns no maximum. That is a physical cutoff, not a rounding issue.
What is the angular dispersion?
It is dθ/dλ = n ÷ (d cosθ). At the defaults that works out to about 0.036° per nm in first order, so a 100 nm band spreads over 3.6°.
How many lines do I need to resolve two wavelengths?
Use R = nN. To separate 500.00 nm from 500.01 nm you need R = 50,000, which is 50,000 illuminated lines in first order or 25,000 in second.
Why do gratings create rainbows?
Each wavelength satisfies the equation at a different angle. White light therefore splits, with 400 nm at 13.89° and 700 nm at 24.83° under the default setup.
Method and sources
- Diffraction grating equation d sin θ = nλ; line spacing d = 1/(lines per metre).