Problem.
Find the longest ladder we can turn right in the corridor.
Finding the longest one, we should consider only the positions of the red colour ladder.
The length of the ladder is \[ \ell(\alpha)=\ell_1+\ell_2=\frac{b}{\sin\alpha}+\frac{a}{\cos\alpha},\qquad 0<\alpha<\pi/2. \] We seek the solution of the equation \[ 0=\ell'(\alpha)=-\frac{b\cos\alpha}{\sin^2\alpha}+\frac{a\sin\alpha}{\cos^2\alpha}. \] We obtain \[
\tan^3\alpha_0=\frac{b}{a}.
\]
Since in our case
\[
\frac{1}{\sin\alpha}=\sqrt{1+\frac{1}{\tan^2\alpha}}
\]
and
\[
\frac{1}{\cos\alpha}=\sqrt{1+\tan^2\alpha}
\]
it follows that
\[
\ell(\alpha_0)= ({a}^{2/3}+{b}^{2/3})^{3/2}. \quad\blacksquare
\]
The length of the ladder is \[ \ell(\alpha)=\ell_1+\ell_2=\frac{b}{\sin\alpha}+\frac{a}{\cos\alpha},\qquad 0<\alpha<\pi/2. \] We seek the solution of the equation \[ 0=\ell'(\alpha)=-\frac{b\cos\alpha}{\sin^2\alpha}+\frac{a\sin\alpha}{\cos^2\alpha}. \] We obtain \[
\tan^3\alpha_0=\frac{b}{a}.
\]
Since in our case
\[
\frac{1}{\sin\alpha}=\sqrt{1+\frac{1}{\tan^2\alpha}}
\]
and
\[
\frac{1}{\cos\alpha}=\sqrt{1+\tan^2\alpha}
\]
it follows that
\[
\ell(\alpha_0)= ({a}^{2/3}+{b}^{2/3})^{3/2}. \quad\blacksquare
\]