Diffraction Grating Calculator

Find where each order of a diffraction grating goes, how many orders exist, and how finely the grating can separate wavelengths.

🌈 Diffraction Grating Calculator
Wavelength λ
nm
Describe the grating by
Grating valuelines/mm or µm, as chosen above
Angle of incidence and order0° is head on
Incidence angle (°)
Order m (whole number)
Known light and measurementnormal incidence
Wavelength (nm)
Order m
Measured angle of that order
°
Wavelength and grating
Wavelength (nm)
Lines per mm
Illuminated width and order
Width lit (mm)
Order m
Wavelength gap to separate (optional)leave blank to skip
nm
Angle of the chosen order
—
Slit spacing d
—
Ruling density
—
Highest order (positive side)
—
Beams in total (with m = 0)
—
λ / d
—

The table lists every observable order. Positive and negative orders lie on opposite sides of the normal, and the order you chose is in bold.

Lines per mm
—
Slit spacing d
—
Lines per cm
—
Highest order (each side)
—
Beams in total
—

Resolving power R = mN
—
Smallest resolvable Δλ
—
Illuminated lines N
—
Highest order
—
Slit spacing d
—
Lines needed for your Δλ
—

🌈 What is a Diffraction Grating Calculator?

A diffraction grating is a surface with a large number of equally spaced parallel lines or slits. When light passes through it, or reflects from it, each slit sends out its own wave, and the waves add up. In most directions they cancel. In a few special directions they arrive in step and reinforce, producing bright, narrow beams called orders. The directions are given by the grating equation d sin θ = m λ, where d is the spacing between neighbouring lines, λ is the wavelength and m is the whole number that labels the order. This calculator solves that equation for the angle of any order, for the number of lines per millimetre, and for the largest order that can exist.

Gratings are the working part of most spectrometers. Astronomers use them to spread starlight into spectra and read the chemical makeup of stars. Chemists use them to measure absorption and emission lines, and physics students use them to measure the wavelength of a laser or a sodium lamp. In optical communications a grating can combine or separate channels at different wavelengths, and the shiny rainbow on the surface of a compact disc is a natural grating made of tightly spaced tracks. Because the angle depends on the wavelength, every order above zero is a spread-out spectrum, with the shortest wavelength closest to the straight-through beam.

There are a few ideas that cause errors. The central maximum, m = 0, always goes straight through, whatever the wavelength. The order number is limited, because sin θ can never be larger than 1, so the highest order is the largest whole number below d / λ. The formula changes if the light arrives at an angle, and this page includes the incidence angle for that reason. Finally, the sharpness of the lines depends on the total number of lines that are lit. That is described by the resolving power R = m N, which tells you the smallest difference in wavelength that the grating can separate.

The three modes cover the usual lab and exam questions. Order angles gives the direction of each beam, with a table and a chart of all the orders. Find the grating works backwards from a measured angle to the ruling. Resolving power tells you whether a grating can split a close pair such as the sodium doublet. For the speed that links wavelength and frequency, see the speed of light calculator.

📐 Formula

d (sin θm − sin θi) = m λ    R = λ / Δλ = m N
d = spacing between adjacent lines. From the density, d = 1 / (lines per unit length), so 600 lines/mm gives d = 1.667 µm.
θm = angle of the order m beam, measured from the grating normal. θi = angle of incidence (0° for head-on light, which reduces the equation to d sin θ = m λ).
m = order, a whole number. m = 0 is the undeviated beam. Positive and negative orders lie on opposite sides.
λ = wavelength of the light in the same unit as d (this page takes nm and µm and converts).
Maximum order: the largest whole m for which |sin θi + m λ / d| is less than 1. At normal incidence this is the largest integer below d / λ.
Resolving power: R = m N, with N the number of lines that are illuminated. The smallest resolvable difference is Δλ = λ / (m N).
Inverse: d = m λ / sin θ at normal incidence, then lines per mm = 1 / d with d in mm.
Example: λ = 550 nm, 600 lines/mm: sin θ = 0.55 / 1.6667 = 0.33, so θ1 = 19.27°.

📖 How to Use This Calculator

Steps

