In short

Snell's law. When light passes from a medium of refractive index n_1 to a medium of index n_2, it bends so that

\boxed{\; n_1 \sin\theta_1 \;=\; n_2 \sin\theta_2 \;}

with both angles measured from the normal. The ray bends toward the normal going into a denser medium (larger n) and away from the normal going into a rarer medium.

Refractive index. The refractive index of a medium is

n = \frac{c}{v} \;\;\;\;\;(\text{vacuum } n = 1)

where c = 3.00\times 10^8 m/s and v is the speed of light in the medium. Typical values: air 1.0003, water 1.33, glass 1.50, diamond 2.42.

Slab. A light ray crossing a glass slab of thickness t emerges parallel to the incident ray but laterally displaced by

d \;=\; \frac{t\sin(\theta_1 - \theta_2)}{\cos\theta_2}

Apparent depth. An object at real depth h in a medium of index n, viewed from air (index 1) at near-normal incidence, appears at depth

\boxed{\; h_{\text{apparent}} \;=\; \frac{h}{n} \;}

A coin at the bottom of 15 cm of water (n = 1.33) appears at only \approx 11.3 cm.

Frequency stays fixed, wavelength changes. Crossing into a medium of index n, the wave slows from c to c/n, the frequency stays the same, and the wavelength shrinks: \lambda_{\text{medium}} = \lambda_0 / n.

Drop a plastic straw into a glass of nimbu pani on a hot afternoon. Look at it from the side. The straw appears broken at the water line — the part inside the water is shifted sideways from the part in the air, as if two different straws were stuck together at the surface. Now look at a rupee coin lying on the floor of a swimming pool at the Andheri Sports Complex: the coin seems to sit a few centimetres higher than where it actually is, and if you reach in to pick it up, your hand lands on nothing.

Every one of these is light changing direction as it crosses a boundary between two materials with different optical properties. The law governing that direction change is three centuries old, and one line long: n_1\sin\theta_1 = n_2\sin\theta_2. It is called Snell's law after the Dutch astronomer who wrote it down in 1621, though it was known and used by the Persian scholar Ibn Sahl around 984 AD — and the Kerala school of mathematician-astronomers in the 14th century understood the bending of light through water well enough to correct star positions observed through the atmosphere. In this chapter you derive the law from a wave picture, apply it to slabs and pools, and meet the refractive index — the single number that tells you everything about how a medium interacts with light.

The phenomenon — light bends at a boundary

Place a coin at the bottom of an empty tumbler and tip it away from you until the coin just disappears below the rim. Hold that angle. Now, without moving your head, pour water slowly into the tumbler. As the water level rises, the coin reappears — you can see it again, through the water, even though neither your eye nor the coin has moved.

The coin did not move. Your eye did not move. What happened is that the light reaching your eye now travels a different path: it leaves the coin, travels up through the water, bends at the water-air interface, and then continues to your eye. The bend is enough to bring the coin back into the line of sight that was previously blocked by the rim.

Light bending at a water-air boundaryA light ray travelling up from water into air bends away from the normal at the flat water surface. The incident ray is at angle theta-1 from the normal in water; the refracted ray is at angle theta-2 greater than theta-1 in air. water (n = 1.33) air (n = 1.00) normal incident refracted θ₁ θ₂ no bend
A ray travelling from water (denser) into air (rarer) bends away from the normal. The faint dashed line shows where the ray would go if it refused to refract.

Three qualitative facts come out of experiments like this one:

  1. The bending happens only at the boundary. Inside either medium the ray travels in a straight line.
  2. The angle of bending depends on the angle of incidence. A ray hitting the surface perpendicularly (normal incidence) does not bend at all.
  3. The bending is sensitive to what the two media are. Going from air into glass bends the ray more than going from air into water, which bends it more than going from air into alcohol.

The single number that captures "how much medium X bends light" is the refractive index.

Refractive index — how fast light moves

