Two layers: $h_1 = 3$ cm, $n_1 = 1.5$; $h_2 = 2.5$ cm, $n_2 = 1.25$
Formula: $d_{app} = h_1/n_1 + h_2/n_2$
$= 3/1.5 + 2.5/1.25 = 2 + 2 = \mathbf{4}$ cm
Answer: 4 cm
Refraction: bending of light at interface. Snell\'s Law: $n_1\sin\theta_1 = n_2\sin\theta_2$. Refractive index $n = c/v = \lambda_{vacuum}/\lambda_{medium}$. Denser medium ($n$ larger): light slows, bends toward normal. Rarer medium ($n$ smaller): light speeds up, bends away from normal. Critical angle: $\sin\theta_c = n_2/n_1$, TIR occurs when $\theta > \theta_c$ going from denser to rarer.
For an object at real depth $d$ in medium of index $n$, seen from air: by Snell\'s law for small angles: $n\sin\theta_r \approx n\theta_r = 1 \cdot \sin\theta_i \approx \theta_i$ where $\theta_r$ = angle in medium, $\theta_i$ = angle in air. $\tan\theta_r \approx \theta_r = x/d$ (real), $\tan\theta_i \approx \theta_i = x/d_{app}$ (apparent). So $n/d = 1/d_{app}$ → $d_{app} = d/n$. For multiple layers: each layer shifts image; apparent depth adds: $d_{app} = \sum d_i/n_i$.
Mirage: hot air near ground has lower $n$; light from sky undergoes TIR → appears as water. Looming: cold air near surface has higher $n$; objects appear elevated. Twinkling of stars: atmospheric refraction and turbulence. Prism: $\delta = (n-1)A$ for thin prism; dispersion because $n$ varies with $\lambda$. Optical fibre: TIR keeps light inside fibre core; used in telecommunications (internet, cable TV) and medical endoscopes.
Mirror: $\frac{1}{v} + \frac{1}{u} = \frac{1}{f} = \frac{2}{R}$, magnification $m = -v/u$. Thin lens: $\frac{1}{v} - \frac{1}{u} = \frac{1}{f}$ (Gaussian form), magnification $m = v/u$. Lens maker\'s equation: $\frac{1}{f} = (n-1)\left(\frac{1}{R_1} - \frac{1}{R_2}\right)$. Lens power: $P = 1/f$ (in metres), unit = Dioptre (D). Lenses in contact: $P_{total} = P_1 + P_2$. Sign convention: distances measured from optical centre, positive in direction of incident light.
When light travels from a denser to a rarer medium and the angle of incidence exceeds the critical angle, it is entirely reflected back. The critical angle satisfies $\sin C = 1/\mu$, so a denser medium has a smaller critical angle — about 49° for water and 24° for diamond, which is why diamonds sparkle so strongly. Two conditions are needed and both must be stated: denser to rarer, and incidence beyond the critical angle.
For a prism, $A + \delta = i + e$, where A is the prism angle and $\delta$ the deviation. Deviation is minimum when the ray passes symmetrically, with $i = e$, and at that point $\mu = \frac{\sin\left(\frac{A+\delta_m}{2}\right)}{\sin(A/2)}$ — the standard method for measuring refractive index. Because $\mu$ differs slightly for each colour, violet deviates most and red least, producing dispersion.
An object under water appears raised because refraction bends the emerging rays, giving apparent depth = real depth / $\mu$. This is why a pool looks shallower than it is and a stick appears bent at the surface. A glass slab instead produces no deviation but a lateral shift, because the two surfaces are parallel and the second refraction undoes the angular change of the first while displacing the ray sideways.
Forgetting that total internal reflection needs the denser medium first. Going from rarer to denser, the ray bends toward the normal and can never be totally reflected, whatever the angle.
Using the minimum deviation formula for any deviation. That expression is valid only at minimum deviation, where $i = e$ and the ray passes symmetrically through the prism.