On rainbows

[This page is a work in progress.]

Introduction

My physics teacher once taught me that a rainbow is created when light refracts into raindrops, reflects twice inside those drops and then refracts out of them, traveling in the opposite direction to where it came from initially. Because water refractive index is slightly different for different wavelengths, the resulting light has its red component traveling at a slightly different angle than its blue or green components, and this is what creates the rainbow colors.

That explanation is overall correct, but it rises a question: since light can fall on any part of a raindrop, refract and reflect in mutitude of directions, how come only beams that go in a very specific direction create a rainbow? What about light in all the other directions, why doesn’t it create rainbows all over the sky?

Well, let’s compute a rainbow and find out.

To make a rainbow, we’ll need three things:

  1. Sunlight that falls onto the raindrops. We’ll be mainly interested in what color it is -- or rather what mixture of wavelength compose it.

  2. Water the raindrops are made of. We’ll want to know how water’s refractive prowess depends on the wavelength of the falling light.

  3. Eyes. One can’t compute a color without knowing how an eye percieves them.

So the plan is to split sunlight into bands of fixed wavelength, target them at a spherical blob of water, and see what colors come out.

Sunlight spectrum

The first ingridient of a rainbow is the sunlight. In theory the temperature of Sun’s photospere varies between and , with effective temperature being , so we could use Planck’s law for the spectrum of black body to find Sun’s spectrum. Here’s the formula:

In practice however, the measurements of daylight spectrum at various places on Earth show different distribution than the black body. Multiple such distribtions have been adopted to model daylight; the most commonly used of them is CIE D65, which is closer to black body of temperature . Here’s a comparions between these distributions:

Refractive index of water

The next bit we’ll need is the refractive index on the boundary between air and the raindrop. Air refracts light so slightly that we can ignore it; refractive index of water on the other hand is significant and well studied: there actually exists The International Association for the Properties of Water and Steam, which maintains a guide [1] with high quality approximated formula of water’s refractive index depending on its temperature, density and light’s wavelength.

Here are the values that formula will give you for and :

Eyes and colors

Human sensation of color is fairly complex: it depends on the spectral composition of light, its intensity, the background against which it is viewed (both the overall environment illumination and the immediately adjacent colors), and which part of the eye is viewing this light.

For our purposes we’ll only need to understand a small portion of this complexity: given a known spectral composition of light, what image on a computer screen will produce the same sensation of color?

To answer a question like this, many experiments have been performed; their result is the CIE XYZ color space and its color matching functions. In a few words: there is a mapping from spectral distibution to three color coordinates X, Y and Z; two different spectral distributions with identical XYZ values will produce the same color sensation (if viewed under the same conditions). All widespread color technology is based on these coordinates.

To obtain XYZ coordinates from a spectral distibution, one needs to multiply it by corresponding response function and sum it up over all wavelengths:

Response functions themselves are available over at CIE website [2] as tables of values. They look like this when plotted:

Now, the color coordinates your monitor uses (or at least the coordinates your browser is theoretically required to support) is not XYZ, but rather sRGB. The conversion between XYZ and sRGB, assuming standard daylight background (D65) of medium brightness, is defined like this:

Light in a raindrop

[This section is under construction.]

Rainbow

[This section is under construction.]

Let’s take a closer look at the region near 140°:

This is the direction where light comes out after two reflections inside the raindrop. Behold the main rainbow.

There’s also an interesting region closer to 130°:

This is the secondary rainbow; it is created by light that is reflected three times inside the raindrop. Note that its colors go in reverse order compared to the main rainbow.

References

  1. http://iapws.org/relguide/rindex.pdf

  2. http://www.cie.co.at/