Diffraction Grating Calculator
- Line spacing d = 1 / 600 lines per mm = 1.667 µm (1,667 nm).
- Grating equation: sin(theta) = m x wavelength / d = 1 x 589 / 1,667 = 0.3534.
- theta = arcsin(0.3534) = 20.70 degrees. The highest order this grating can show at 589 nm is 2.
A diffraction grating is a surface ruled with many evenly spaced lines, and it spreads light into spectra far more strongly than a prism. Our diffraction grating calculator applies the grating equation, d × sin(theta) = m × wavelength, where d is the line spacing, m is the order (0, 1, 2, ...), and theta is the angle from the straight-through direction. Because line spacing d equals 1 divided by grating density, a 600 lines/mm grating has d = 1.667 µm (1,667 nm). Enter your grating density and wavelength, and the calculator returns the diffraction angle for any order, along with the maximum order, which is the largest whole number m with m × wavelength <= d.
The grating equation is the accepted standard for this kind of calculation because it directly relates line spacing, wavelength, and diffraction angle with no empirical correction needed. This page shows the formula, step-by-step workings, worked examples, and sources. For a 600 lines/mm grating with sodium light at 589 nm in the first order, sin(theta) = 0.3534, so theta = 20.70 degrees. With green laser light at 532 nm in the second order, theta = 39.67 degrees, and the highest order possible at this wavelength is 3. For a 1,200 lines/mm grating (d = 0.833 µm) with red light at 650 nm in the first order, theta = 51.26 degrees, and no second order exists because it would need sin(theta) above 1.
Worked examples
Sodium light, first order
Primary result: 20.70° — with 1.667 µm between lines, sin of the angle is 0.3534. (600 lines/mm · 589 nm · 1)
| Diffraction angle | 20.70° |
| Grating spacing | 1.667 µm |
| sin of the angle | 0.3534 |
| Highest possible order | 2 |
Green laser, second order
Primary result: 39.67° — the second order spreads the spectrum twice as far; this grating allows up to order 3 at 532 nm. (600 lines/mm · 532 nm · 2)
| Diffraction angle | 39.67° |
| Grating spacing | 1.667 µm |
| sin of the angle | 0.6384 |
| Highest possible order | 3 |
A finer grating
Primary result: 51.26° — at 1,200 lines per mm the spacing drops to 0.833 µm and only the first order fits at 650 nm. (1200 lines/mm · 650 nm · 1)
| Diffraction angle | 51.26° |
| Grating spacing | 0.833 µm |
| sin of the angle | 0.7800 |
| Highest possible order | 1 |
The grating equation
A diffraction grating is a surface ruled with many evenly spaced lines; it spreads light into spectra far more strongly than a prism. To understand why, picture two neighboring slits in the grating. A flat wavefront arrives at both slits at the same instant. The light leaving each slit spreads outward in all directions, and the waves from the two slits overlap. In the straight-through direction, the waves travel the same distance to a distant screen and arrive in step, reinforcing each other. At an angle theta away from that straight-through direction, the wave from the lower slit must travel farther than the wave from the upper slit. Trace a line from the upper slit perpendicular to the outgoing ray from the lower slit. The extra distance the lower wave travels is exactly the side of a right triangle whose hypotenuse is the line spacing d. By basic trigonometry, that extra path length equals d times sin(theta).
Bright reinforcement occurs only when this extra path length is a whole number of wavelengths. If the extra distance is one wavelength, two wavelengths, or any whole number m times the wavelength, the waves arrive crest on crest and produce a bright line. Setting the path difference equal to m times the wavelength gives the grating equation: d x sin(theta) = m x wavelength. Here d is the line spacing, m is the order (0, 1, 2, ...), and theta is the angle measured from the straight-through direction. The zeroth order, m = 0, places all wavelengths at the center because sin(theta) = 0 for every wavelength. Higher orders spread the colors out, and a diffraction grating calculator applies this equation directly to find the angle for any combination of grating, wavelength, and order.
Line spacing d and grating density are reciprocals: d = 1 / grating density. A 600 lines/mm grating has d = 1.667 µm (1,667 nm). Working through examples shows the equation in action. With a 600 lines/mm grating and sodium light at 589 nm in the first order, sin(theta) = 0.3534, so theta = 20.70 degrees. Switching to a green laser at 532 nm in the second order on the same grating gives theta = 39.67 degrees; the highest order possible at this wavelength is 3. A denser 1,200 lines/mm grating has d = 0.833 µm. Sending red light at 650 nm through it in the first order produces theta = 51.26 degrees, and no second order exists because it would need sin(theta) above 1.
The maximum order is the largest whole number m with m x wavelength <= d. Because sin(theta) can never exceed 1, wavelengths longer than the line spacing have no first order at all, and shorter wavelengths may support several orders. This limit is why dense gratings spread light so widely but also why they cut off higher orders sooner.
From lines per mm to spacing
A diffraction grating is a surface ruled with many evenly spaced lines; it spreads light into spectra far more strongly than a prism. To use the grating equation — d x sin(theta) = m x wavelength, where d is the line spacing, m the order (0, 1, 2, ...) and theta the angle from the straight-through direction — you first need the line spacing d. Manufacturers quote gratings in lines per millimeter, so the diffraction grating calculator converts that density into a physical spacing before solving for the angle.
The conversion is straightforward: line spacing d = 1 / grating density. A 600 lines/mm grating has d = 1.667 µm (1,667 nm). Doubling the density to 1,200 lines/mm shrinks the spacing by half, giving d = 0.833 µm. Once d is in the same units as the wavelength, you can plug both into the grating equation and solve for sin(theta).
With a 600 lines/mm grating and sodium light at 589 nm in the first order, sin(theta) = 0.3534, so theta = 20.70 degrees. Push the same grating to the second order with a green laser at 532 nm and theta rises to 39.67 degrees; the highest order possible at this wavelength is 3. Switch to a denser 1,200 lines/mm grating and red light at 650 nm in the first order, and theta jumps to 51.26 degrees — and no second order exists because it would need sin(theta) above 1.
That upper limit comes from a simple rule: the maximum order is the largest whole number m with m x wavelength <= d. When the product of order and wavelength exceeds the line spacing, sin(theta) would have to surpass 1, which is physically impossible. Denser gratings produce wider diffraction angles but also cap the number of visible orders you can observe.
| Grating density | Line spacing d | Wavelength | Order m | Angle theta | Notes |
|---|---|---|---|---|---|
| 600 lines/mm | 1.667 µm (1,667 nm) | 589 nm (sodium) | 1 | 20.70° | sin(theta) = 0.3534 |
| 600 lines/mm | 1.667 µm (1,667 nm) | 532 nm (green laser) | 2 | 39.67° | Highest order possible at this wavelength is 3 |
| 1,200 lines/mm | 0.833 µm | 650 nm (red) | 1 | 51.26° | No second order exists (sin(theta) would exceed 1) |
The worked examples, including a missing order
The diffraction grating calculator handles the three most common textbook setups. Each worked example below applies the grating equation d x sin(theta) = m x wavelength, where d is the line spacing, m is the order (0, 1, 2, ...), and theta is the angle from the straight-through direction. Remember that line spacing d equals 1 divided by the grating density: a 600 lines/mm grating has d = 1.667 µm (1,667 nm).
First example: a 600 lines/mm grating with sodium light at 589 nm, examined in the first order. Plugging into the equation gives sin(theta) = (1 x 589) / 1,667 = 0.3534, so theta = 20.70 degrees. The sodium D lines appear just over 20 degrees from the central beam.
Second example: the same 600 lines/mm grating, but now with a green laser at 532 nm in the second order. Here sin(theta) = (2 x 532) / 1,667 = 0.6381, giving theta = 39.67 degrees. To find the highest order possible at this wavelength, use the rule that the maximum order is the largest whole number m with m x wavelength <= d. Since d = 1,667 nm and wavelength = 532 nm, the largest m satisfying m x 532 <= 1,667 is 3, because 3 x 532 = 1,596 nm fits but 4 x 532 = 2,128 nm exceeds the spacing. The highest order possible at this wavelength is 3.
Third example: a denser 1,200 lines/mm grating (d = 0.833 µm, or 833 nm) with red light at 650 nm in the first order. The calculation gives sin(theta) = (1 x 650) / 833 = 0.7803, so theta = 51.26 degrees. No second order exists for this setup. Checking the cut-off: the maximum order is the largest whole number m with m x wavelength <= d, so m x 650 <= 833. For m = 1, 650 <= 833 holds. For m = 2, 1,300 exceeds 833, which would require sin(theta) above 1. Since sine cannot exceed 1, the second order is a missing order, and the highest order present is 1.
Gratings at work
A diffraction grating is a surface ruled with many evenly spaced lines, and it spreads light into spectra far more strongly than a prism. That is why the grating equation, d x sin(theta) = m x wavelength, shows up in tools far beyond the lab bench. The same relationship that governs a research spectrometer also explains the shimmering rainbow you see on the back of a CD or DVD. Those discs are pressed with spirals of microscopic pits that act as a reflection grating, splitting white light into its component colors because each wavelength bends at a different angle.
In astronomy, large ruled gratings sit inside spectrographs attached to telescopes. Starlight passes through the grating, and the resulting spectrum reveals what elements are present in a distant star. A 600 lines/mm grating has a line spacing d of 1.667 µm (1,667 nm). Aim sodium light at 589 nm at that grating and look at the first order: sin(theta) = 0.3534, so theta = 20.70 degrees. Switch to a green laser at 532 nm and ask for the second order, and the angle widens to 39.67 degrees. The highest order possible at that wavelength is 3.
Push the grating density higher and the angles grow fast. A 1,200 lines/mm grating has d = 0.833 µm. Shine red light at 650 nm through it and the first order appears at 51.26 degrees, but no second order exists because it would need sin(theta) above 1, which is impossible. The maximum order is the largest whole number m with m x wavelength <= d. That single rule tells you instantly how many spectra a given grating can produce before the math breaks down.
A diffraction grating calculator turns these relationships into quick answers. Enter the grating density and a wavelength, and it solves for the diffraction angle or checks whether a given order is physically reachable. The same equation that splits starlight in a professional spectrograph also splits sunlight reflecting off a music disc, which is why the rainbow on a disc looks so much richer than a simple prism rainbow.
FAQs
What is the grating equation?
The grating equation is d sin(theta) = m lambda. Here, d is the line spacing, theta is the diffraction angle, m is the order, and lambda is the wavelength. In plain terms, the line spacing times the sine of the diffraction angle equals the order times the wavelength. This relationship lets you calculate the angle at which each wavelength appears.
What does 'order' mean?
The zeroth order goes straight through without separating wavelengths. The first, second, and higher orders are the successive spectra formed on each side of the zeroth order. Each higher order is more spread out than the one before it, but also dimmer, because the light energy is distributed across more orders as the order number increases.
How do I get line spacing from lines per mm?
Divide 1 mm by the line count. For example, a grating with 600 lines/mm gives a line spacing of 1/600 mm, which equals 1.667 µm between lines. This line spacing is the value you use as d in the grating equation, so converting lines per mm to an actual spacing is the first step in any diffraction calculation.
Why do some orders not exist?
If m times the wavelength exceeds the line spacing, then sin(theta) would have to exceed 1 to satisfy the grating equation. Since the sine of an angle can never be greater than 1, that order is cut off and cannot appear. Higher orders are the first to disappear, because multiplying by a larger order makes the product exceed the line spacing sooner.
Why do gratings beat prisms for spectroscopy?
Gratings produce higher orders that spread wavelengths over large angles with a linear scale, giving much finer wavelength resolution than a prism can achieve. Prisms bend different wavelengths by different amounts, but the spacing is not linear and the angular spread is limited. A grating's linear wavelength-to-angle relationship makes it easier to identify and measure spectral lines accurately.
What is the white zeroth order?
At m = 0, the grating equation gives sin(theta) = 0 for every wavelength, so theta = 0 for all of them. This means all wavelengths overlap at the same central position, producing an unseparated white light maximum. The zeroth order is bright but useless for spectroscopy because no wavelength separation occurs there.