Hello,

let l be the length of the beam and x the distance from the fence to the foot of the beam (see attachment)

To calculate lē use Pythagorean theorem:

. Expand the brackets:

l get an extreme value if (lē)' = 0

. Now solve (lē)' = 0

. Plug in the positive value into the equation for lē and calculate afterwards the square root: