Shortest line between perpendicular lines passing through a point

Given two perpendicular lines, $A$ and $B$, and a point $p$, I'm trying to find the points $a$ on $A$ and $b$ on $B$, such that $\overline{ab}$ passes through $p$ and is as short as possible. I'm not very math-y, and my googling has failed to turn up a solution. Is there one?

• Do we know any measurements or coordinates? – randomgirl Dec 1 '17 at 22:31
• Have you taken calculus? – The Chaz 2.0 Dec 1 '17 at 22:31
• I think it's worth noting that if the lines $A$ and $B$ are walls of a hallway that goes around a corner, and the point $P$ is the inside corner of that hallway, the shortest possible distance $ab$ is also the length of the longest possible pipe or ladder that can be carried around the corner. And the steps in solving that problem include finding the points $a$ and $b.$ See math.stackexchange.com/questions/583707/… – David K Dec 1 '17 at 23:27
• @me-- are you ok with the solution? – gimusi Dec 3 '17 at 9:43
• @me-- you can set as solved if you are ok – gimusi Dec 3 '17 at 10:01

Solution can be found by Pythagoras theorem to evaluate the minimum of the lenth square of the segment

here is a derivation of the solution here is some graph of the solution for $(X_P,Y_P)\in$ line $x+y=1$ • Thank you I've fixed yhe typo! – gimusi Dec 1 '17 at 23:01
• The handwriting is not the easiest to read but the result agrees with math.stackexchange.com/a/1290503 (specifically, the intermediate step that says $x^3=AB^2$), so I'm reasonably sure it's correct. – David K Dec 1 '17 at 23:33
• Thanks, I'm preparing some graph to vizualize the solution :) – gimusi Dec 1 '17 at 23:48

The equation of any straight line passing through $P(h,k)$ can be set to $$\dfrac{y-k}{x-h}=m$$y/(k-mh)-mx/(k-mh)=1$$We need to minimize$$(k-mh)^2+(k-mh)^2/m^2$$Now use$$2(a^2+b^2)\le(a+b)^2