Why the sky is blue — and sunsets red

Concept: tiny air molecules scatter short (blue) wavelengths far more than long (red) ones.

☀ sun (transmitted light)  ▮ scattered light reaching your eye (R · G · B)  — the taller the bar, the more that colour is scattered
sun elevation θ 90°,
air mass 1.00,
blue:red scatter 6.4×,
sun colour warm white
scatter ∝ 1/λ⁴  ⟹  blue (440 nm) scatters (700/440)⁴ ≈ 6.4× more than red;  transmitted = e⁻ᵗ·ᴬᴹ, air mass AM = 1/sin θ

What you'll learn

Rayleigh scattering. Air molecules are far smaller than the wavelength of light, so they scatter it with an intensity that grows as 1/λ⁴. Blue light (λ≈440 nm) therefore scatters about (700/440)⁴ ≈ 6.4× more strongly than red (λ≈700 nm). Looking away from the sun, the sky is filled with this scattered blue light.

Why sunsets are red

Near the horizon, sunlight travels through much more atmosphere — the air mass rises as AM = 1/sin θ. Over that long path almost all the blue is scattered out of the direct beam (Beer–Lambert: transmitted intensity = e−τ·AM, with the optical depth τ largest for blue), so the sun and horizon glow orange and red.

What the animation shows

The sun disc is coloured by the transmitted beam and the R/G/B bars show the scattered fraction (1 − e−τ·AM) per channel — both computed live from the elevation you set. It is a single-scattering Rayleigh model (τ₀ ≈ 0.06 / 0.16 / 0.40 at zenith for red/green/blue).

Sources

Lord Rayleigh (1871); Bohren & Huffman, Absorption and Scattering of Light; standard atmospheric Rayleigh optical depths.