Problem:
A ladder is to be carried down a hallway p feet wide. Unfortunately at the end of the hallway there is a right-angled turn into a hallway q feet wide. What is the length of the longest ladder that can be carried horizontally around the corner?


Visualization:

Above you can see a crude picture of the situation. The red bar represents the ladder to be carried. Click on Play to see the animation. You can change the values of p and q as well as the length of the ladder.

Now let's solve the problem. First instead of trying to find the maximal length let's see how to determine if a ladder of a given length l can be carried safely around the corner.

On the picture above we can see the critical moment. The ladder is represented by a red line segment AB of length l. It is easy to find the coordinates of B in terms of a: $B\left(0,\sqrt{l^2-a^2}\right)$. So the equation of a line passing through AB is

\begin{displaymath}\frac{1}{a}x+\frac{1}{\sqrt{l^2-a^2}}y-1=0
\end{displaymath}

The most important point on the picture is R. Its coordinates are (p,q). The ladder touches R if

\begin{displaymath}\frac{1}{a}p+\frac{1}{\sqrt{l^2-a^2}}q-1=0
\end{displaymath}

Otherwise we have

\begin{displaymath}\frac{1}{a}p+\frac{1}{\sqrt{l^2-a^2}}q-1>0
\end{displaymath}

So if

\begin{displaymath}\phi(a)=\frac{1}{a}p+\frac{1}{\sqrt{l^2-a^2}}q-1,\qquad 0<a<l
\end{displaymath}

then we can carry the ladder without getting stuck if and only if

\begin{displaymath}\phi(a)\geqslant0\mbox{ for all }0<a<l
\end{displaymath}

If we find the minimum of $\phi$ on (0,l) and test if it is greater or equal zero then we are done. Now:

\begin{displaymath}\phi^\prime(a)=-\frac{p}{a^2}+\frac{aq}{\left(l^2-a^2\right)^{3/2}}
\end{displaymath}


\begin{displaymath}\phi^{\prime\prime}(a)=\frac{2p}{a^3}+
\frac{q\left(l^2-a^2\r...
...sqrt{l^2-a^2}}{\left(l^2-a^2\right)^3}
>0\mbox{ for all }0<a<l
\end{displaymath}

The second derivative tells us that $\phi$ is concave up, so its critical value is a minimum. Let's solve

\begin{displaymath}-\frac{p}{a^2}+\frac{aq}{\left(l^2-a^2\right)^{3/2}}=0
\end{displaymath}

for a by multiplying both sides by $a^2\left(l^2-a^2\right)^{3/2}$:

\begin{displaymath}-p\left(l^2-a^2\right)^{3/2}+a^3q=0
\end{displaymath}


\begin{displaymath}a^2\left(p^{2/3}+q^{2/3}\right)=p^{2/3}l^2
\end{displaymath}


\begin{displaymath}a_0=a=\frac{p^{1/3}l}{\sqrt{p^{2/3}+q^{2/3}}}\mbox{ is a minimum }
\end{displaymath}

If we have the values of p, q, l given, we can compute a0 and see if $\phi(a_0)\geqslant0$.

If $\phi(a_0)=0$, then our ladder has the biggest possible length. So in order to find the length of the longest ladder plug a0 expressed in terms of p, q, l into

\begin{displaymath}\frac{1}{a}p+\frac{1}{\sqrt{l^2-a^2}}q-1=0
\end{displaymath}

and solve it for l. You should obtain

\begin{displaymath}l_{max}=\left(p^{2/3}+q^{2/3}\right)^{3/2}
\end{displaymath}

This page and the Java applet were written by Marek Szapiel.