A Square Inside A Triangle (but with a twist) I have a right $\triangle ABC$ and I want to find the side length of one of the legs, $x$, when the square is at its max area, as shown in 
I am given that $AB + BC$ is $10$.
Here's what I tried so far:


*

*I found ratios between the sides using similarity, but I wasn't able to get a conclusive answer, just things in terms of each other.

*I tried to set up equations using the Pythagorean theorem, but that just ended up with some messy variable terms and zero actual progress.
The answer is $x=5$, but I want to know how I would go about approaching this kind of problem. It's like others I've seen before here and in other places, but not being given the side lengths threw me off.
 A: The area of the square would be maximal, when $l$ would be maximal.
Let $AB=a$ and $AC=b$.
Thus, $$\frac{a-l}{a}=\frac{l}{b},$$
which by AM-GM gives:
$$l=\frac{ab}{a+b}\leq\frac{\left(\frac{a+b}{2}\right)^2}{a+b}=\frac{5}{2}.$$
The equality occurs for $a=b=5$.
Thus, the area of the square gets a maximal value for $x=5$.
Done!
A: You can show this strictly geometrically. 
By symmetry of the situation you can assume that $BD\ge DC$. Then form the triangle $EGH$ by mirroring $DCE$ by $E$. Now we see that the triangle $EGH$ can be extended to a square $FEGI$ congruent to $BDEF$ and therefore $BCE$ and $AFE$ is together of at least the same  area that $BDEF$. That is $BDEF$ is at most half of ther area of the triangle $ABC$. You also have that the maximal area of the triangle is when $x=5$ and that also happens to coincide with $BDEF$ having half of the ario of the triangle.

A: we have $$\frac{c-l}{l}=\frac{AB}{BC}$$ and with $$BC=10-c$$ we get
$$\frac{c-l}{l}=\frac{c}{10-c}$$
can you finish? $c=AB$
and you will get $$-c^2+10c-10l=0$$
from here we get
$$l=\frac{-c^2+10c}{10}$$
$$l'(c)=\frac{-2c+10}{10}$$ thus $$l'(c)=0$$ if $$c=5$$
