2. An ellipse is inscribed in a rectangle with length $m$ and width $n$. Find the maximum value of the perimeter of the rectangle that is tangent to this ellipse.
(1983, Shanghai Mathematics Competition)
(Tip: Take the major and minor axes of the ellipse as the $x$-axis and $y$-axis respectively, and set the equation of the ellipse as $\frac{x^{2}}{a^{2}}+\frac{y^{2}}{b^{2}}=1$. From the given information, we have $2 \sqrt{a^{2}+b^{2}}=\sqrt{m^{2}+n^{2}}$. The coordinates of the vertex of the inscribed rectangle in the first quadrant are $(a \cos \theta, b \sin \theta)$ (where $\theta$ is an acute angle). The perimeter of the rectangle is $4(a \cos \theta+b \sin \theta)=4 \sqrt{a^{2}+b^{2}} \sin (\varphi+\theta) \leqslant 4 \sqrt{a^{2}+b^{2}}=2 \sqrt{m^{2}+n^{2}}$ (where $\tan \varphi=\frac{a}{b}$). The equality holds if and only if $\theta=\frac{\pi}{2}-\arctan \frac{a}{b}$.)