Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

consider a two dimensional system. two points are given whose co-ordinates are $(h1,h2)$ and $(k1,k2)$. I want to minimize the distance between these two points with the condition that person has to go to each co-ordinates axes while going from $(h1,h2)$ to $(k1,k2)$. So possible conditions are

1.$(h1,h2)$ to $(0,0)$ to $(k1,k2)$

2.$(h1,h2)$ to $(0,y)$ to $(x,0)$ to $(k1,k2)$

3.$(h1,h2)$ to $(x,0)$ to $(0,y)$ to $(k1,k2)$

so I want to minimize this distance.

so let $(x,0)$ and $(0,y)$ be the two general points on co-ordinate axes the the distance s is given by


where $s1$=$sqrt((h1)^2+(h2-y)^2)$



I could have took $x$ with $h1$ and $y$ with $k2$ but that depends upon the $(h1,h2)$ $(k1,k2)$, in either case final result will not change.

I know to minimize $s$ we need to differentiate $s$ and put it equal to 0. But since there are two variables x and y, I am not able to solve . Can someone help me with this.


some test cases

$h1$----$h$2-----$k1$------ $k2$--------$ans$--------------- $path$

1-------1---------2---------2----------- 4.242641-------(1,1)->(0,0)->(2,2)



share|cite|improve this question
You could set the partials wrt $x$ and $y$ to be zero. Alternately, draw a light ray from one point reflecting off both axes to reach the second point... – Macavity Jun 27 '14 at 5:52
@Macavity can you kindly explain the your method – user157920 Jun 27 '14 at 5:54
His method is in every physics book on optics, "How to find the image of an object in a mirror. Try it for one mirror to get comfortable with the method, then use two, each one on one coordinate axis – Lord_Gestalter Jun 27 '14 at 5:57
Can you provide a link which can be useful for this problem – user157920 Jun 27 '14 at 6:07
Let me see if I can draw something that helps you. Otherwise, search for Fermat's principle and Reflection (e.g. – Macavity Jun 27 '14 at 6:43
up vote 2 down vote accepted


Reflection Approach

Note you could have also reflected $H$ across $x$-axis instead and $K$ across the $y$-axis. But then you may get negative intercepts for $X, Y$. Can you think through why this would give the shortest path and what happens in other cases (e.g. $H'K'$ passing through the origin)?

Alternate approach is the calculus one, or using triangle inequality (the same graph gives you the hint for that as well).

share|cite|improve this answer
thank you so much sir, very well explained now I have a general idea on how to solve this kind of a problem but can you explain why this strategy leads to shortest path in each case – user157920 Jun 27 '14 at 8:35
if H'K' pass through origin then the equation of line would be y=-x which gives s=sqrt(h1^2+h2^2)+sqrt(k1^2+k2^2) is this right?? – user157920 Jun 27 '14 at 8:57
@user157920 Yes. In general, you will find $H'$ and $K'$ are in II and III quadrants (or vice versa). Now any path between $H$ and $K$ which touches both axes in the manner described, has a corresponding path connecting $H'$ and $K'$ of the same length. So the straight line $H'K'$ is the shortest path, and has length $\sqrt{(h_1+k_1)^2+(h_2+k_2)^2}$. When the path passes through the origin, this is the same as the expression you put down. – Macavity Jun 27 '14 at 10:05
thank you so much sir @Macavity – user157920 Jun 27 '14 at 15:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.