There are 3 possible routes:
a) run only on the path- that gives the fastest rate.
b) run on the straight line for 1 to 2 over the swamp- that gives the shortest path.
c) run some distance along the path, then through the swamp.
and we can include (a) and (b) as special cases of (c).
If we let "x" be the distance he runs along the path. That leaves 300- x on that path and 400 as the other leg of a right triangle having his path through the swamp as hypotenuse. By the Pythagorean theorem. the length of that path is .
Since he runs distance x at speed 3v, his time for that is . Since he runs distance at speed v, his time for that is .
You want to find the route that minimizes total time so you want to find x that minimizes