Prisms and the Rainbow
Refraction
Before we get to prisms we should begin with the physics concept, refraction; this is a very important concept. Refraction describes the change in direction of a light path when it passes into a different material. Light passing from air into glass, water, clear plastic, etc experiences refraction. Light passing through a prism experiences refraction both when it enters and exits, which allows it to split white light into its colored components.
While all wavelengths of light move at c = 2.998*108 m/s in a vacuum where there is no air, they travel slightly slower in matter (including the gasses that form air). This is because each atom will absorb the light energy, and then reemit the energy into the next atom in the light's path. Although a near instant process, it does slightly delay the speed of light. Dispersion of Light by Prisms
So light is slightly slowed by air molecules, and it is slowed even more by materials like water, glass, and plastic. This change in speed will cause refraction, the bending of the light path. Going from a "slow" material like glass into a "fast" material like air will also cause refraction, just in the opposite direction.
So why does the direction of light change when it passes into a "slower" or "faster" material? It all boils down to the fact that light travels in waves.
In a beam of light there are countless photons traveling in waves. These waves line up with each other so that the peaks next to each other form a wavefront.
Here the wavefronts are represented as colored lines. The spaces between these lines are the waves' valleys. The waves are traveling fast until they pass into the new material where they start traveling slower, represented by condensed wavefronts. When light passes through a surface at 90 degrees, it does not change direction, it easily slows down (or speeds up) in the new material without complication. However something happens when light hits a surface at an angle.
Note about the diagrams
The width of the lines/spaces here does not represent wavelength. A wave does not change wavelength when it enters a new material, it changes speed. Closer together means the wavefronts are slower, further away means they are faster (since something faster is able to get further away in the same amount of time).
If the light went straight through the new angled material, we would get broken up peaks and valleys shown here. Notice how many more peaks are touching the surace on the right side, where as the left side only has a few peaks touching the surface, they are not lined up either. This is not possible though. As the peak of a light wave passes into a new material, it does not suddenly become a valley or inbetween, it has to continue in the wave pattern.
The only way for the waves' peaks and valleys to stay intact as they pass into a different material, is for the light path to bend. Notice how there are the same amount of peaks and valleys touching the surface on both sides, despite their difference in speed. They also line up with each other, meaning the light waves were able to follow the wave pattern. See below for an animated illustration.
The more angled the surface is to the path of light, the more the light will bend when entering/exiting it.
Which diraction the light bends, depends on wheather it is going into a "slower" or "faster" material. (Add more info/diagrams)
So why are certain materials "slower" or "faster" than one another? Each material affects the speed of light slightly differently because of the amount of energy required to put the chemical structure of the material at a higher energy state than its resting state. Dispersion of Light by Prisms This is a very precise unit of energy, unique an atom, molecule, or other structure. In order to put a molecule into a higher energy state, the energy it recieves must be exactly equal to the difference between its current state and excited state, it cannot be less or greater than that. Quantum Energy Levels in Atoms - LibreText Chemistry
The index of refraction is a constant number unique to a specific material, used to calculate the angle of refraction (how much the light is bent when passing from one material to another). The index of refaction for a material is related to the amount of energy required to excite the material to a higher energy state, which is different for each material. The closer the energy of a specific wavelength of light is to the energy required to excite the material, the slower the light will move through said material. The further way the light energy is to the materials excitation energy, the faster it moves through the material.Dispersion of Light by Prisms (Recall that different colors of light have different wavelengths and amounts of energy: The Visible Spectrum). Also note that the light passing through the material rarely has enough energy to actually put the material into a higher energy state.
Prisms and Dispersion
Prisms can split white light into the different wavelengths that make up white light, which is called dispersion. A prism is usually made of glass, which is a "slower" material compaired to air, causing the light path to bend. Even in the same material, different wavlengths of light will move at different rates through the material. This causes them to go in different directions from each other. The slightly different directions these wavelegths go separates them, allowing the individual colors to be seen rather than just white light.
So why do different wavelengths of light travel at different speeds? This is for the same reason that light moves at different speeds in different materials. The closer the energy of a specific wavelength of light is to the energy required to excite the material, the slower the light will move through said material. The further away the light energy is to the materials excitation energy, the faster it moves through the material.Dispersion of Light by Prisms Since different wavelengths of light have different amounts of energy, some are slowed down more than others.
Most materials will have excitation energies higher than the energy of any light wavelength. Thus violet, having the largest energy, will be slowed down the most when passing from air into another material. Red with the smallest energy will be slowed down the least.
Rare reverse senario
On very rare occasion there are materials that have excitation energies lower than the energy of wavelengths in the visible spectrum. Since red has the lowest energy, it will be closest to the said material's and be slowed down the most, resulting in abnormal dispersion, where red is bent the most and violet is bent the least by a change in material. Radiation - Britannica
Speculation: Theoretically this means that there are also materials that have an excitation energy in the middle of the visible light energy range. Suppose it was at a yellow wavelength, that particular wavelength would be absorbed (not visible), and then the yellows around it would be bent the most, then green and orange would be bent medium, with red and blue bent the least, causing an overlap in the colors that are equally bent (yellow, green + orange, red + blue), possibly creating a yellow to purple gradient instead of a rainbow. This is just speculation of mine however.
The shape of prisms
Most glass windows do not throw rainbows when direct sunlight passes through them, however many leaded glass windows will (at the right time of day). Likewise a cube (or any rectangular prism) of glass/crystal will not separate white light into colors, but a pyramid or triangular prism will.
This is because a normal window or cube has parallel surfaces that the light enters and exits. When the light exits the parallel glass surface, the lights refraction as it passes back into air is the reverse of that as it entered the glass, stopping the divergence, meaning the colors have only seperated for as long as they were in the relatively thin glass. In the diagram above, the parallel rainbows (through a parallel faced material) will overlap, creating white again, except at the very edges where a red-yellow edge may be observed on one side and a blue-violet edge on the other side. Because a pyramid or beveled edge does not have parallel surfaces, the light upon exiting the glass will be additionally refracted, separating the colors further so that they don't overlap as much. Why doesn’t a normal window produce an apparent rainbow?
Here you can see a prism dispersing light into a rainbow, where the colors overlap closer to the prism.
Rainbows
So what do prisms have to do with the rainbows we see in the sky?
Basically, water droplets in the air act as prisms, splitting the white light from the sun into a spectrum of colors. Notice that the light is reflected by the inside of the water droplets. So the light enters the droplet, is reflected by the inside surface of the droplet, and then exits the droplet. Note that most of the light that enters the water drop passes right through it rather than reflecting, but this light does not form a rainbow, only those that are reflected within the drop do. This is explained on the next pages, primary rainbows and secondary rainbows.
Suggested next page: Primary Rainbows