When the Sun illuminates the sky after rain, we marvel at the beauty of the optical phenomenon that we see in the distance: the rainbow. But where do all those colors come from? The light coming from our Sun is known as white light and is formed by the superposition of lights of different colors, which have a specific wavelength and frequency. The phenomenon that occurs when this white light is broken down into the different colors that make it up is known as light scattering.
The dispersion of white light in the different colors that compose it was explained for the first time by Isaac Newton in the 18th century. He discovered that when a beam of white light, for example, from the Sun, passes through a glass prism, the different monochromatic radiations are deflected by refraction. The shorter their wavelength, the greater the deflection. In this way, the red rays are less deflected than the violet ones and the primitive beam of white light, thus widened by the prism, becomes an electromagnetic spectrum in which the colored radiations are exposed. Thus, the optical dispersion can be obtained employing transparent prisms (made of glass, plastic, or other material) or by diffraction gratings.
Although the spectrum of visible light that Newton investigated is made up of a continuous range of colors, he listed seven main ones: red, orange, yellow, green, blue, indigo, and violet. This approach by Newton was consistent with the fact that at the end of the 17th century. There were also seven known celestial stars (Sun, Moon, Mercury, Venus, Mars, Jupiter, and Saturn), the metals used in alchemy (gold, silver, copper, mercury, lead, tin, and iron), the musical notes of a scale, and even the days of a week.
In this way, Newton showed that, contrary to the belief of the time, the colors of the substances did not come from inside them but were due to the decomposition of the white light that fell on them.
Why does light scattering happen?

We know that the speed of light in a vacuum is constant and independent of its wavelength (in the absence of matter, this speed is independent of wavelength or frequency). However, its speed in any other medium other than vacuum does depend on the wavelength it has. For example, in glass, red light has a wavelength = 750 nm, and violet light, at the other end of the spectrum, has a wavelength = 390 nm. Longer wavelength means faster speed, so the violet light beam is deflected more than the red light beam in this refraction process. This dependence is due to the molecular structures of the materials and is responsible for the fact that, ultimately, the refractive index depends on the wavelength.
Where can we see it?

Rainbow
When sunlight falls on the raindrops, they are responsible for producing the effect. The rays of the Sun involved in the formation of the rainbow exit the raindrops at an angle of approximately 138 degrees from the direction they were going before entering them. This is the “rainbow angle,” discovered by René Descartes in 1637. As the angle of departure is only 138 degrees, the light is not reflected exactly towards its origin. This makes it possible for the rainbow to be visible to the observer, who is not usually found exactly between the Sun and the rain. So always, if you are facing a rainbow, the Sun will be behind.
A ray of sunlight, the kind that forms a rainbow, changes direction three times as it moves through a raindrop: It enters the drop first, causing it to refract slightly, then it moves to the opposite end of the drop and is reflected on the inside of the drop. Finally, it refracts again when it comes out of the raindrop in the form of scattered light. Color decomposition is possible because each wavelength is refracted at a different angle, generating each color of the rainbow.

Halos
Another natural phenomenon that is also due to light scattering is halos, which can be seen in the sky when sunlight passes through microscopic ice crystals suspended in the atmosphere, such as those contained in high clouds. Ice crystals can be considered parallelepipeds with a hexagonal base, whose faces and edges form prisms that deflect light at a different angle for each color.
How to Create a Rainbow Indoors

It is easy to observe the scattering effect of light at home with materials that are very easy to get. This is a very simple experiment to do: all you need is a compact disc (CD), a white light source, and a surface where the rainbow is going to be shown. You just have to direct the beam of light towards the bottom of the CD and play with the angle at which it is held. This is possible because the CD acts as a diffraction grating due to the size of its slits, which are very small and comparable to the wavelength of the light that falls on it. The illuminated CD returns light from multiple points, and the light emitted in all directions from each of them interferes with those emitted from the others. These interferences cause each light of a specific wavelength (each color) to emerge from the CD at a different angle. You can watch a video of this experiment here.