Simulation of a RAINBOW

 
Objective: To simulate the generation of a rainbow using a probability experiment employing the Monte Carlo technique.  (For a general description of the Monte Carlo technique go to the Elementary Probability Demo Collection.)

Level: High school or precalculus, or even probability courses for math majors. This demo could also be used in an introductory physics or science course.

Prerequisites: Basic probability concepts; knowledge of equally likely chance and the chance of winning a lottery. Some basic notions from physics regarding angles of reflection and refraction; that is, elementary optics. Basic trigonometry.

Platform: A computer which has a function that generates random numbers and a color graphics display.

Instructor's Notes:

General Background: We have been fascinated by the phenomena of a rainbow throughout time. It was Sir Isaac Newton's experiment with light passing through a prism that revealed a band of colors varying from red to violet. The colors of the band are violet, indigo, blue, green, yellow, orange, and red. (A pneumonic that is often used to recall these colors is VIBGYOR or Richard Of York Gained Battle In Vain. An alternate form, ROY G. BIV is also used.)

Newton concluded that white light is really a mixture of colored lights, and that each color bends differently as it passes through a prism. Thus we see the band of colored light which is called the visible spectrum. The light we can see is but a portion of the huge spectrum of energy called electromagnetic radiation. 
 


A Rainbow:A rainbow is formed by light from the sun hitting a raindrop. When this occurs the light is refracted (the change of direction of light in passing from one medium to another) into the colors of the spectrum and then reflected (the return of the light from striking a surface) off the back of the raindrop. For more details see Figure 1 and the description below it.

                                                           Figure 1.
 
A light ray hits the drop from direction SA. As the beam enters the drop it is refracted (bent) and then strikes the back wall of the drop at B. It is reflected off the back wall of the drop towards C. As it emerges from the drop at C it is refracted (bent) again.
Each color of the spectrum is refracted at a slightly different angle depending upon it wavelength. For instance violet light is refracted more than red light. As the spectrum of light emerges from the drop an observer on the ground will see only one color depending upon the angle of observation. 
The rainbow we normally see is called the primary rainbow and is produced by one internal reflection within the drop. When conditions are just right a fainter larger secondary rainbow with colors in reverse order appears. This is the result of rays undergoing a second reflection within the drop. It is possible for light to be reflected more than twice within the drop, giving rise to higher order rainbows, but these are rarely seen.
 


In order to develop a mathematical model to simulate a rainbow we need further information about the angles of reflection for the various colors of light within the visible spectrum. This requires familiarity with the laws of reflection and refraction as well as the speed of light in various mediums. For detailed information on these topics see reference [2] and [3]. The following paragraph is a nontechnical summary of the information we need in order to produce an elementary simulation of a rainbow.

The velocity of light is dependent upon the medium through which it passes, like air or water. The change in velocity of light as it passes from air to water cause the refraction, bending, described above. The refraction index or index of refraction is the ratio of the velocities of light in the two media. We can use the refraction indices of the colored light to set up the appropriate angles of refraction and reflection in our simulation. This information together with algebra and trigonometry can be blended to model the color dispersion we see in the phenomena of a rainbow. (More details can be found in the references cited below.)

The Model: Imagine a large number of parallel rays hitting a spherical rain drop. For each ray we plot a single point of light in accordance with the laws of reflection and refraction. For each ray of light we randomly choose a color that will be seen by an observer once it has been refracted and reflected either resulting in a point of light in the primary or secondary rainbow. Since we are randomly assigning a color from the spectrum to a ray, the process is using a Monte Carlo simulation. In order to get the angles correct we use the refraction index of the colored light for the mediums air and water. This also determines the placement of the corresponding dot of light in our picture. Figure 2 shows a result of our simulation using 15,000 rays. In this simulation we have used only the three primary colors red, green and blue for simplicity. Even with this small number of rays the primary 

                                                     Figure 2.

and secondary rainbows are evident, with of course a lot of 'scatter' within the primary arc. In Figure 3 we simulated the rainbow using 30,000 rays. The result is a stronger definition of both the primary and secondary arcs.
 


                          Figure 3.
If the water droplets are sea water then the index of refraction changes for the colors in the visible spectrum. By altering these indices we can simulate a sea water rainbow as depicted in Figure 4.
                                                                Figure 4.

A careful comparison of Figures 3 and 4 shows that the sea water rainbow has a higher arch with a larger separation between the primary and secondary rainbows.

The rainbow figures in this demo were generated by Matlab routines rainbow and rainbowsea respectively. (Click on the names to download these programs. To see a description of the mfile rainbow click on mfiledescription.) These routines are based on an Applesoft Basic program written by eighth and ninth grade students in a summer program supported by NSF; see reference [1] below. Interestingly, there is also additional information on simulating an "acid rainbow," which may occur in the clouds of Venus.

Comments:

There are a number of web sites that contain information on rainbows. Several that were helpful in creating the descriptions above are listed in the references. [6] contains an java applet related to refraction and reflection.)

References:

[1] D. Olson, et al., "Monte Carlo Computer Simulation of a Rainbow", 
The Physics Teacher, April 1990, pp. 226-227.

[2] S. Janke, "Somewhere Within the Rainbow", UMAP Module 724, COMAP, Inc., Lexington, MA. (This work appeared in the UMAP Journal 13 (2), pp. 149 - 174, 1992.)

[3] F.J. Wicklin and P. Edelman, "Circles of Light: The Mathematics of Rainbows", http://www.geom.umn.edu/education/calc-init/rainbow
(This work is based on the module in [2].)

[4] D. Harrison, "LIght", http://www.newi.ac.uk/buckleyc/light.htm

[5] B.T.Lynds, "About Rainbows", http://www.unidata.ucar.edu/staff/blynds/rnbw.html

[6] F.K. Hwang, "Rainbow", http://www.phy.ntnu.edu.tw/java/Rainbow/rainbow.html
(A Java applet that shows refraction and reflection of colored light. Page contains some interesting links for physics.)
 

Credits

Donald Olson
Department of Physics
Southwest Texas State University

and is included in Demos with Positive Impact with his permission.

A web search revealed reference [1]. The Matlab programs were developed by David R. Hill utilizing the Applesoft code in [1].


DRH 4/30/01