# Rainbow Refraction

> One ray of white light through a water droplet: refracted in, reflected once, refracted out, and split into a fan of colors, with the impact height animating.

A rainbow forms when sunlight enters falling raindrops, reflects once off the back of each drop, and leaves again toward an observer with the Sun behind them. This document follows one horizontal ray of white light at the height $y_0$ into a spherical droplet of radius 1. At the surface the ray refracts toward the normal, crosses the drop, reflects on the far side, crosses again, and refracts out. Because the refractive index of water $N(L)$ is slightly larger for violet light than for red, each color bends by a different amount, and the single white ray leaves as a fan of colors.

The geometry is written in closed form. The angle of incidence is $a = \arcsin(y_0)$ and the angle of refraction is $b(L) = \arcsin(y_0 / N(L))$. Each chord inside the drop turns the contact point around the circle by $2b - \pi$, so the back reflection point sits at the polar angle $u(L) = 2b(L) - a$, and the ray leaves at the angle $2u = 4b - 2a$ below the horizontal. The functions $X(L, t)$ and $Y(L, t)$ draw the whole path, chord by chord, for eight wavelengths from red to violet. The dashed grey rays show the light reflected off the outside of the drop and the light that leaves after a single pass.

As the impact height $y_0$ animates, the exit angle rises to a maximum, the rainbow angle $D$ (dotted line), and falls back. Near that maximum, rays from a wide band of impact heights leave in almost the same direction, and this concentration of light is the bright bow, about $42°$ from the point opposite the Sun. Red leaves at the largest angle, so it is on the outside of the bow. To make the fan easy to see, the document uses about twice the real spread of the refractive index of water.

After a Desmos graph by Fabrice Neyret.

- [Open the interactive version](https://graph-paper.io/showcase/en/rainbow-refraction)
- [Learn more on Wikipedia](https://en.wikipedia.org/wiki/Rainbow)