Light travels at c = 2.998 \times 10^8 m/s in vacuum. In air, water, glass, diamond — or any other transparent medium — it travels slower. The refractive index of a medium is the ratio of the vacuum speed to the medium speed:

Refractive index

The refractive index n of a medium is

n = \frac{c}{v}

where c is the speed of light in vacuum and v is the speed of light in the medium.

A denser optical medium (higher n) slows light more. By definition, vacuum has n = 1.

A table of common values:

Medium n Speed v = c/n
Vacuum 1.0000 2.998\times 10^8 m/s
Air (1 atm, 20°C) 1.0003 2.997\times 10^8 m/s
Water (20°C) 1.333 2.250\times 10^8 m/s
Crown glass 1.52 1.972\times 10^8 m/s
Dense flint glass 1.65 1.817\times 10^8 m/s
Diamond 2.42 1.239\times 10^8 m/s

The tiny excess of air's n above 1 is large enough to matter in astronomy — every star you see through the Mount Abu InfraRed Observatory appears a little higher in the sky than it really is, because the atmosphere bends its light downward by a few arcseconds. Near the horizon, the bend is enough that you see the Sun for a minute or two after it has, geometrically, set.

Light slows in a medium — what "slowing" means

A quick clarification: photons still travel at c between atoms even in glass. What the refractive index measures is the group velocity of the electromagnetic wave, which is slower because the photons continually interact with atoms, get absorbed and re-emitted, and the net forward propagation is delayed. You can, for calculation purposes, treat light in a medium as simply moving at c/n — Maxwell's equations inside the medium give exactly this speed, and every optical formula that uses n is consistent with this picture.

Deriving Snell's law from Huygens' principle

The wave picture of reflection (developed in Reflection of Light) extends directly to refraction. The only change is that the wave speed is different on the two sides of the boundary. That one difference produces Snell's law — all of it, in five lines of geometry.

Huygens' construction for refractionA plane wavefront hits a flat boundary obliquely. By the time point B of the wavefront lands on the boundary at B-prime, a secondary wavelet from A has expanded into the slower medium to radius c-tau-over-n. The new wavefront in the medium is the tangent from B-prime to this circle. medium 1 (n₁, v₁ = c/n₁) medium 2 (n₂, v₂ = c/n₂) A B B' wavefront AB wavelet from A (radius v₂τ) new wavefront θ₁ θ₂
At $t = 0$, the wavefront $AB$ has just touched the boundary at $A$. After time $\tau$ (the time $B$ takes to reach $B'$), a secondary wavelet from $A$ has grown to radius $v_2\tau = c\tau/n_2$ in medium 2. The new wavefront is the tangent from $B'$ to this wavelet — and its geometry forces $n_1\sin\theta_1 = n_2\sin\theta_2$.

Step 1. A plane wavefront AB in medium 1 hits the boundary obliquely. At time t = 0, point A just touches the boundary; point B is still above it.

Step 2. Let \tau be the time for B to cover the remaining distance BB' to the boundary. Travelling at v_1 = c/n_1:

BB' = v_1 \tau

During this time, A has started radiating a secondary wavelet into medium 2, where the speed is v_2 = c/n_2. The wavelet has grown to radius

r = v_2 \tau = \frac{c\tau}{n_2}

Why: Huygens says every point on a wavefront becomes a source of secondary wavelets. Those wavelets spread at the local speed of light in whichever medium they are in. A has been emitting into medium 2 for time \tau, so its wavelet has radius v_2\tau in medium 2.

Step 3. The new wavefront in medium 2 is the tangent from B' to the circle centred at A with radius r. Call the tangent point T. Then AT = r and B'T is perpendicular to AT (the definition of tangent).

Step 4. Work out the geometry. In the right triangle AB'B above the boundary, AB' lies on the boundary, and \angle ABB' = \theta_1 (where \theta_1 is the angle between the incident ray and the normal — and the incident ray is perpendicular to the wavefront AB, so the wavefront itself makes angle \theta_1 with the boundary).

BB' = AB' \sin\theta_1

Substituting BB' = v_1\tau:

v_1 \tau = AB' \sin\theta_1

Step 5. In the right triangle AB'T below the boundary, AT = r is perpendicular to B'T, and \angle TAB' = \theta_2 (the angle of refraction — the refracted ray, perpendicular to the new wavefront B'T, makes angle \theta_2 with the normal).

