(APEX Calculus, Section 4.3, pg. 177)
15) A woman throws a stick into a lake for her dog to fetch; the stick is 20ft down the shore line and 15ft into the water from there. The dog may jump directly into the water and swim, or run along the shore line to get closer to the stick before swimming. The dog runs about 22ft/sec and swims 1.5ft/sec.

We are given the distance of the shoreline (15ft) and distance from shore (30ft). The optimal point for the pooch to switch from running to swimming lies at some point x between 0ft and 15ft along the shoreline. We can divide the shoreline into two segments, x and 15 less x.

\[ \begin{align} shore &= 15 = x + (15-x) \\ water &= 30 \\ hypoteneuse &= \sqrt{x^{2}+30^{2}} \end{align} \]

The total time is a composite of swimtime on the hypoteneuse of the triangle with base of distance x and height of distance 30; and runtime on distance of 15 less x.

\[ \begin{align} time &= swimtime + runtime \\ &= \frac{(15-x)ft}{22 ft/sec} + \frac{(\sqrt{x^{2}+30^{2})ft}}{1.5ft/sec} \\ &= \frac{15}{22}-\frac{x}{22}+\frac{\sqrt{x^{2}+30^{2}}}{1.5} \end{align} \]

The endpoints of the interval are unlikely to provide minima, but we check to be sure.

\[ \begin{align} c(0) &= \frac{15}{22}-\frac{0}{22}+\frac{\sqrt{0^{2}+30^{2}}}{1.5} \\ &= \frac{15}{22}+\frac{30}{1.5} \\ &= 20.68182 \\ c(15) &= \frac{15}{22}-\frac{15}{22}+\frac{\sqrt{15^{2}+30^{2}}}{1.5} \\ &= \frac{\sqrt{1125}}{1.5} \\ &= 22.36068 \end{align} \]

The critical values are found by solving for \(c'(0)\).

\[ \begin{align} c'(x)=0-\frac{1}{22}&+\frac{x}{1.5\sqrt{x^{2}+30^{2}}} \\ \frac{1}{22}&=\frac{x}{1.5\sqrt{x^{2}+30^{2}}} \\ \sqrt{x^{2}+30^{2}}&=22x \\ x^{2}+30^{2}&=(22x)^{2} \\ 483x^{2}&=900 \\ x^{2}&=\frac{900}{483} \\ x&=1.365047 \\ \end{align} \]

This critical value designated a minimum on the [0, 15] interval, and we can solve for swimming and running distance and time.

shoredist_swim <- sqrt(900/483)
shoredist_run <- 15-shoredist_swim
waterdist <- 30
hypoteneuse <- sqrt(waterdist^2 + shoredist_swim^2)

runtime <- shoredist_run / 22
swimtime <- hypoteneuse / 1.5

shoredist_run
## [1] 13.63495
hypoteneuse
## [1] 30.03104
runtime
## [1] 0.6197706
swimtime
## [1] 20.02069

To minimize time-to-stick-retrieval, the dog should run along 13.6ft of shoreline and then swim 33ft through the water. That’s about .62sec of running followed by nearly 20sec of swimming. Good dog!