1
Choose a mode. Use Order angles to find where the beams go, Find the grating to work back from a measured angle, or Resolving power to see how finely the grating separates wavelengths.
2
Enter the wavelength and the grating. Type the wavelength in nanometres. Choose whether you are entering lines per millimetre or the spacing in micrometres, then type the value. Add an angle of incidence if the beam is tilted.
3
Pick the order. Enter the whole number m. If no such beam exists, the result says Not observed and gives the highest order that does.
4
Read the results. You get the angle, the spacing, the highest order and the beam count. A table lists every order, and the chart shows how the angle changes with order.

💡 Example Calculations

Example 1 — Green Light on a 600 Lines/mm Grating

550 nm light at normal incidence, 600 lines/mm, first order

1
d = 1000 / 600 = 1.6667 µm = 1666.7 nm.
2
sin θ = m λ / d = 550 / 1666.7 = 0.33000.
3
θ = arcsin(0.33) = 19.269°. Since λ / d = 0.33, the third order (sin = 0.99) still exists, giving a highest order of 3 and 7 beams in total.
First-order angle = 19.269°, highest order = 3
Try this example →

Example 2 — Second Order of Sodium Light

589 nm light, 300 lines/mm, second order

1
d = 1000 / 300 = 3.3333 µm = 3333.3 nm.
2
sin θ = 2 × 589 / 3333.3 = 0.35340.
3
θ = arcsin(0.3534) = 20.695°.
Second-order angle = 20.695°
Try this example →

Example 3 — Light Arriving at 30 Degrees

400 nm light at 30° incidence, 1000 lines/mm, first order

1
d = 1000 / 1000 = 1.0000 µm, so λ / d = 0.4.
2
sin θ = sin 30° + 1 × 0.4 = 0.5 + 0.4 = 0.90000.
3
θ = arcsin(0.9) = 64.158°. Orders +1 to the right and −1, −2, −3 to the left exist, so the highest positive order is 1 and there are 5 beams.
First-order angle = 64.158°, 5 beams
Try this example →

Example 4 — Finding the Ruling From a Laser

A 632.8 nm helium-neon laser gives its second-order spot at 20°

1
d = m λ / sin θ = 2 × 632.8 / sin 20° = 1265.6 / 0.34202 = 3700.4 nm = 3.7004 µm.
2
Lines per mm = 1000 / 3.7004 = 270.24.
3
λ / d = 0.17101, so orders up to 5 exist (5 × 0.171 = 0.855 < 1) and the total is 11 beams.
Ruling = 270.24 lines/mm, d = 3.7004 µm
Try this example →

Example 5 — Resolving the Sodium Doublet

589.3 nm, 600 lines/mm, 10 mm of the grating lit, first order, doublet gap 0.597 nm

1
N = 600 × 10 = 6000 lines, so R = m N = 6000.
2
Δλ = 589.3 / 6000 = 0.0982 nm, much finer than the 0.597 nm gap.
3
Lines needed = 589.3 / (1 × 0.597) = 987.1, which rounds up to 988 lines (1.65 mm of the grating).
R = 6000, Δλ = 0.0982 nm, lines needed = 988
Try this example →

Example 6 — An Order That Does Not Exist

700 nm light, 300 lines/mm, order 5

1
d = 3333.3 nm, so λ / d = 0.21000.
2
sin θ = 5 × 0.21 = 1.05, which is greater than 1, so there is no solution.
3
The highest order is 4 (4 × 0.21 = 0.84), so there are 9 beams including the central one.
Order 5 = Not observed, highest order = 4
Try this example →

❓ Frequently Asked Questions

