Solution (source code)

= Solution

For a primary <rainbow>, sunlight is refracted into a water drop, internally reflected once, and refracted out. The <refractive index> varies with <wavelength>, producing <optical dispersion>. If $i$ is the incidence angle and $r$ the refracted angle, a spherical-drop ray has deviation
$$
D=\pi+2i-4r,\qquad \sin i=n\sin r.
$$
A stationary deviation concentrates neighbouring rays into a bright angular region. For visible light in water, the primary bow lies around $42^\circ$ from the antisolar direction, with red outside violet. Each observer receives the suitable colour from drops on the corresponding cone; the bow is not a fixed coloured object attached to one particular group of drops. Further internal reflections produce secondary bows with different angles and colour order.

A <soap film> uses <thin-film interference>. Rays reflected from its two surfaces acquire an optical path difference $2nt\cos r$. With air on both sides of a nonabsorbing film, one of the surface reflections has a phase reversal. A constructive reflected condition is consequently
$$
\boxed{2nt\cos r=\left(j+\frac12\right)\lambda.}
$$
Different <thicknesses>, angles and wavelengths therefore give different reflected colours. A sufficiently thin symmetric film becomes dark because its leading reflected contributions cancel. The colour is chiefly an interference effect, rather than a pigment carried by the soap.

<Mother-of-pearl>, or <nacre>, has a structured arrangement of mineral tablets and organic layers. Repeated refractive-index contrasts produce wavelength-selective reflection; surface grooves can also act as <diffraction gratings>. Thus both multilayer interference and surface diffraction can contribute. A representative repeating-layer condition is $2(n_1d_1\cos r_1+n_2d_2\cos r_2)=j\lambda$. Modern structural-colour measurements and modelling distinguish these two contributions instead of treating every nacre appearance as a single grating effect.<Investigation of Nacre Nanostructure by Analyzing Its Structural Color Pattern by Nicole Fan and others>[2021, Introduction and equation 1: aragonite–conchiolin layers versus surface grooves]{ref} That microscopic account uses later structural evidence, not techniques available to an 1865 candidate.