Optimization Problem - a rod inside a hallway 
The question:
I'm given the figure shown above, and need to calculate the length of the longest rod that can fit inside this figure and rotate the corner.
My thoughts: 
I have tried doing the following : put $(0,0)$ at the bottom left corner. This way, the place where the rod touches the upper block is $(2,1) $ , and if we denote by $(2+t,0)$ the place where the rod touches the lower block, we get that the place where it touches the lower block is $y=t+2 $ , and then, the length is $d=\sqrt{2}(t+2)$ which doesn't have a maximum.
What am I doing wrong ? 
THe final answer should be $ \sqrt{(1+\sqrt[3]{4} ) ^2 + (2+\sqrt[3]{2})^2 } $ .
Thanks ! 

Let's say the rod makes an angle $\theta$ with the long wall.  Let's say the wide area has width $W$ and the narrow area has width $N$.  Then, the length of the rod that can fit in at angle $\theta$ is
$$x = \frac{W}{\sin \theta} + \frac{N}{\cos \theta} = W \csc \theta + N \sec \theta.$$
There's a minimum in there at some $\theta$:
$$\frac{dx}{d \theta} = N \sec \theta \tan \theta - W \csc \theta \cot \theta = 0.$$
This simplifies to
$$\tan^3 \theta = W/N = 2.$$
Now if $\tan \theta = \sqrt[3]{2},$
$$\cos \theta = \frac{1}{\sqrt{1 + \sqrt[3]{4}}}; \sin \theta = \frac{\sqrt[3]{2}}{\sqrt{1 + \sqrt[3]{4}}},$$
and the rest should follow.