AT = AB' \sin\theta_2

Substituting AT = v_2\tau:

v_2 \tau = AB' \sin\theta_2

Step 6. Divide the two equations to eliminate AB'\tau:

\frac{v_1\tau}{v_2\tau} = \frac{AB'\sin\theta_1}{AB'\sin\theta_2}
\frac{v_1}{v_2} = \frac{\sin\theta_1}{\sin\theta_2}

Why: the \tau cancels, the AB' cancels, and we are left with a relation between angles and speeds alone.

Step 7. Convert speeds to refractive indices using v = c/n:

\frac{c/n_1}{c/n_2} = \frac{\sin\theta_1}{\sin\theta_2}
\frac{n_2}{n_1} = \frac{\sin\theta_1}{\sin\theta_2}

Rearranging:

\boxed{\; n_1 \sin\theta_1 = n_2 \sin\theta_2 \;}

Why: this is Snell's law in its standard form. The quantity n\sin\theta is conserved across the boundary — it does not matter which medium you are in, this combination stays constant.

Step 8. Which way does the ray bend? Going into a denser medium (n_2 > n_1), the ratio \sin\theta_1/\sin\theta_2 = n_2/n_1 > 1, so \sin\theta_2 < \sin\theta_1, so \theta_2 < \theta_1. The ray bends toward the normal. Going into a rarer medium is the reverse — the ray bends away from the normal.

This is the single most used fact in optical design: every pair of glass surfaces in a camera lens, every gemstone cut, every fibre optic cable, every contact lens prescription — all reduce to repeated applications of n_1\sin\theta_1 = n_2\sin\theta_2.

Interactive — drag the angle, watch the bending

Interactive: drag the angle of incidence, see the refracted rayA horizontal boundary between air (above) and glass (n=1.5) below. A draggable red point on the upper left controls the angle of incidence. The refracted ray in glass bends toward the normal. air (n = 1.00) glass (n = 1.50) normal incident refracted drag the red point left/right to change θ₁
Drag the red point to change the angle of incidence $\theta_1$. Watch $\theta_2$ adjust so that $\sin\theta_1/\sin\theta_2 = n_2/n_1 = 1.5$. The faint dashed line shows the (wrong) path the ray would take if it continued straight without refraction — the gap between the dashed line and the solid refracted ray is the full content of Snell's law.

Refraction through a parallel-sided slab

Now apply Snell's law twice: once when a ray enters a glass slab, again when it leaves. A plane-parallel slab is a piece of glass with two flat, parallel faces — a microscope slide, a mobile phone screen glass, a window pane.

The claim: after passing through the slab, the emergent ray is parallel to the incident ray. It is not in the same line — it has been shifted sideways by a distance d called the lateral displacement. But the direction is unchanged.

Refraction through a parallel-sided glass slabA light ray enters a glass slab at angle theta-1, refracts to theta-2 inside, travels through, and emerges at angle theta-1 again, parallel to the incident ray but laterally displaced. air (n₁ = 1) air (n₁ = 1) glass (n₂ = 1.5) t incident emergent d θ₁ θ₂ θ₂ θ₁
The ray enters at $\theta_1$, refracts to $\theta_2$ inside, emerges at $\theta_1$ again — parallel to the incident ray but shifted sideways by the lateral displacement $d$. The dashed line is where the ray would have gone with no slab.

Why the emergent ray is parallel

