TITLE: Find if one rectangle can fit inside the other
QUESTION [14 upvotes]: Given two rectangles $R_1(l_1, b_1)$ and $R_2(l_2, b_2)$ where $l$ and $b$ are their length and breadth respectively, how to check if $R_1$ can fit inside $R_2$ or vice versa.
If $R_1$   and $R_2$ lie in the same plane and there exists an orientation of $R_1$ such that it lies completely inside $R_2$, then $R_1$  fits inside $R_2$.

REPLY [6 votes]: Joseph Malkevitch's answer is perfect.
For all who can't read the complete article, here's the most elegant solution (necessary and sufficient condition for a rectangle pxq to fit in a rectangle axb, provided p≥q, a≥b and p>a):

=((a+b)/(p+q))^2+((a-b)/(p-q))^2
Two obvious day-to-day applications: rug on a floor, tray in an oven.