Maths behind the rainbow

When the great mathematician Isaac Newton explained the colours of the rainbow with refraction the poet John Keats was horrified. Keats complained (through poetry of course) that a mathematical explanation robbed these marvels of nature of their magic, conquering "all mysteries by rule and line". But as we will see, the mathematical explanation, requiring just the basic geometry of lines and circles, is just as elegant as the rainbows themselves.

Bent on refraction

The visible spectrum from violet (left) to red (right).

The colours of the rainbow are a result of refraction splitting the light into its constituent components, just as happens when light shines through a prism. The white light that arrives from the Sun is a combination of electromagnetic waves with varying frequencies. You see white when this mix of frequencies hits your eye at the same time, but when your eye catches an individual wave on its own, you perceive a particular colour.

Waves with frequencies between around 670 and 780 THz are perceived as shades of violet. On the other end of the spectrum are
waves with frequencies between around 400 and 480 THz, which are perceived as shades of red. All the other colours come from frequencies in between these two bands. Electromagnetic waves of other frequencies can't be perceived at all by the human eye.

Figure 1: A ray of light being refracted, reflected and then refracted again.

When a ray of sunlight hits a spherical water droplet some of it will be reflected by the surface of the droplet, but some of it will enter it. As it enters, the light ray will be bent, or refracted. It's the same phenomenon you see when you stick a straw in a water glass. The ray then continues until it hits the back of the droplet. Some of the light will exit, but some of it will be reflected back, leaving the droplet on the other side and being refracted again in the process. See figure 1.

Refraction is a result of a ray of light being slowed down as it passes from one medium to another. For a very crude analogy think of pushing a shopping trolley from the road onto grass at an angle: it will change direction because the side of the trolley that hits the grass first will be slowed down first.

Figure 2: Light of different frequencies is refracted by different amounts.

When light from the Sun travels through a vacuum (and to a very good approximation through air) all frequencies travel at the same speed , roughly 300,000 km per second. As the ray of light passes into water, the frequency, and therefore colour, remains the same. However, its speed will change by an amount that depends on the frequency. This is because the atomic structure of water interacts differently with waves of different frequencies. A measure of the slowing-down of light with frequency is given by the refractive index Its value depends not only on the frequency but also on the medium the light is entering (in this case water, as indicated by the subscript ). The index is defined as

The refractive index barely changes as the frequency varies: is around 1.34 for the violet end of the spectrum and around 1.33 for the red end. But this small variation is enough to split sunlight into the beautiful spectrum of colours we see in a rainbow. (The refractive index also varies slightly with temperature, but we can ignore this here.)

Figure 3: The diagram shows the cross-section of the water droplet containing the incident ray, the refracted ray and the normal. The angles α and β are related by Snell's law.

Just how much the light of different frequencies is bent when entering the droplet is described by Snell’s law. The law says that the refracted ray of light lies in the plane formed by the incident ray and the normal at the point of incidence – the normal is the line that passes through the point where the ray hits the droplet and is perpendicular to the surface of the droplet. Since we’re assuming the droplet to be spherical, the normal in this case is just the extended radius of the droplet, connecting its centre to the point of incidence.

Snell’s law also tells us that the angle by which a ray is refracted is given by this equation:

Here and are the angles shown in figure 3 and and are the refractive indices of air and water, respectively, for light with frequency . As air is very similar to a vacuum, the refractive index is very nearly equal to 1 for all frequencies. Thus, if a light ray hits the droplet so that , then red light with a refractive index 1.33 has

(The result is rounded to two decimal places.) Violet light with a refractive index of 1.34 has

It's these different refraction angles for the different frequencies of light that gives a rainbow its colours.

Catching rainbow rays

But why do we see each of the colours forming a perfect circular arc? To understand the shape of the rainbow, think of light from the Sun as coming down in parallel rays and striking a particular water droplet in the air. Using Snell’s law and the law of reflection (that the angle of incidence equals the angle of reflection), we can work out by how much a ray is deviated in terms of the angle at which it first hits the droplet. In other words, by what angle it is being turned as it is refracted, reflected and then refracted again (see figure 4). This angle will of course be different for each frequency, or colour of light.

By staring hard at figure 4 you can convince yourself that the deviation is given by the formula

Figure 4: Working out the angle of deviation.

From Snell’s law, we know that we can substitute

in the above expression. (We are taking the refractive index of air to be 1 here.)

Figure 5 shows the graph of , taking the refractive index for a particular shade of red. Notice that it has a minimum at a value somewhere in the region of .

Figure 5: The graph of Df(α).

