A fence q feet tall runs parallel to a building at a distance of p feet from the building. What is the length of the shortest ladder that can reach from the ground over the fence to the wall of the building?


Below you can experiment with different values of p, q and with different ladders. To see if the ladder can be used to reach the building, press Play. You can also find the shortest ladder ( for the given p and q ) that will reach the wall ( just click on Optimize ).

Now let's try to solve this problem.

On the picture above you can see a ladder reaching from the ground ( point A ) to the wall ( point D ). The ladder touches the fence ( point B ), so clearly it is the shortest ladder that can reach to the wall from A. Let us express the length of this ladder in terms of a. Using Pythagorean Theorem we have


It's easy to see that

\begin{displaymath}\vert OA\vert=p+a\qquad\mbox{ and }\qquad \vert OD\vert=q+\vert ED\vert

In order to find the length |ED| we can use the similarity of triangles $\Delta ABC$ and $\Delta BDE$.

\begin{displaymath}\frac{\vert ED\vert}{\vert CB\vert}=\frac{\vert EB\vert}{\vert CA\vert}

\begin{displaymath}\frac{\vert ED\vert}{q}=\frac{p}{a}

So finally:

\begin{displaymath}l(a)=\vert AD\vert=\sqrt{\left(q+\frac{pq}{a}\right)^2+(p+a)^2}

Now we can find the minimum of l(a) for a>0 ( that will give us the shortest ladder ). In order to simplify computations we will find the minimum of


We have



\begin{displaymath}\phi^\prime(a)=0\quad\iff\quad \frac{pq^2}{a^3}=1


If a<p1/3q2/3, then a3<pq2 and $\phi^\prime(a)<0$. If in turn a>p1/3q2/3, then a3>pq2 and $\phi^\prime(a)>0$. Thus it is clear that $\phi$ has a minimum at a0 and of course


has a minimum at a0 too. We can now obtain the length of the shortest ladder by plugging a0 into l(a):


This page including the Java applet was written by Marek Szapiel.