Maximum area of a square in a triangle

There is a famous book of Polya ("How to solve it"), in which the problem of inscribing a square in a triangle is treated in a really interesting way, I strongly suggest the reading.

The inscribed square is clearly unique once we choose the triangle side where two vertices of the square lie. If we suppose that the square has two vertices on $AB$ and side $l$, then:

$$l+l\cot A + l\cot B = c,$$

so:

$$ l = \frac{c}{1+\cot A+\cot B} = \frac{2R \sin A \sin B \sin C}{\sin C + \sin A\sin B}=\frac{abc}{2Rc+ab},$$

where $R$ is the circumradius of $ABC$. In order to maximize $l$, you only need to minimize $2Rc+ab = 2R\left(c+\frac{2\Delta}{c}\right)$, or "land" the square on the side whose length is as close as possible to $\sqrt{2\Delta}$, where $\Delta$ is the area of $ABC$.


Say $x$ be the side of the largest square within a triangle with sides $a,b,c$. Say one side of the square is on the side $BC$. So we get a square and 3 triangles. Equating the area of the bigger triangle with the sum of area of the 3 small triangle and the square we get:

$$\frac12 ch = x^2\text{[area of the square]}+ \frac12 x(c - x) \text{[area of two small base triangle]} + \frac12 x( h - x)\text{[area of the upper triangle]}$$

Upon solving:

$$x= \frac{ch}{(c+h)}$$