This minimum angle is what gives us the rainbow. Figure 6 shows a 2D cross-section of the droplet containing a bunch of rays for our refractive index . The ray entering at the minimum angle in this cross-section is shown in red. It is called the rainbow ray. The rays that hit the droplet near the rainbow ray (with an angle close to ) cluster close to it during their passage through the droplet and when they emerge. So if your eye happens to catch the rainbow ray from this droplet after it's emerged, you will see a whole bunch of other rays too, making the light that comes from our droplet particularly intense. Since all the clustering rays are of the same colour, our particular shade of red which has , the droplet lights up red in the sky.

Figure 6: The rainbow ray is shown in red. A cluster of rays emerges from the droplet near the rainbow ray, while rays that emerge elsewhere are more spaced out.

The fact that emerging red rays cluster near the rainbow ray is a consequence of being the minimum of the function . You can see this in figure 7. Take an interval centred on the minimum and an interval of the same width centred elsewhere. The range of deviation angles for values in (given by the interval ) is much smaller than the range of deviation angles for values in (given by the interval ). Thus, rays that hit the droplet with angles in stick closer together than rays with angles in .

Colour cones

So you see a red dot in the sky for every droplet from which your eye manages to catch an outgoing red rainbow ray. To see where in the sky these droplets are relative to you, let’s first work out the exact value of . Solving to find the minimum gives

Now if an emerging rainbow ray from a droplet meets your eye, then this means that the emerging ray makes an angle with the line shown in figure 8. It’s the line you get from extending the ray of sunlight that would pass straight through your eye if your head wasn’t in the way. (Remember we’re assuming that the rays from the Sun are parallel.) Let’s call the rainbow angle. Of course it depends on the frequency and therefore on colour.

Figure 8: The deviated rainbow ray from your droplet makes a 42.52 degree angle with the line L.

If you take all lines that emanate from your eye and make a angle with , what you get is a cone (see figure 9). The droplets that light up red for you all lie on this cone: if they didn't, you wouldn't be catching their red rainbow ray. But when you look along the surface of a cone from its vertex, as your eye is doing, all you see is a circle. You can try this by rolling a sheet of paper up into a cone shape and peering through the little hole at the tip. The rainbow comes from droplets that lie on the cone at different distances from your eye, some can be near and others can be far. But your eye can't distinguish the distances, all it sees is red light mingling together to form a circular arc that appears to be located somewhere in the distance. The reason why you don't see the full circle is that the Earth gets in the way. Unless you're above the water droplets, for example when looking down from a plane, in which case you can see a beautiful circular rainbow.

Figure 9: The droplets you see light up in the sky lie on the surface of a cone.

The same reasoning goes for all the other colours of the spectrum: they appear as circular arcs. But the varying indices of refraction give a different rainbow angle for each colour. For example, violet light with gives and , so the rainbow angle in this case is . Thus, the rainbow appears as a nested sequence of circles of colours in order of their refractive indices, or, equivalently, in order of their frequencies: red at the top all the way through to violet at the bottom.

This explanation also shows why you only ever see a rainbow when you're standing with your back to the Sun: that's the only way you can catch rainbow rays coming from droplets. It also explains why the sky appears much brighter below the rainbow than above. Since the vast majority of rays leaving a droplet do so above the rainbow ray (see figure 6), you won't catch any rays from droplets that are "above" the rainbow (that is, outside the cones for the various colours). So you won't see any reflected light from these droplets. However, your eye does catch reflected light from droplets "below" the rainbow (droplets that lie inside the cones) and it's this light that makes the sky below the rainbow appear brighter. It appears as white light because non-rainbow rays for different colours, coming to your eye from different droplets, are mixed together.

The rainbow geometry also shows that any rainbow you see is yours and yours alone: whatever a person standing next to you might see, it'll come from a different set of water droplets and therefore it'll be a different rainbow.

Sometimes, if you are lucky, you might see a second, slightly fainter rainbow above the main one. The secondary rainbow is a result of light rays being reflected twice within the water droplets. The rainbow angles for the various colours are around 51 degrees in this case, which is why the secondary rainbow is seen higher in the sky. The double reflection also means that the colours of the secondary rainbow appear in reverse order, with violet at the bottom and red at the top. Here's the original sketch by René Descartes, who first explained the shape of the rainbow, showing both the primary and secondary rainbow. The double reflection corresponding to the secondary rainbow is traced in red.

Descartes' sketch of the primary and secondary rainbow.

It is even possible in theory (though it hardly ever happens in practice) to see rainbows coming from three, four or more reflections within the droplets. But I'll leave these calculations to you.