Minimize Distance to Walk
Optimization Problem
The first derivative is used to minimize (optimize) distance travelled between two points.
Problem
The diagram below shows the path that Wilson follows every morning to take water from the river to his farm. Help Wilson minimize the total distance travelled from his house to the farm.Solution to the Problem

Two methods, to solve this problem, are suggested.

METHOD 1: In the diagram below we find the distances d and D add them and minimize the total distance.
d = √ [ x^{ 2} + 5^{ 2} ]
D = √ [ (20  x)^{ 2} + 10^{ 2} ]

The total distance T is given by.
T = d + D = √ [ x^{ 2} + 5^{ 2} ] + √ [ (20x)^{ 2} + 10^{ 2} ]

We now need to find the first derivative dT/dx of T with respect to x and check that T has a minimum value then find the value of x that minimizes T.
[ x √ ((x  20)^{ 2} + 100) + (x  20) √( x^{ 2} + 25) ]
dT / dx = 
[ √( x^{ 2} + 25) + √ ((x  20)^{ 2} + 100) ]

The graph of dT / dx is shown below. At approximatel x = 6.6, the first derivative is equal to zero; below that value it is negative and above that same value it is positive. Hence T has a minimum value at around x = 6.6. Let us find the exact value by calculation

The value of x that makes T minimum is found by setting dT / dx = 0 and solving the equation obtained. It is called a critical value of the first derivative. dT / dx = 0 gives
x √ ((x  20)^{ 2} + 100) + (x  20) √( x^{ 2} + 25) = 0

which may be written as
x √ ((x  20)^{ 2} + 100) =  (x  20) √( x^{ 2} + 25)

Square both sides
x^{ 2}((x  20)^{ 2} + 100) = (x  20)^{ 2}( x^{ 2} + 25)

Expand and simplify to obtain the quadratic equation
3 x^{ 2} + 40 x  400 = 0

Solve for x and select the positive value
x = 20 / 3 = 6.67 km (approximately)

METHOD 2: We "construct a virtual house" (projection) H on the other side of the river and then for the distance d + D to be minimum we need to have the points H, O and F to be collinear since the shortest distance between two points is along a straight line. For these points to be on the same line angle HOH' have to be equal (in size) to angle FOF' and the tangent of the two angles have to be equal. Hence

Calculate the tangent in terms of x for both angles as follows
tan(HOH') = 5 / x
tan(FOF') = 10 / (20  x)
10 / (20  x) = 5 / x

Solve for x to obtain
x = 20 / 3 = 6.67 km (approximately)
More references on calculus problems