At the top surface, n_1\sin\theta_1 = n_2\sin\theta_2 (medium 1 is air, medium 2 is glass). At the bottom surface, the ray goes from glass back into air, so

n_2\sin\theta_2 = n_1\sin\theta_1'

But both equations have n_2\sin\theta_2 on one side. Combining:

n_1\sin\theta_1 = n_1\sin\theta_1'
\sin\theta_1 = \sin\theta_1'
\theta_1' = \theta_1

The emergent ray makes the same angle with the normal as the incident ray. Since the two surfaces are parallel, their normals are parallel too, and the emergent ray is parallel to the incident ray. The slab does not change direction — it only shifts.

Computing the lateral displacement

The shift d comes from simple triangle geometry. The slab has thickness t. Inside the slab, the ray travels a distance L = t/\cos\theta_2 along the slanted path. The sideways shift in that path, measured perpendicular to the incident ray direction, comes from the extra angle (\theta_1 - \theta_2) between the slanted path inside and what the path would have been if there were no refraction.

Step 1. Length of slanted path inside the slab:

L = \frac{t}{\cos\theta_2}

Why: the ray enters at the top, exits at the bottom; vertical distance t; angle from vertical \theta_2. So t = L\cos\theta_2, hence L = t/\cos\theta_2.

Step 2. If there were no slab, the ray would have continued at angle \theta_1 from the normal and travelled the same vertical distance t in a slanted length t/\cos\theta_1. The two slanted paths (with-slab and without-slab) share the same starting point on the top surface and end at different points on the plane of the bottom surface — the difference between these endpoints, measured perpendicular to the exiting ray, is d.

Step 3. Drop a perpendicular from the actual exit point to the ghost ray's line. The perpendicular length is d. From the triangle with hypotenuse L (the actual path length in the slab) and angle (\theta_1 - \theta_2) at the entry point between the actual path and the ghost path:

d = L \sin(\theta_1 - \theta_2)

Step 4. Substitute L = t/\cos\theta_2:

\boxed{\; d = \frac{t\sin(\theta_1 - \theta_2)}{\cos\theta_2} \;}

For small angles this reduces to d \approx t(\theta_1 - \theta_2), which for a slab of n = 1.5 at \theta_1 = 30° gives about t \cdot (30° - 19.47°) \cdot \pi/180 = 0.18t — an 18\% shift for a moderately oblique ray.

Apparent depth — why pools look shallow

A coin sits on the bottom of a 15-cm deep tray of water in a Pune home kitchen. You look down at it (nearly vertically). The coin seems to be only 11.3 cm below the surface. This is apparent depth.

The geometry uses small-angle Snell's law. For rays that are close to the normal (so \sin\theta \approx \tan\theta \approx \theta in radians), the law

n_1 \sin\theta_1 = n_2 \sin\theta_2

becomes

n_1 \theta_1 \approx n_2 \theta_2

Now consider a point source O at depth h below the water-air interface. A ray from O near the vertical reaches the surface at a horizontal distance x from the point directly above O. The angles are:

Snell (small angle) for water-to-air: n_{\text{water}} \cdot \theta_1 = n_{\text{air}} \cdot \theta_2, i.e. 1.33\cdot(x/h) = 1.00\cdot(x/h_{\text{apparent}}).

Cancelling x:

\frac{1.33}{h} = \frac{1.00}{h_{\text{apparent}}}
\boxed{\; h_{\text{apparent}} = \frac{h}{n} \;}

For h = 15 cm and n = 1.33, h_{\text{apparent}} = 11.28 cm. A coin in a Kanpur bathtub sits at 15 cm but fishes at 11.3 cm, and the bather's hand grabs water instead.

The reverse case — looking up from under water at an object in air — gives the opposite effect: objects above the surface appear farther than they really are, by a factor of n. This is why a fish that wants to lunge at a dragonfly hovering 20 cm above the surface must learn that the dragonfly is really only 20/1.33 = 15 cm above the water line. Fish evolve excellent refraction intuition.

