Problem:
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?

Visualization:

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

|AD|2=|OA|2+|OD|2

It's easy to see that

In order to find the length |ED| we can use the similarity of triangles
and
.

So finally:

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

So

a0=p1/3q2/3

If
a<p1/3q2/3, then a3<pq2 and
.
If in turn
a>p1/3q2/3, then a3>pq2 and
.
Thus it is clear
that
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):