You first calculate the length of the pole as a function of . Now you need to find the minimum of that function. The construction guarantees that you have the largest possible pole, but it needs to fit for all in order to be carried around the corner.
To find the minimum, you set the derivative to zero, of course. And I assume you can take derivatives and manipulate trig functions.
If you run into any more trouble, post again in this thread and I'll answer as soon as I can.