Worked examples

Example 1: Light from water into glass

A ray of light travelling inside a tank of water (n_w = 1.33) strikes the flat bottom of the tank, which is a glass plate (n_g = 1.50). The angle of incidence in water is 40°. Find the angle of refraction in the glass.

Refraction from water into glass at 40 degreesA ray in water above a glass boundary. The ray hits at 40 degrees from the normal. It refracts in glass to about 35.1 degrees — bending toward the normal because glass is denser than water. water (n = 1.33) glass (n = 1.50) incident refracted 40° 34.7°
Water-to-glass: the ray bends toward the normal because glass ($n = 1.50$) is denser than water ($n = 1.33$). From $40°$ in water to about $34.7°$ in glass.

Step 1. Identify the two media and angles.

n_1 = 1.33 (water), n_2 = 1.50 (glass), \theta_1 = 40°. Find \theta_2.

Step 2. Apply Snell's law.

n_1\sin\theta_1 = n_2\sin\theta_2
1.33 \times \sin 40° = 1.50 \times \sin\theta_2
1.33 \times 0.6428 = 1.50 \times \sin\theta_2
0.8549 = 1.50 \times \sin\theta_2

Why: Snell's law is symmetric in direction; it doesn't matter that we are going from water to glass rather than air to glass. The index of each medium matters, and only those.

Step 3. Solve for \sin\theta_2.

\sin\theta_2 = \frac{0.8549}{1.50} = 0.5699

Step 4. Take the inverse sine.

\theta_2 = \sin^{-1}(0.5699) \approx 34.75°

Why: the ray bent from 40° down to about 34.7°. It bent toward the normal because it entered a denser medium. This confirms the rule: larger n means smaller angle from the normal, which means the ray clings closer to the vertical.

Result. The refracted ray in the glass makes an angle of approximately 34.7° with the normal.

What this shows. Snell's law works for any two media, not just one-in-air. The bending depends on the ratio n_1/n_2: from water (1.33) to glass (1.50), the ratio is 0.89, and the angle shrinks by about . From air (1.00) to glass (1.50) at the same 40° of incidence, the ratio is 0.67 and the angle would shrink much more — to about 25.4°.

Example 2: Lateral shift through a window pane

A ray of sunlight hits a 5.0 mm thick glass window pane of refractive index n = 1.52 at an angle of 60° from the normal. Find the lateral shift of the emergent ray.

Lateral shift of a ray through a 5 mm glass pane at 60 degreesA ray at 60 degrees from the normal strikes a 5 mm glass pane and emerges parallel but laterally displaced by 2.6 mm. air air glass (n = 1.52), t = 5 mm incident emergent d
The incident and emergent rays are parallel but offset by the lateral shift $d$. The $5$ mm-thick glass at $60°$ produces $d \approx 2.6$ mm — small enough that a window does not visually distort the street, large enough to matter in precision optics.

Step 1. Find \theta_2 inside the glass.

n_1\sin\theta_1 = n_2\sin\theta_2
1.00 \times \sin 60° = 1.52 \times \sin\theta_2
\sin\theta_2 = \frac{0.8660}{1.52} = 0.5697
\theta_2 = \sin^{-1}(0.5697) \approx 34.75°

Step 2. Compute the lateral shift.

d = \frac{t\sin(\theta_1 - \theta_2)}{\cos\theta_2}
= \frac{5.0 \text{ mm} \times \sin(60° - 34.75°)}{\cos 34.75°}
= \frac{5.0 \times \sin 25.25°}{\cos 34.75°}
= \frac{5.0 \times 0.4268}{0.8215}

Why: \sin(\theta_1 - \theta_2) is the component of the in-slab slanted path that lies perpendicular to the original direction. Dividing by \cos\theta_2 converts from the in-slab length to the perpendicular offset.

Step 3. Evaluate.

d = \frac{2.134}{0.8215} \approx 2.6 \text{ mm}

