A fence

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 |

So finally:

Now we can find the minimum of

We have

So

If

has a minimum at

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