On the same side of a straight river are two towns, and the townspeople want to build a pumping station, S. The river is 4 miles long from town 1 to town 2. town 2 is 4 miles away from the rivers edge. town 1 is 1 mile from the river. The distance between town 1 and the pumping station,S, is x. The pumping station is to be at the rivers edge with pipes extending straight to the two town. Where should the pumping station be located to minimize the total length of the pipe?
1 Answer

x = 1.28
details to follow
Draw the river as a 4 mile vertical line (south to north).
Put town 1 1 mile east of the bottom (south end) of the river and town to 4 miles east of the north end of the river.
Then the distance from the pumping station to each town is the hypotenuse of a right triangle.
Town 1 right triangle:
distance between pump and town = x
distance between town and river = 1
distance up the river from town 1 to pump station = a
so x = √(a^2 + 1^2) = √(a^2+1)
Town 2 right triangle:
distance between pump and town = y
distance between town and river = 4
distance down the river from town 2 to pump station = 4a
so y = √((4a)^2 + 4^2) = √(a^28a+32)
then the total pipe distance (D) = x+y
D = √(a^2+1) + √(a^28a+32)
take the derivative with respect to a and set equal to zero
0 = (1/2)(2a)(a^2+1)^(1/2) + (1/2)(8+2a)(a^28a+32)^(1/2)
simplify
0 = a(a^2+1)^(1/2) + (a4)(a^28a+32)^(1/2)
eliminate roots by multiplying by the difference (difference of squares method)
0 = (a(a^2+1)^(1/2) + (a4)(a^28a+32)^(1/2)) * (a(a^2+1)^(1/2) – (a4)(a^28a+32)^(1/2))
simplify
0 = a^2/(a^2+1) – (a4)^2/(a^28a+32)
eliminate denominators by multiplying through by them
0 = a^2(a^28a+32) – (a4)^2 * (a^2+1)
perform the multiplication
0 = a^4 8a^3+32a^2 – (a^2 8a +16)(a^2+1)
0 = a^4 8a^3+32a^2 – (a^4+a^2 8a^3 8a +16a^2 +16)
0 = a^4 – 8a^3 + 32a^2 – a^4 +8a^3 17a^2 +8a 16
simplify by combining like terms
0 = 32a^2 17a^2 +8a 16
0 = 15a^2 + 8a – 16
use quadratic equation to determine solution for a
a = (8 +/ √(64+4*15*16))/(2*15)
drop the negative term because we need a positive answer
a = (8 + 32) / 30 = 0.8 (distance up river from town 1 to pump station)
x = √((0.8)^2+1) = 1.28 (distance between town 1 and pump station)
y = √((0.8)^28(0.8)+32) = 5.12 (distance between town 2 and pump station)
4a = 3.2 miles (distance down river from town 2 to pump station)