# How to find the largest rectangle inside an ellipse [duplicate]

I have an ellipse that is defined by center, width and height. The axes of the ellipse parallel to the x and y. I want to find the largest rectangle that completely fits inside this ellipse. Is there an easy way to do this?

And sorry if my terminology is a bit off... it's been a long time since I last tackled with geometry

-

## marked as duplicate by Bookend, Jyrki Lahtonen♦Dec 7 '15 at 23:10

sorry. edited the question. – vainolo Oct 10 '12 at 21:14
What do you mean by "largest" - area or perimeter? – marty cohen Oct 26 '15 at 22:08

The naive thing is to see the ellipse as a stretched circle. We know the size of the largest rectangle that fits in a circle of radius $r$ is a square of side ${\sqrt 2}r$. If the semi-axes are $a$ and $b$ we would expect the rectangle to be ${\sqrt 2}a \times {\sqrt 2}b$.

To prove this, let us put the center at the origin. The equation of the ellipse is $\left(\frac xa\right)^2+\left(\frac yb\right)^2=1$. The area of the rectangle is $4xy,$ where $(x,y)$ is a point on the ellipse and we choose the point to maximize it. The area is then $4xb\sqrt{1-\left(\frac xa\right)^2}$. The derivative of this is $\frac {4b(a^2-2x^2)}{\sqrt{1-\left(\frac xa\right)^2}}$ which is duly zero at $x=\frac a{\sqrt 2}$, giving a side of $\sqrt 2 a$

-
Sorry, but I lost you at "to prove this"... why do I need to prove things to calculate a rectangle? – vainolo Oct 10 '12 at 21:30
@vainolo: I wanted to prove that the rectangle cited in the first paragraph is in fact the largest rectangle that fits in the ellipse. If you believe it from the first paragraph, you don't need to prove it. – Ross Millikan Oct 10 '12 at 21:39
OK, so you mean that the rectangle is $w=\sqrt{2}a, h=\sqrt{2}b$ centered like the ellipse? – vainolo Oct 10 '12 at 21:40
@vainolo: Correct – Ross Millikan Oct 10 '12 at 21:42
For a proof, it is sufficient to observe that stretching will scale the areas of all rectangles by the same factor. – Théophile Jul 22 '14 at 15:58

Top right corner on the ellipse (centered on origin): $x = a \cos \theta$ and $y=b\sin\theta$

where $0\le \theta \le \frac{\pi}{2}, a=\frac{width}{2}$ and $b = \frac{height}{2}$

So area:$$A(\theta) = 4xy=4ab\sin\theta\cos\theta = 2ab\sin2\theta$$ Maximum of sin is at $2\theta=\frac{\pi}{2}$. So, we have $\theta = \frac{\pi}{4}$. Therefore the 4 corners are: $$(a\cos \frac{\pi}{4},b\sin \frac{\pi}{4}), (a\cos \frac{3\pi}{4},b\sin \frac{3\pi}{4}), (a\cos \frac{5\pi}{4},b\sin \frac{5\pi}{4}), (a\cos \frac{7\pi}{4},b\sin \frac{7\pi}{4}),$$

which are of course equal to:

$$(\frac{a\sqrt{2}}{2},\frac{b\sqrt{2}}{2}), (-\frac{a\sqrt{2}}{2},\frac{b\sqrt{2}}{2}), (-\frac{a\sqrt{2}}{2},-\frac{b\sqrt{2}}{2}), (\frac{a\sqrt{2}}{2},-\frac{b\sqrt{2}}{2}),$$

And it's area is: $a\sqrt{2}\cdot b\sqrt{2}=2ab$

-

Using the equation $1 = y^2/n + x^2/m$ for the ellipse, write definitions for side lengths as $2(y^2/n)$ and $2(x^2/m)$. Area equals the product of these sides. Using substitution assert that $(1 - x^2/m) = y^2/m$ and in turn the area = $2(y^2/n) \cdot 2(1 - x^2/m)$. Graph this function and find the maximi. These are your coordinate values. Use +/- in front of these values to form a set of coordinates.

-