# How to find minimum distance path between 2 points on a surface

Given a surface equation is $z=f(x,y)$ and also given two points on surface are $A(x_1,y_1,z_1)$ and $B(x_2,y_2,z_2)$

How can be found the path equation $(x=p(t),y=s(t),z=u(t))$ that it creates minimum distance between A and B on the surface $z=f(x,y)$ ?

we can write that if $z=ax+by+c$ (plane) then the path equation must be a line between two points. (Proof done by using Euler-Lagrange Equation, the link is below)

And also as a sense (without proof) If $z=\sqrt{r^2-x^2-y^2}$ (sphere) then the path equation must be the circle that its center is on origin.

My attempt to solve it:

$$d=\int^{t_1}_{t_2} \sqrt{dx^2+dy^2+dz^2}$$ $$d=\int^{t_1}_{t_2} \sqrt{\frac{dx^2}{dt^2}+\frac{dy^2}{dt^2}+\frac{dz^2}{dt^2}} dt$$

$$d=\int^{t_1}_{t_2} \sqrt{p'(t)^2+s'(t)^2+u'(t)^2} dt$$

And also we know that $z=f(x,y)$

thus

$$u(t)=f(p(t),s(t))$$

I need minimum $d$ but I don't know how to proceed after that

I think I must use Euler-Lagrange Equation but I could not establish the equation for 3D. There is solution in here for plane surface.

EDIT: (June 3)

I used same strategy in link that I gave above and I got an equation.

$$F(p'(t),s'(t),u'(t))=\sqrt{p'(t)^2+s'(t)^2+u'(t)^2}$$

For stortest path:

$$0=\int^{t_1}_{t_2} \frac{d}{dt}(\frac{dF}{dp'}+\frac{dF}{ds'}+\frac{dF}{du'}) dt$$

$$\frac{d}{dt}(\frac{dF}{dp'}+\frac{dF}{ds'}+\frac{dF}{du'})=0$$

$$\frac{dF}{dp'}+\frac{dF}{ds'}+\frac{dF}{du'}=k$$

Thus I got an equation for shortest path :

$$\frac{p'(t)+s'(t)+u'(t)}{\sqrt{p'(t)^2+s'(t)^2+u'(t)^2}}=k$$ where k is constant

It seems that the equation confirms for plane case but I am not sure for other examples.

Is it correct equation?

• Try using the fundamental theorem of Calculus to remove the integral sign: $$\frac{d}{dt} \int_{t_2}^{t_1} \sqrt{p'(t)^2+q'(t)^2+r'(t)^2} dt$$ $$\sqrt{p'(t_1)^2+q'(t_1)^2+r'(t_1)^2}-\sqrt{p'(t_2)^2+q'(t_2)^2+r'(t_2)^2}$$ This can be set equal to zero to find the minima and maxima. – FundThmCalculus Jun 2 '15 at 13:55
• We cannot use it here. Because $t_1$ and $t_2$ fixed points. Please check the link I gave. – Mathlover Jun 2 '15 at 13:58
• It seems that you are searching a geodesic: en.wikipedia.org/wiki/Geodesic. – Emilio Novati Jun 2 '15 at 13:59
• Good catch. You are right about that. – FundThmCalculus Jun 2 '15 at 14:11
• You can try Dijkstras algorithm in computer science together with some grid approach, possibly multigrid. – mathreadler Jun 3 '15 at 8:27