@JonathanZ Thanks for going all the way to help me out.
An oil-pipe has to connect the oil-well O and the factory F, between which there is a river whose banks are parallel. The pipe must cross the river perpendicular to the banks. Find the position and nature of the shortest such pipe and justify your answer.
I tried out this problem with some numbers and got the idea of path of minimum pipe length. How can I do it more rigorously?
This is what I got through my intuition. I think blue one is the minimal path.






$d_1^2=a^2+x^2$
$d_2^2=b^2+(1-x)^2$
$y=d_1+d_2=\sqrt{(a^2+x^2 )}+\sqrt{(b^2+(1-x)^2 )}$
Note that w does not appear here, so it doesn't matter. We can set it to zero and looking at the diagram the answer becomes obvious, but let's just verify that:
We need to find the x that minimises y
$\frac{dy}{dx}=\frac{d(\sqrt{a^2+x^2}+\sqrt{b^2+(1-x)^2})}{dx}=\frac{x}{\sqrt{a^2+x^2}}-\frac{1-x}{\sqrt{b^2+(1-x)^2}}=0$
$\frac{1-x}{\sqrt{b^2+(1-x)^2}}=\frac{x}{\sqrt{a^2+x^2}}$
${1-x}{\sqrt{a^2+x^2}}={x}{\sqrt{b^2+(1-x)^2}}$
$(1-x)^2(a^2+x^2)-x^2(b^2+(1-x)^2)=0$
$(a^2 - b^2 ) x^2- 2 a^2 x + a^2=0$
$x=\frac{a}{a+b}$ or $x=\frac{a}{a-b}$
Only the first one makes sense for a minimum so the other must be a max (check by getting 2nd derivative)
So pick x so that it is in the proportion a/(a+b) of the y distance to the factory, i.e. on a straight line to the factory if the river was not there.