This is really tricky
Let's generalize a bit to say we want to find the quickest path across two media:
We are traveling from point A to point B then to point C by the quickest path possible. The question is, where should point B be placed?
I have set up xy coordinate axes such that:
$\displaystyle O=(0,0)$
$\displaystyle A=(0,-W_1)$
$\displaystyle B=(B,0)$
$\displaystyle C=(L,W_2)$
The distance from A to B is:
$\displaystyle AB=\sqrt{(B-0)^2+(0-(-W_1))^2}=\sqrt{B^2+W_1^2}$
The distance from B to C is:
$\displaystyle BC=\sqrt{(L-B)^2+(W_2-0)^2}=\sqrt{(L-B)^2+W_2^2}$
The speed through medium 1 is $\displaystyle v_1$ and the speed through medium 2 is $\displaystyle v_2$. We assume both velocities are positive values. Thus, using the relationship between distance, constant velocity and time, we find the total time as a function of B is:
$\displaystyle t\(B\)=\frac{\sqrt{B^2+W_1^2}}{v_1}+\frac{\sqrt{(L-B)^2+W_2^2}}{v_2}$
Differentiating with respect to B, we find:
$\displaystyle t'(B)=\frac{B}{v_1\sqrt{B^2+W_1^2}}+\frac{(B-L)}{v_2\sqrt{(L-B)^2+W_2^2}}=\frac{Bv_2\sqrt{(L-B)^2+W_2^2}+(B-L)v_1\sqrt{B^2+W_1^2}}{v_1v_2\sqrt{B^2+W_1^2}\sqrt {(L-B)^2+W_2^2}}$
The denominator will always be positive, so we need only consider:
$\displaystyle Bv_2\sqrt{(L-B)^2+W_2^2}+(B-L)v_1\sqrt{B^2+W_1^2}=0$
$\displaystyle Bv_2\sqrt{(L-B)^2+W_2^2}=(L-B)v_1\sqrt{B^2+W_1^2}$
Let's take a moment to rewrite this:
$\displaystyle \frac{B}{\sqrt{B^2+W_1^2}}\cdot\frac{\sqrt{(L-B)^2+W_2^2}}{L-B}=\frac{v_1}{v_2}$
$\displaystyle \frac{\frac{B}{\sqrt{B^2+W_1^2}}}{\frac{L-B}{\sqrt{(L-B)^2+W_2^2}}}=\frac{v_1}{v_2}$
$\displaystyle \frac{\sin\theta_1}{\sin\theta_2}=\frac{v_1}{v_2}$
Thus, we have shown that Snell's law (or Descartes' law) is satisfied when $\displaystyle t'(B)=0$.