Take the first boat's starting point to be the origin. After some time [tex]t[/tex] (in hours), the second boat covers a distance of [tex]20t[/tex] km.
At 4:00 PM, the second boat is 15 km to the east of the dock. After some time [tex]t[/tex], it covers a distance of [tex]15t[/tex] km. Its distance to the dock is given by [tex]15-15t[/tex] km.
The paths of the boats form a right triangle, in which the hypotenuse (also the distance between the two boats) is
[tex]h(t)=\sqrt{(20t)^2-(15-15t)^2}=5\sqrt{9-18t+25t^2}[/tex]
We want to minimize this distance over the time interval [tex]0\le t\le1[/tex].
We have critical points where the first derivative vanishes:
[tex]h'(t)=\dfrac{5(50t-18)}{2\sqrt{9-18t+25t^2}}=0\implies 50t-18=0\implies t=0.36[/tex]
(and at this critical point, we can show the second derivative is positive, indicating a minimum)
The two boats are closest together 0.36 h = 21.6 min after 4:00 PM.