Solution (source code)

= Solution

For $N$ uniformly illuminated identical slits of a <diffraction grating>, with width $b$ and period $d$, the far-field amplitude is a single-slit transform times a finite phasor sum. At <normal incidence>, write $\beta=\pi d\sin\theta/\lambda$. Then
$$
\boxed{I(\theta)=I_{1,0}\left[\frac{\sin(\pi b\sin\theta/\lambda)}{\pi b\sin\theta/\lambda}\right]^2
\left(\frac{\sin N\beta}{\sin\beta}\right)^2}.
$$
Principal maxima obey $d\sin\theta=m\lambda$ and have $N^2$ times the single-slit intensity at that angle. Nearby first minima are separated from a principal maximum by $\delta\theta\simeq\lambda/(Nd\cos\theta_m)$, so more illuminated slits sharpen each order. The broad single-slit envelope suppresses high angles; an order is missing if its principal maximum coincides with an envelope zero.

Differentiating the <grating equation> gives angular dispersion $d\theta/d\lambda=m/(d\cos\theta_m)$. Comparing the separation of nearby <wavelengths> with the first-minimum width yields the Rayleigh resolving <power>
$$
\boxed{\lambda/\delta\lambda=|m|N}.
$$
Only propagating orders with $|m\lambda|\leq d$ exist. Different spectral orders can overlap, and finite source-slit width, limited coherence, aberrations and grating errors worsen ideal resolution. A <spectrometer> therefore collimates light from an entrance slit and focuses each diffracted direction onto a detector; the slit image width and illuminated grating width must both support the desired spectral separation.