Step 4. Sanity check. For \theta_1 = 0° (normal incidence), \theta_2 = 0° and the formula gives d = 0 — no shift. For \theta_1 \to 90° (grazing), \sin(\theta_1 - \theta_2) \to \sin(90° - \theta_c) where \theta_c is the critical angle, and the shift grows rapidly. Both limits make physical sense.

Result. The emergent ray is parallel to the incident ray, shifted sideways by approximately 2.6 mm.

What this shows. Even a thin window pane produces a visible shift at oblique angles. Multiply by many surfaces (a stack of lens elements, a prism sequence, a thick tinted glass) and the shift accumulates. This is why precision instruments — the theodolite used by the Survey of India for triangulation, or the autocollimators in ISRO's optical calibration labs — must account for every slab of glass in the beam path.

Example 3: How high does the coin appear?

A Rs. 5 coin lies at the bottom of a steel tumbler in a Chennai kitchen. The tumbler is filled to 12 cm depth with water (n = 1.33), and on top of the water floats a 3 cm layer of cooking oil (n = 1.47). Looking straight down, what depth does the coin appear to be at?

Coin seen through two-layer fluidA steel tumbler containing 3 cm of oil on top of 12 cm of water. A coin at the bottom appears at the sum of (oil thickness)/n_oil + (water thickness)/n_water = 2.04 + 9.02 = 11.06 cm. oil (3 cm) n = 1.47 water (12 cm) n = 1.33 real coin apparent coin eye (straight down) 15 cm real 11.1 cm apparent
With two layers, the apparent depth is the sum of each layer's apparent thickness. The oil contributes $3/1.47 = 2.04$ cm; the water contributes $12/1.33 = 9.02$ cm; total $\approx 11.1$ cm.

Step 1. Recognise that the apparent-depth formula applies layer by layer when viewed near the normal.

h_{\text{apparent}} = \sum_i \frac{h_i}{n_i}

Why: each layer refracts light independently. The angles are so small (near-normal viewing) that we can apply h_i/n_i to each layer separately and add. The full derivation uses ray-tracing through each interface in the small-angle limit, and every layer's contribution decouples.

Step 2. Apply to the oil layer.

h_{\text{oil, apparent}} = \frac{3.0}{1.47} = 2.041 \text{ cm}

Step 3. Apply to the water layer.

h_{\text{water, apparent}} = \frac{12.0}{1.33} = 9.023 \text{ cm}

Step 4. Add.

h_{\text{total, apparent}} = 2.041 + 9.023 = 11.064 \text{ cm}

Step 5. Compare with the real depth. The actual depth is 3 + 12 = 15 cm. The coin appears about 4 cm higher than it really is — the coin's image is lifted by the combined refraction at both interfaces.

Result. The coin appears to lie at a depth of approximately \mathbf{11.1} cm below the top of the oil.

What this shows. Apparent depth adds in layers. This is the principle behind optical path length, which appears later in the theory of thin films and interferometry. The key insight: refraction at each interface lifts the image by a factor of n, and when you have a stack of layers, the lifts compound. A tumbler that contains oil-on-water produces more image-lift than a plain tumbler of water of the same total depth.

Common confusions

If you came here to use Snell's law, understand where it comes from, and solve slab-and-pool problems, you are done. What follows is the Fermat-principle derivation, the connection to Maxwell's equations, and the variable-index case that produces mirages.

Snell's law from Fermat's principle

Fermat: light travelling from point P_1 in medium 1 to point P_2 in medium 2 takes the path that minimises the total travel time (strictly, makes it stationary).

Let P_1 = (0, h_1) above the boundary and P_2 = (D, -h_2) below. The ray crosses the boundary (the x-axis) at some point (x, 0). The total time is

T(x) = \frac{\sqrt{x^2 + h_1^2}}{v_1} + \frac{\sqrt{(D-x)^2 + h_2^2}}{v_2}

