This past week, certain portions of the internet worked themselves into a tizzy over a math problem about a crocodile.

Specifically, this problem:

The problem was written into this year’s Higher Maths exam in Scotland, and has since been the source of much angst for Scottish high schoolers and many Twitter jokes for everyone else.

As with most word problems, I’m sure that what confounded people was making the translation between a verbal description of the problem and a set of equations.  The actual math problem that needs to be solved is pretty standard for a calculus class.  It just comes down to finding the minimum of the function $T(x)$ (which is one of the things that calculus is absolutely most useful for).  In practical terms, that means taking the derivative $dT/dx$ and setting it equal to zero.

But it turns out that there is a more clever way to solve the problem that doesn’t require you to know any calculus or take any derivatives.  It has fewer technical steps (and therefore comes with a smaller chance of screwing up your calculation somewhere along the way), but more steps of logical thinking.  And it goes like this.

The problem is essentially asking you to find the path of shortest time for a crocodile moving from one point to another.  If the crocodile were just walking on land, this would be easy: the quickest route is always a straight line.  The tricky part is that the crocodile has to move partly on land and partly on water, and the water section is slower than the land section.

If you want to know the speed of the crocodile on land and on water, you can pretty much read them off directly from the problem statement.  The problem gives you the equation $T(x) = 5\sqrt{36 + x} + 4(20-x)$.  The quantity $20 - x$ in that equation represents the path length for the on-land section, and the quantity $\sqrt{36 + x^2}$ is the path length for the water section.  (That square root is the length of the hypotenuse of a triangle with side lengths $x$ and $6$ — apparently the river is 6 meters wide.)  Since $\textrm{time} = \textrm{distance} / \textrm{velocity}$, this means that the on-land speed is $(10/4)$ m/s, and the water velocity is $(10/5)$ m/s  (remember that the units of time were given in tenths of a second, and not seconds — not that it matters for the final answer).

That was just interpreting the problem statement.  Now comes the clever part.

The trick is to realize that the problem of “find the shortest time path across two areas with different speed” is not new.  It’s something that nature does continually whenever light passes from one medium to another:

I’m talking, of course, about Fermat’s principle: any time you see light go from one point to another, you can be confident that it took the shortest time path to get there.  And when light goes from one medium to another one where it has a different speed, it bends.  (Like in the picture above: light moves slower through the glass, so the light beam bends inward in order to cross through the glass more quickly.)

The bending of light is described by Snell’s law:

$\sin(\theta_1)/\sin(\theta_2) = v_1/v_2$,

where $v_1$ and $v_2$ are the speeds in regions $1$ and $2$, and $\theta_1$ and $\theta_2$ are the angles that the light makes with the surface normal.

Since our crocodile is solving the exact same problem as a light ray, it follows that its motion is described by the exact same equation.  Which means this:

$(\sin \theta_r)/(\sin \theta_l) = v_r/v_l$

Here, $v_l = (10/4)$ m/s is the crocodile speed on land, and $v_r = (10/5)$ m/s is its speed in the river.  The sine of $90^o$ is $1$, and the sine of $\theta_r$ is $\text{opposite}/\text{hypotenuse} = x/\sqrt{36 + x^2}$.

So in the end the fastest path for the crocodile is the one that satisfies

$x/\sqrt{36 + x^2} = 4/5$.

If you solve that equation (square both sides and rearrange), you’ll get the correct answer: $x = 8$ m.

So knowing some basic optics will give you a quick solution to the crocodile problems.

This happy coincidence brings to mind a great Richard Feynman quote: “Nature uses only the longest threads to weave her patterns, so each small piece of her fabric reveals the organization of the entire tapestry.”  It turns out that this particular tapestry had both light rays and crocodiles in it.

$\hspace{1mm}$

$\hspace{1mm}$

By the way, this post has a very cool footnote.  It turns out that ants frequently have to solve a version of this same problem: they need to make an efficient trail from the anthill to some food source, but the trail passes over different pieces of terrain that have different walking speeds.

And, as it turns out, ants understand how to follow Fermat’s principle too!  (original paper here)

1. October 11, 2015 1:54 am

Neat. I am sure your solution is correct in the case where the finishing point is fixed. Within the fictional world of the maths problem, it is, but in the real world that this reflects, it would not be.

The zebra may remain blissfully unaware of the crocodile’s intentions while the latter is in the water but not once he emerges onto the land. At this point, the zebra will spot the crocodile and start to run away. We now have a problem more akin to Achilles and the Tortoise except that in this case I think the tortoise can run faster than Achilles.