Find if one rectangle can fit inside the other

Look at: http://www.jstor.org/stable/2691523


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):

Rectangle pxq fit in rectangle axb

=((a+b)/(p+q))^2+((a-b)/(p-q))^2

Two obvious day-to-day applications: rug on a floor, tray in an oven.