You have correctly found, using the Pythagorean theorem and the relation between time, distance and constant velocity:

where f measures time in hours. You then began the process of differentiating f with respect to x to find the critical values.

Noting the denominator is always positive, we then consider:

Observing both sides represent non-negative values, we may square:

A graph of this polynomial shows only one real root for .

Using a root-finding technique such as Newton's method, we find:

The first derivative test confirms this is a minimum, i.e., f'(4) < 0 and f'(5) > 0.

To apply Snell's Law, we could write:

This leads to the same equation we have above.