One of the most dazzling displays that nature offers on a rainy day is a full rainbow arcing across the sky. These ephemeral daytime occurrences have captured the human imagination for centuries — leading to a wide array of myths and legends as to what causes them.

While we know that there are solid scientific principles involved, many of us would probably struggle to describe exactly what those are. Here's a quick guide to the science behind rainbows, so you can understand what's going on in the sky the next time you see one.

Light refraction

Person's hand holding prism against light, showing rainbow colors
Credit: Mila Drumeva / Shutterstock

To understand how a rainbow occurs in a natural environment, we need to understand what happens during the process of light refraction. To illustrate that, we need to take a closer look at a basic science class tool — the prism.

A prism is a pyramid-shaped piece of glass that can produce a rainbow-like display of color from an ordinary beam of white light in a controlled indoor setting. It does this because glass has a different refractive index than air does. The refractive index measures how quickly light can pass through a medium. When two objects have a different refractive index, the light bends when it moves from one environment to the next.

Different wavelengths of light

Up close view of crumpled foil refracting light in various colors of the rainbow
Credit: Fevziie / Shutterstock

A beam of white light, or sunlight, is actually made up of many different colors. These colors — red, orange, yellow, green, blue, and violet — each have their own wavelength. When light is refracted, each wavelength has its own angle of bending.

This means that during the split second that a white light enters and exits a prism, each color is separated slightly. When they leave the prism and are projected onto a flat surface, each color hits a different spot because it has been bent at a slightly different angle. This allows you to see each color side by side.

Natural prisms

Brightly colored rainbow set against scattered clouds and blue sky
Credit: Pushish Images / Shutterstock

On a wet yet still sunny day, each raindrop acts as an individual prism. As sunlight hits each raindrop, it is reflected off the interior of the raindrop and refracted — separating the different wavelengths of light.

This process explains why rainbows always have the same color pattern. Violet has the shortest wavelength, which causes it to bend the most. Red has the longest wavelength, which causes it to bend the least. This is why violet is always the bottom color of the rainbow and why red is always on the top. All of the other colors have wavelengths that are in between those two and will always be in the middle.

Circular rainbows

Distant rainbow alight under stormy skies and dark gray clouds
Credit: Aluca69 / Shutterstock

One question still remains though. When light is refracted in a prism, it comes out in a straight line. However, rainbows are always curved. Why does this happen?

The answer is in the shape of the object that causes the refraction. Raindrops are spherical and refract light in a circle. Because of our angle relative to the sun and the horizon, we typically only see half of that circle — the arc that we associate with normal rainbows. However, if you are in a plane flying high above the horizon and observe a rainbow from the right angle, you might have the opportunity the see the full, circular rainbow effect.

Rainbows are a seemingly mystical phenomenon, but, like most things, they can be explained with some basic observations and repeated under the correct circumstances. So, the next time you see a rainbow after a stormy day, enjoy the effect and appreciate the fascinating science behind these marvelous bands of color in the sky.