Snell's law explains the relationship between the angle of refraction, incidence, and the refractive law of indices for the specified media such as light, glass, and air. It asserts that the ratio of the sines of the angle of incidence 1 and angle of refraction 2 for a given set of media is equal to the ratio of phase velocities (v1/v2) in the two media, or equivalently, the refractive indices (n2/n1). When light moves from one medium to another, it undergoes either bending or refraction. The angle of bending is determined by using Snell's law.
Snell's Law Formula
n1 sin θ1 = n2 sin θ2 = μ
Where,
n1 is the initial media,
θ1 is the angle of incidence,
n2 is the final media,
θ2 is the angle of refraction,
μ is the refractive index.
Derivation
Suppose an incident ray OA undergoes refraction from refractive index n1 to that of n2.
The phase velocities of light ray in medium 1 and 2 are,
v1 = c/n1, v2 = c/n2 ⇢ (1)
The time taken (by incident ray) from A to O is,
 t1 = √(x2 + a2)/v1
The time taken (by refracted ray) from O to B is,
 t2 = √(b2 + (l - x)2)/v2
To minimize the total time, we must equate its differential to zero.