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.)
 A: 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}$$
A: Let $x$ be the side length of the square.

By similarity,


*

*The hypotenuse of the lower small right triangle is $\bigl({\large{\frac{c}{b}}}\bigr)x$.$\\[4pt]$

*The hypotenuse of the upper small right triangle is $\bigl({\large{\frac{c}{a}}}\bigr)x$.


Hence we get
$$\left(\frac{c}{b}\right)x+\left(\frac{c}{a}\right)x=c$$
which yields
$$x=\frac{ab}{a+b}$$
If $S,U$ are the respective areas of the shaded and unshaded regions, then


*

*$S=x^2$$\\[4pt]$

*$U=\bigl({\large{\frac{1}{2}}}\bigr)ab-x^2$


hence, the required ratio can be expressed as
\begin{align*}
\frac{U}{S}
&=\frac{\left(\frac{1}{2}\right)ab-x^2}{x^2}\\[4pt]
&=\frac{\left(\frac{1}{2}\right)ab}{x^2}-1\\[4pt]
&=\left(
\left({\small{\frac{1}{2}}}\right)ab
\right)
\left({\small{\frac{1}{x}}}\right)^2
-1
\\[4pt]
&=\left(
\left({\small{\frac{1}{2}}}\right)ab
\right)
\left({\small{\frac{a+b}{ab}}}\right)^2
-1
\\[4pt]
&=\frac{(a+b)^2}{2ab}-1\\[4pt]
&=\frac{(a+b)^2-2ab}{2ab}\\[4pt]
&=\frac{a^2+b^2}{2ab}\\[4pt]
&=\frac{c^2}{2ab}\\[4pt]
\end{align*}
