# Largest rectangle inside a square

For e.g I have rectangle with known sides and a square with a known side as well. I would like to know if this rectangle can be inscribed or just can "pass through" the square. I understand that area of rectangle should be lesser or equal. But there is also a case when I rotate the rectangle with some side greater, than square side and rectangle will pass. How to solve it?

Consider a rectangle $ABDC$ of side $2b \times 2a$, placed with center at the origin, like in the sketch.

Then consider a square, sides $2s \times 2s$, also placed with the center at the origin, having one corner at $P=(s,s)$.

It is clear that the minimum square through which the rectangle is still "passing through" would be the one for which
- the segment $AB$ is contained in the square, or
- the segment $A'B'$ ($AB$ rotated by $45^\circ$) is contained in the square
which can be seen by considering to gradually rotate the segment along the circumscribing circle.

In the second case, shifting back the triangle $P'A'B'$ to $PAB$, noting that the angle in $P$ is $90^\circ$, then we will have $$|PH| =a$$ and thus $$|PH|+|HO| =a+b= \sqrt{2}\,s$$

So, to pass we shall have $$a \le b \le s\quad \vee \quad {{a + b} \over {\sqrt 2 }} \le s$$

At this point we can scale by a factor 2 and tell the inequalities above are for a rectangle of sides $a,b$ and a square of side $s$

As usual, you should draw a picture, like below. Let the short side of the rectangle be $a$, the long side $b$, and the side of the square be $s$. To fit horizontally we need $a\cos (\frac \pi 2-\theta)+b\cos \theta =a\sin \theta + b \cos \theta \le s$. Similarly, to fit vertically we need $a \cos \theta + b \sin \theta \le s$

For a given $a,b$ you can find the minimum $s$ and proper $\theta$ by setting these equal. $$s=a\cos \theta+b\sin \theta=a\sin \theta + b\cos \theta\\ a+\frac b{\tan \theta}=a\tan \theta + b$$ This is a quadratic in $\tan \theta$

• Sorry for stupid question, but how can I count the angle θ? – Dmytro Osaulenko Nov 2 '17 at 14:44
• See the edit... – Ross Millikan Nov 2 '17 at 14:58