What is the diffraction grating equation?+
For light at normal incidence the maxima satisfy d sin(theta) = m lambda, where d is the spacing between lines, theta the angle from the normal, m the order (0, 1, 2 and so on) and lambda the wavelength. For 550 nm light on a 600 lines/mm grating the first order is at 19.27 degrees.
How do you convert lines per mm to slit spacing?+
Divide 1 mm by the number of lines: d = 1 / N. For 600 lines/mm, d = 1/600 mm = 1.667 micrometres. For 300 lines/mm, d = 3.333 micrometres.
How do you find the maximum order of a grating?+
The sine of the angle cannot exceed 1, so m must be less than d / lambda. For d = 1.667 micrometres and 550 nm, d / lambda = 3.03, so the highest order is 3. The calculator counts both sides of the central maximum, here 7 beams.
Why does a grating split white light into colours?+
The angle of each order depends on the wavelength through sin(theta) = m lambda / d. Each colour therefore leaves at its own angle, and every order above zero is a spectrum with violet closest to the central beam and red farthest.
What is the resolving power of a diffraction grating?+
Resolving power is R = lambda / delta lambda = m N, where N is the number of illuminated lines. A grating lit over 6000 lines in the first order has R = 6000 and can separate lines 0.098 nm apart near 589.3 nm.
How many lines are needed to resolve the sodium doublet?+
The two sodium D lines are about 0.597 nm apart near 589.3 nm. In the first order you need N of at least 589.3 / 0.597, which rounds up to 988 lines. A 600 lines/mm grating therefore needs about 1.65 mm of its width illuminated.
What happens when the light does not hit the grating head on?+
The equation becomes d (sin(theta_m) - sin(theta_i)) = m lambda. With 400 nm light at 30 degrees incidence on a 1000 lines/mm grating the first order is at 64.16 degrees, and the orders are no longer symmetric about the normal.
What does a diffraction grating spectrometer measure?+
It measures the angle of a spectral line. If the grating spacing and the order are known, the wavelength follows from lambda = d sin(theta) / m. Reversing it, a known laser wavelength and a measured angle give the lines per mm.
Why do higher orders overlap?+
The second-order blue can fall at the same angle as the third-order red, because m lambda is the same. Spectrometers use filters or limit the range so that the orders do not overlap.
What is the difference between a grating and a double slit?+
Both use d sin(theta) = m lambda for the bright maxima. With many slits the maxima become much narrower and brighter, so a grating gives sharp lines that can be measured accurately, while two slits give broad fringes.
Is a larger grating spacing better?+
Not for spreading colours. A larger spacing gives smaller angles and more orders but less dispersion. A finer ruling spreads the spectrum more widely, up to the point where only the first order still exists.

What is the diffraction grating equation?

For light at normal incidence the maxima satisfy d sin(theta) = m lambda, where d is the spacing between lines, theta the angle from the normal, m the order (0, 1, 2 and so on) and lambda the wavelength. For 550 nm light on a 600 lines/mm grating the first order is at 19.27 degrees.

How do you convert lines per mm to slit spacing?

Divide 1 mm by the number of lines: d = 1 / N. For 600 lines/mm, d = 1/600 mm = 1.667 micrometres. For 300 lines/mm, d = 3.333 micrometres.

How do you find the maximum order of a grating?

The sine of the angle cannot exceed 1, so m must be less than d / lambda. For d = 1.667 micrometres and 550 nm, d / lambda = 3.03, so the highest order is 3. The calculator counts both sides of the central maximum, here 7 beams.

Why does a grating split white light into colours?

The angle of each order depends on the wavelength through sin(theta) = m lambda / d. Each colour therefore leaves at its own angle, and every order above zero is a spectrum with violet closest to the central beam and red farthest.

What is the resolving power of a diffraction grating?

Resolving power is R = lambda / delta lambda = m N, where N is the number of illuminated lines. A grating lit over 6000 lines in the first order has R = 6000 and can separate lines 0.098 nm apart near 589.3 nm.

How many lines are needed to resolve the sodium doublet?

The two sodium D lines are about 0.597 nm apart near 589.3 nm. In the first order you need N of at least 589.3 / 0.597, which rounds up to 988 lines. A 600 lines/mm grating therefore needs about 1.65 mm of its width illuminated.

What happens when the light does not hit the grating head on?

The equation becomes d (sin(theta_m) - sin(theta_i)) = m lambda. With 400 nm light at 30 degrees incidence on a 1000 lines/mm grating the first order is at 64.16 degrees, and the orders are no longer symmetric about the normal.

What does a diffraction grating spectrometer measure?

It measures the angle of a spectral line. If the grating spacing and the order are known, the wavelength follows from lambda = d sin(theta) / m. Reversing it, a known laser wavelength and a measured angle give the lines per mm.

Why do higher orders overlap?

The second-order blue can fall at the same angle as the third-order red, because m lambda is the same. Spectrometers use filters or limit the range so that the orders do not overlap.

What is the difference between a grating and a double slit?

Both use d sin(theta) = m lambda for the bright maxima. With many slits the maxima become much narrower and brighter, so a grating gives sharp lines that can be measured accurately, while two slits give broad fringes.

Is a larger grating spacing better?

Not for spreading colours. A larger spacing gives smaller angles and more orders but less dispersion. A finer ruling spreads the spectrum more widely, up to the point where only the first order still exists.