Home » Optics » Rainbows
Science Calculators


Web 2.0 scientific calculator

Optics Calculators


A brief explanation of how rainbows are made...with equations!

Double Rainbow...but what does it mean???

If you haven't explored the refraction page, check it out! It provides a general introduction, and of course calculators and demos, to some of the concepts used here.

Rainbows, either in the sky or from prisms, come from the splitting of white light into different colors. Each color has its own energy, frequency and wavelength, which are all interrelated through fundamental constants:
$$f = c/\lambda \;\; \;\; f = E/h \; \; \;\; E = hc/\lambda $$

\(c\) is the speed of light, 3x108m/s, and \(h\) is Planck's constant = 6.63x1034J s = 4.13566733×10−15 eV s

The "light properties" calculator provides conversions among \(f\), \(\lambda\), and \(E\).

How rainbows are formed is something we learned in my advanced physics class in high school when we had a unit on light and optics. I thought it was pretty cool, and now I want to share.

Index of refraction

Photons (light particles) with different energies or frequencies result in different behavior when the light travels through a medium, such as prism glass or a water droplet. The speed of light is only \(c\) in a vacuum. As soon as light starts passing through matter, the electromagnetic fields of the atoms slow it down. The details of the process are a bit complicated, but the point to remember is that it slows down, and the amount it slows down depends on the frequency of the light. So if a ray of white light hits a water droplet, the red light waves (low frequency) will react differently than the blue ones (high frequency). Not only does the light slow down when it moves from air to water, it also changes direction, or "refracts".

The index of refraction is the property of a material, e.g. n~1.000 for air and n~1.333 for water, that indicates the change of the speed of light when entering the material: \(v = c/n\). The index of refraction, same as the amount a photon slows down, is dependent on the frequency of the light, so the numbers quoted above only apply to light at a specific frequency or wavelength (which actually changes slightly along with the speed).

Snell's Law

Snell's law is the equation used to calculate the refraction: Rays in droplet $$\frac{\sin\theta_1}{\sin\theta_2} = \frac{v_1}{v_2} = \frac{n_2}{n_1}$$

This equation says that the ratio of the sine of the incident and refracted angles, \(\theta_1\) and \(\theta_2\), is equal to the ratio of the velocity of the light, v, and the ratio of the indices of refraction, n. All angles are measured relative to the "normal", meaning the line perpendicular to the tangent (dotted gray lines in the figures). Thus a ray of white light will be split into its constituent colors because each has a different frequency, each sees a slightly different value of n, and thus the angle \(\theta_2\) will be different. For water, the index of refraction only varies between 1.33 (red) and 1.34 (violet). $$ \theta_2 = \sin^{-1}\left(\frac{n_1\sin\theta_1}{n_2}\right) $$

Application to rainbows

raindrop geometry

Let's move on to applying these equations to rainbows. Rainbows appear where there are many droplets of water in the air, and all contribute a little bit to the full effect. So we can start with a single droplet and calculate how the sunlight is dispersed. First, we assume the water droplets in the air are perfect spheres, which is close enough to true. We must think about what happens when light hits the water droplet and eventually finds its way to our eyes. There are a couple options. One could be that the sunlight enters the droplet, changes direction a little bit, and exits the other side. This happens, but it won't get us a rainbow. Another option is light entering, being deflected, reflecting off the back of the droplet, and coming back out at another angle towards us. Now we have the makings of a rainbow. Given the orientation, this means that we will only see rainbows when we have the sun at our backs.

We can calculate the angle at which the light will reflect back, relative to the angle of the sun, using Snell's Law, some geometry, and a just a touch of calculus. The figure below shows the angles that the ray of light makes as it passes through and within the droplet. What we will calculate is \(\alpha\), the angle relative to the rays of the sun that enters our eye: $$ \alpha(\theta) = 4\phi - 2 \theta$$ $$= 4 \arcsin(\sin(\theta)/n_2) - 2 \theta $$

We have made use of Snell's law to get the second part of this equation (with \(\phi = \theta_2\) and \(n_1=1\)). The question now is what is \(\theta\) for which we get highest concentration of rays and thus a bright rainbow? Let's plot \(\alpha\) as a function of \(\theta\):

What we want are the angles of incidence, \(\theta\), that have the greatest concentration of rays coming out of the droplet. That point is where the plot to the right is maximized. To get the maximum we can read it from this graph, or to derive it more precisely we can do some calculus: Take the derivative of \(\alpha\) with respect to \(\theta\) and set it equal to zero: $$\alpha'(\theta) = \frac{4 \cos(\theta)}{\sqrt{1-\sin^2\theta/n_2}} = 0 $$ Solve for \(\theta^{max}\): $$ \theta^{max} = \arccos(\sqrt{(n^2-1)/3}) = 59.6^{\circ}$$ Solve for \(\alpha(\theta^{max})\): $$\alpha(\theta^{max}) = 42.52^{\circ}$$ ? We leave the actual geometry, algebra, and calculus as an exercise for the reader :)

From the above equations, we have found that the rainbow will be 42.52° above the rays of the sun. When the sun is closer to setting, the rainbow will appear higher in the sky. See the illustration below showing rays from the sun and the resulting rainbow. Two example droplets are shown to illustrate how different droplets produce each of the color bands. The red light from the higher droplet is refracted into the eye, but the violet light from that droplet is refracted above the eye. The opposite is true for the lower droplet. If we account for the different indices of refraction of different colors of light, we find that the rainbow spans the angles 40.6° (violet) to 42.3° (red).

sun rays and rainbow

Double Rainbows

In case you aren't excited enough about rainbows at this point, maybe some of this guy's enthusiasm for double rainbows will rub off:

double rainbow geometry

The double rainbow occurs when the light undergoes two internal reflections before being refracted out to the viewer's eye. For every reflection and refraction, some of the light is lost, so the 2nd rainbow appears fainter than the main rainbow. It also appears higher in the sky: 50-53° above the sun's rays. In addition, the colors are reversed, with red on the bottom and violet on the top (compare the difference in the exit paths of the orange and purple rays between the single and double reflection illustrations).


While we have done our best to assure accurate results, the authors of this website do not make any representation or warranty, express or implied, regarding the calculators on this website, nor assume any liability for its use. The code implementation is the intellectual property of the developers.

Please let the webmaster know if you find any errors or discrepancies.
We also take suggestions for new calculators to include on the site.