Now a ray of ordinary sunlight is separated into the rays of various colors, which form the solar spectrum when it passes from a medium of one density obliquely to a medium of another density, as when it passes from air to glass, or from air to water, or from outer space into the earth's atmosphere. Under such circumstances its velocity is slowed down when it passes from a rare to a denser medium, and the waves of different wave-lengths are bent from their former course, or refracted, by different amounts. The red rays, of longest wave-length, are bent from their former course the least, and the violet rays, of shortest wave-length, are bent the most upon passing from a rare to a denser medium. As a result the ray of sunlight is spread out or dispersed into its rays of different wave-length and color upon entering a medium of different density. It is this refraction and dispersion of sunlight that produces many color effects in the earth's atmosphere.
The atmosphere is not of uniform density throughout. At high altitudes it is extremely rare. That is, there is little of it in a given volume. Close to the earth's surface, however, it is comparatively dense. Half of all the atmosphere is within three and one-half miles of the surface and half of the remainder lies within the next three and a half miles. We may consider it as made up, on the whole, of layers of different densities, strongly compressed near the surface.
Imagine a ray of sunlight entering the earth's atmosphere from without. If it comes from a point in the zenith its course is not changed upon entering the atmosphere, because light passing from a certain medium--as space--into a medium of different density, is not bent from its course, or refracted, provided it enters the new medium in a direction perpendicular to the surface. If it enters the atmosphere (which is the new medium of greater density) _obliquely_, refraction, or bending of the ray, takes place, and as the ray advances toward the earth, through layers of increasing densities, it is bent from its former course more and more. As the advancing rays of different colors and wave-lengths in the beam of sunlight are slowed down in the new medium, the red rays are turned from their course the least and the violet rays the most and the entire advancing wave-front of the beam of sunlight is bent down more and more toward the horizon, as it proceeds through the atmosphere. As we on the earth's surface see the ray not along its bent course through the atmosphere, but in the direction in which it finally enters our eyes, the effect of refraction upon a ray of light passing through the atmosphere is to displace the object in the direction of the zenith or increase its distance above the horizon. As a result of refraction we see the sun--or moon--above the western horizon after it has really set, and above the eastern horizon before it has really risen. The oval shape that the sun, or moon, often presents on rising or setting, is due to the fact that the light from the lower limb is passing through denser air than the light from the upper limb, and so is refracted more. As a result the lower limb is lifted proportionately more than the upper limb. This distorts the form of the solar or lunar disk, making it appear oval instead of circular.