Area of inscribed rectangle as a function of right triangle base I am stuck with trying to find the area of the rectangle $A$ as a function of $x$:

(Drawing replicated from my textbook, not sure if more labels would be helpful?)
Obviously $A$ is given by the product of two adjacent rectangle sides, one of which is equal to the hypotenuse of the bottom-left inner triangle. The hypotenuse in turn is given by the Pythagorean relation $\sqrt{x^2+y^2}$, if we let $y$ be equal to $b$ minus the hypotenuse of the upper-left inner triangle.
I have tried doing some algebra from there, but I am unable to eliminate all the variables I believe I am supposed to. Am I correct that the final expression may take the outer triangle as given, but otherwise should only depend on $x$?
Any hints as to which (geometric?) relations I may be missing out on? Or similar problems posted here earlier that I should take a more thorough look at?
(I have seen similar problems discussed on this site, but not with the rectangle in this position. Also, similar problems I have seen tend to include some numbers and not just general quantities, which in my experience is a bit easier to wrap my mind around. The next step of the task is to optimize the area of the inscribed rectangle, but that should be simple enough once I have the formula worked out.)
 A: Let $c$ and $d$ be the lengths of the two sides of the rectangle, as indicated on the figure. The area of the rectangle is $cd$.

With the notations introduced in the figure above, the triangles $GDC$ and $ABC$ are similar because they are right triangles sharing one of the non-right angles. Thus $\frac{GD}{AB} = \frac{GC}{AC}$, ie $$\frac{c}{b} = \frac{a-x}{\sqrt{a^2+b^2}}.$$ 
In the same way, using the similarity of triangles $FBG$ and $ABC$, we obtain $$\frac{d}{\sqrt{a^2+b^2}} = \frac{x}{a}.$$
From these two equalities you can compute $c$ and $d$ as functions of $x, a$ and $b$.
Thus the rectangle area is $\mathcal{A} = cd = \frac{b}{a}x(a-x)$. 
A: Note that you know all angles. Let $\alpha$ be the lower-right angle and $\beta$ the upper left angle (you don't need it, but anyway). Now, the triangles are similar so, they share the same angles.
Denote by $z$ the long side of the rectangle $A$ and $l$ the short side, so that $Area(A)=z\cdot l$. Now, it is easy to check that 
$z=\frac{x}{\cos\alpha}=\frac{cx}{a}$, and
$l=(a-x)\sin\alpha=(a-x)\frac{b}{c}$.
So $A=z\cdot l=\dfrac{x(a-x)b}{a}$
Edit: For the biggest area, take a look of $A'_x(x)=0$ so you'd have that area is max. when $x=a/2$.
