Ratio of areas determined by a square inscribed in the corner of a right triangle I’m having trouble working out how to algebraically get to the answer of this question. (See original image below.)

A square is drawn in the corner of a right-angled triangle with side lengths $a$, $b$, and [hypotenuse] $c$, as shown.
Which expression gives the ratio of the unshaded area [inside the triangle, but outside the square] to the shaded area [of the square] in all cases?

*

*(A) $1:1$

*(B) $c:(a+b)$

*(C) $a b: c^2$

*(D) $( a + b )^2 : 2 c^2$

*(E) $c^2 : 2 a b$
Apparently the answer is $c^2 : 2 a b$ (choice E), but how?

Your help is greatly appreciated! Thank you in advance.


(Please ignore the pen marks! They are incorrect assumptions a friend made on the diagram.)

Let the side of the square is $x$. Then, using similarity of triangles, $\frac{b-x}{x}=\frac{x}{a-x}$ or $(b-x)(a-x)=x^2$; $ab-ax-bx+x^2=x^2$; $ab=x(a+b)$ or $x=\frac{ab}{a+b}$. Thus, the shaded area is $\frac{(ab)^2}{(a+b)^2}$. The unshaded area is $$0.5x(b-x)+0.5x(a-x)=0.5\left(\frac{ab}{a+b}(b-\frac{ab}{a+b})+\frac{ab}{a+b}(a-\frac{ab}{a+b}\right)=\frac{ab(b^2+a^2)}{2(a+b)^2}=\frac{abc^2}{2(a+b)^2}$$ so the final ratio is $$\frac{2ab}{c^2}$$
