A rainbow is formed by sunlight that is refracted and reflected by the droplets of a rain shower. It can consist of more than one bow, each formed by light reflected a different number of times inside the droplets.
Primary rainbow
The primary rainbow, the brightest bow, is formed by light reflected once inside each droplet, along the path shown below.
The droplet is assumed to be spherical. A ray meets it at \(A\) at an angle \(\alpha\) to the normal (the line perpendicular to the surface), and is partly reflected and partly refracted into the droplet at an angle \(\beta\) to the normal. Snell's law relates the two angles:
where \(n = 1.333\) is the refractive index of water for yellow light (wavelength 589 nm), and that of air is taken to be 1. At \(B\), most of the light leaves the droplet, but some is reflected and leaves the droplet at \(C\). Each chord inside the droplet meets the surface at the angle \(\beta\) to the normal, and since \(\sin\beta = \sin\alpha/n < 1/n\), \(\beta\) is always less than the critical angle, \(\arcsin(1/n) = 48.6^\circ\): a ray inside a spherical droplet is never totally internally reflected.
The ray is turned through an angle \(\alpha - \beta\) at \(A\), \(\pi - 2\beta\) at \(B\) and \(\alpha - \beta\) at \(C\), so its total deflection is
Sunlight strikes the whole of the droplet's illuminated face, in rays that are almost parallel (not exactly, because the sun's disc subtends an angle of about 0.5°). The figure below traces rays that meet the droplet at a range of heights.
The deflection has a minimum, near which a wide range of rays leave the droplet in almost the same direction; the scattered light is most intense in this direction, which is that of the primary rainbow. At the minimum,
For \(n = 1.333\), this gives \(\alpha = 59.4^\circ\), \(\beta = 40.2^\circ\) and \(\phi_1 = 137.9^\circ\): the light leaves the droplet at \(180^\circ - \phi_1 = 42.1^\circ\) to the direction it came from. An observer with the sun behind them therefore sees this light from the droplets that lie \(42.1^\circ\) from the antisolar point (the point directly opposite the sun, where the shadow of the observer's head falls). The primary rainbow is a circle about that point with an angular radius of \(42.1^\circ\), called the rainbow angle. The antisolar point is as far below the horizon as the sun is above it, so from the ground the bow can be seen only when the sun is less than about 42° above the horizon; from an aircraft, or from a mountain above the rain, more of the circle can be seen.
The refractive index of water depends on the wavelength of the light, from 1.33141 for red light (700 nm) to 1.34451 for violet light (400 nm), and so does the rainbow angle: it is 42.3° for red light and 40.4° for violet. The primary rainbow is therefore red on the outside and about 1.9° wide, and the 0.5° width of the sun's disc blurs its colours.
At \(B\), the ray meets the surface at \(\beta = 40.2^\circ\), close to Brewster's angle for light inside the droplet, \(\arctan(1/n) = 36.9^\circ\), at which light polarised in the plane of incidence is not reflected at all. The Fresnel equations give a reflectance at \(B\) of 0.11 for light polarised perpendicular to the plane of incidence, but only 0.0035 for light polarised in it, so the light of the rainbow is strongly polarised, tangentially to the bow.
This description in terms of rays (geometrical optics) gives the angles of the bows, but it predicts an infinite intensity at the rainbow angle, and it cannot account for supernumerary bows (faint fringes just inside the primary bow), which result from the interference of light that leaves the droplet in the same direction along different paths.
Secondary rainbow
A secondary rainbow is often visible outside the primary bow. It is formed by light that is reflected twice inside each droplet:
The secondary rainbow lies between 50.5° (red) and 53.9° (violet) from the antisolar point. Its colours are in the reverse order to those of the primary, and it is wider and fainter, because light is lost at the extra reflection and the rest is spread over a wider band. The sky between the two bows, called Alexander's band after Alexander of Aphrodisias, who described it in about AD 200, is darker than the sky inside the primary bow or outside the secondary, because no light reflected once or twice inside a droplet is scattered into it.
Higher orders
A ray reflected \(k\) times inside the droplet contributes to the rainbow of order \(k\). The code below draws the path of such a ray, with the droplet's radius as the unit of length and its centre at the origin. Points are represented as complex numbers, so that the point on the surface at an angle \(\chi\) from the \(x\)-axis is \(e^{i\chi}\).
import matplotlib.pyplot as plt
import numpy as np
def plot_ray(ax, n, y0, k=1, x0=-2.5, c="r", lw=1):
"""Plot the path of a light ray through a spherical droplet.
The droplet has unit radius and is centred on the origin; n is the
refractive index of its material at the wavelength of the ray. The ray
starts at (x0, y0), travels in the +x direction and is reflected k times
inside the droplet.
"""
# Angles of incidence and refraction (Snell's law, with n = 1 for air).
alpha = np.arcsin(y0)
beta = np.arcsin(np.sin(alpha) / n)
# The ray enters the droplet at the point A = exp(i.chi).
chi = np.pi - alpha
A = np.exp(1j * chi)
ax.plot([x0, A.real], [y0, A.imag], c=c, lw=lw)
# Each chord inside the droplet subtends an angle pi - 2.beta at its centre.
for _ in range(k + 1):
chi -= np.pi - 2 * beta
B = np.exp(1j * chi)
ax.plot([A.real, B.real], [A.imag, B.imag], c=c, lw=lw)
A = B
# The ray leaves the droplet deflected through phi, in the direction exp(-i.phi).
phi = k * np.pi + 2 * alpha - 2 * (k + 1) * beta
end = A + 3 * np.exp(-1j * phi)
ax.plot([A.real, end.real], [A.imag, end.imag], c=c, lw=lw)
fig, ax = plt.subplots(figsize=(7, 4.5))
ax.add_patch(plt.Circle((0, 0), 1, fc="#ddeeff", ec="b", lw=1.5))
# A ray reflected three times inside a water droplet (n = 1.33).
plot_ray(ax, n=1.33, y0=0.85, k=3)
ax.set_xlim(-2.6, 2.6)
ax.set_ylim(-1.6, 1.6)
ax.set_aspect("equal")
ax.axis("off")
plt.show()
The figures above were drawn in the same way: the second with k=1 and 39 values of y0 from −0.95 to 0.95, and the third with k=2 and y0=-0.75.
Each internal reflection turns the ray through a further \(\pi - 2\beta\), so after \(k\) reflections its deflection is
Setting \(\mathrm{d}\phi_k/\mathrm{d}\alpha = 0\) as before gives \((k+1)\cos\alpha = \sqrt{n^2 - \sin^2\alpha}\), so the ray that forms the rainbow of order \(k\) meets the droplet at the angle \(\alpha_k\), where
and is deflected through
If \(\phi_k\) (reduced modulo 360°) lies between 90° and 270°, the light is scattered back towards the sun, and the bow is seen facing away from the sun, as a circle about the antisolar point with angular radius \(\lvert 180^\circ - \phi_k \rvert\). This is the case for the primary and secondary rainbows. Otherwise, the light is scattered forwards, and the bow is seen facing the sun, as a circle about the sun with angular radius \(\phi_k\) or \(360^\circ - \phi_k\), whichever is less. The third- and fourth-order rainbows are of this kind, at 41.7° and 43.7° from the sun for \(n = 1.333\). They are much fainter than the primary and secondary bows and lie in the sun's glare, and were first photographed in 2011 [Großmann et al., Applied Optics 50, F134 (2011), doi:10.1364/AO.50.00F134; Theusner, Applied Optics 50, F129 (2011), doi:10.1364/AO.50.00F129].
Simulation
The code below draws the rainbows of chosen orders as they would appear if each were bright enough to see; it does not calculate their brightness. Each bow is drawn as 61 rings, one for each wavelength from 400 nm to 700 nm in steps of 5 nm, with the refractive index interpolated linearly between the values for red and violet light given above. Each ring is drawn in the colour of its wavelength, calculated as described in the post Converting a spectrum to a colour; the code needs that post's module, colour_system.py, and the file of colour-matching functions that it reads, cie-cmf.txt, which can be downloaded below the code. The rings lie on a plane at unit distance from the observer, so a bow of angular radius \(\theta\) appears as a circle of radius \(\tan\theta\), and the image extends to \(\arctan 1.5 = 56^\circ\) from its centre. Every ring has the same low opacity, so a wide bow, whose rings overlap less, looks fainter.
import matplotlib.pyplot as plt
import numpy as np
from colour_system import CMF_LAM, cs_srgb
# Draw rainbows of these orders.
RAINBOW_ORDERS = [1, 2, 5]
# True to draw the rainbows seen facing away from the sun (such as the primary
# and secondary bows), False for those seen facing towards it (such as the
# third- and fourth-order bows).
AWAY_FROM_SUN = True
# The opacity of each ring.
OPACITY = 0.1
# The refractive index of water for red (700 nm) and violet (400 nm) light.
LAM_RED, N_RED = 700, 1.33141
LAM_VIOLET, N_VIOLET = 400, 1.34451
def refractive_index(lam):
"""Return the refractive index of water at wavelength lam (nm)."""
return N_RED + (lam - LAM_RED) / (LAM_VIOLET - LAM_RED) * (N_VIOLET - N_RED)
def rainbow_cone_angle(n, k=1):
"""Return (away_from_sun, cone_angle) for the rainbow of order k.
away_from_sun is True for a bow seen facing away from the sun, and False
for one seen facing towards it; cone_angle is the bow's angular radius (in
radians) about the antisolar point or the sun.
"""
sin_alpha = np.sqrt(1 - (n**2 - 1) / (k * (k + 2)))
phi = k * np.pi + 2 * np.arcsin(sin_alpha) - 2 * (k + 1) * np.arcsin(sin_alpha / n)
phi %= 2 * np.pi
if np.pi / 2 < phi < 3 * np.pi / 2:
return True, abs(np.pi - phi)
return False, min(phi, 2 * np.pi - phi)
fig, ax = plt.subplots()
ax.set_aspect("equal")
ax.set_xlim(-1.5, 1.5)
ax.set_ylim(0, 1.5)
ax.axis("off")
# The colour-matching functions are tabulated for 380-780 nm in 5 nm steps:
# draw a ring for each of these wavelengths from 400 to 700 nm.
for i, lam in enumerate(CMF_LAM):
if not LAM_VIOLET <= lam <= LAM_RED:
continue
spec = np.zeros(len(CMF_LAM))
spec[i] = 1
rgb = cs_srgb.spec_to_rgb(spec)
n = refractive_index(lam)
for k in RAINBOW_ORDERS:
away_from_sun, cone_angle = rainbow_cone_angle(n, k)
if away_from_sun == AWAY_FROM_SUN:
ax.add_patch(
plt.Circle((0, 0), np.tan(cone_angle), fill=False, ec=(*rgb, OPACITY))
)
if not AWAY_FROM_SUN:
# Draw the sun (not to scale).
ax.add_patch(plt.Circle((0, 0), 0.05, fc="#ffd000", ec="none"))
plt.show()
With RAINBOW_ORDERS = range(1, 13), the code draws every order up to 12 that appears in the image, and with AWAY_FROM_SUN = False as well, those seen facing the sun.