Minimise: dT/dx = 0.

\frac{x}{v_1\sqrt{x^2 + h_1^2}} - \frac{D-x}{v_2\sqrt{(D-x)^2 + h_2^2}} = 0

Recognise the geometric meaning of each term. x/\sqrt{x^2 + h_1^2} = \sin\theta_1, the sine of the angle from the vertical (normal) on the incident side. Similarly, (D-x)/\sqrt{(D-x)^2 + h_2^2} = \sin\theta_2 on the refracted side. So

\frac{\sin\theta_1}{v_1} = \frac{\sin\theta_2}{v_2}

Substituting v = c/n:

\frac{n_1\sin\theta_1}{c} = \frac{n_2\sin\theta_2}{c}
n_1\sin\theta_1 = n_2\sin\theta_2

Fermat's principle recovers Snell's law in one minimisation. The deeper lesson is that the refractive index is, up to a constant, the inverse of the speed of light in the medium — and the rule "light takes the fastest path" is the single axiom that governs all of geometric optics.

Snell from Maxwell's boundary conditions

A still deeper derivation comes from Maxwell's equations and the requirement that the tangential components of \vec{E} and \vec{H} be continuous across the boundary. Write the incident wave as

\vec{E}_i = \vec{E}_{0i} \exp[i(\vec{k}_i\cdot\vec{r} - \omega t)]

and similarly for the reflected and transmitted (refracted) waves. At every point on the boundary and every time, the phase \vec{k}\cdot\vec{r} of each wave must match its partner. The tangential components of the wave vectors must therefore be equal:

k_{i,x} = k_{r,x} = k_{t,x}

The magnitudes are k = n\omega/c (since \omega = ck_0 and k = nk_0 in a medium). The tangential component is k\sin\theta. So

n_1\sin\theta_1 = n_2\sin\theta_2

— exactly Snell's law. This derivation reveals that the law is a consequence of translation invariance along the boundary: the phase of the wave advances at the same rate on both sides, because the boundary conditions are the same at every point along it.

Continuously varying index — mirages

Real media often have an index that varies smoothly with position. Hot air near a Delhi road on a summer afternoon has a lower index than the cooler air above it. The boundary is not sharp — the index grades continuously. In such cases, Snell's law applies infinitesimally: between two very thin layers with indices n(y) and n(y+dy), the relation n\sin\theta = \text{constant} holds. Over the whole path,

n(y)\sin\theta(y) = \text{constant}

For a ray travelling at near-horizontal in hot air that grows hotter downward (index decreasing), \sin\theta must increase — the angle from the vertical grows — until \sin\theta = 1, at which point the ray is horizontal and can no longer descend. It bends back upward, creating an inverted image of the sky in the hot layer. This is a mirage: the shimmering puddle on the road that is not there, but is a real optical image of the sky refracted by the hot air.

The mathematics is the eikonal equation — the continuous-limit version of Snell's law, and it is the starting point of both modern optical design and the ray-tracing algorithms used in computer graphics to render refraction in caustics, water surfaces, and the like. All of it is Snell's law, applied in infinitesimal slices.

Refraction and the speed of light in a medium

A subtle point: the phase velocity of light in a medium is c/n. The group velocity (the speed at which a pulse or energy travels) can be different, and in regions of strong dispersion (rapid variation of n with frequency) it can even exceed c — which does not violate relativity because no information is transmitted faster than c. Snell's law, derived from phase-matching at the boundary, uses the phase velocity and therefore always uses the phase refractive index n(\omega) = c/v_{\text{phase}}.

For the purposes of ray optics and JEE-level problems, you never need to worry about this distinction. Snell's law works. But if you ever wonder why optical communications engineers quote two "refractive indices" for a fibre (phase index and group index), this is why — they are different physical quantities arising from the same underlying material response, and both are needed to design high-speed data links through the optical fibre trunk lines of BSNL and Reliance Jio.

Where this leads next