Area of a rectangle inside a triangle with given coordinates 
Given a triangle with vertices at points $(0, -a), (0, a), (b, 0)$, where $a > 0$, find the maximal area and the dimensions (base and height) of a rectangle that can be contained within the triangle.


I tried to find a function, differentiate it, and find the maximum. I think I kind of did it right, but since I'm not sure I want to ask for some advice.
I set up $x$ as the length of the base and $y$ as the height, but since $y$ is being divided by the $x$ axis in two parts, the function of the area is:
$$\mbox{Area}=x2y$$
and to find y with the triangle, I saw that we can do a little similar triangle to the bigger triangle on the positive side so
$$ \frac ab = y/{b-x}$$
then
$$y=a-{ax}/{b}$$
plugin that into de area equation gives
$$\mbox{Area}=2x(a-{ax}/b)$$
so the derivative is
$$A'=2a-4{ax/b}$$
solving for A'=0 gives $x=b/2$ so finding the dimensions and the area won't be hard once you get the proper x, but I'm kinda doubtful because I didn't set any constraint for the base "x"

Let $A(0,b),$ $B(b,0),$ $C(0,-a)$ and $KLMN$ be our rectangle, $KL=x$, where $K\in BC$ and $N\in AB$.
Thus, since $\Delta ABC\sim\Delta NBK$, we obtain:
$$\frac{NK}{2a}=\frac{b-x}{b}$$ or
$$NK=\frac{2a(b-x)}{b}.$$
Id est, by AM-GM
$$S_{KLMN}=\frac{2a(b-x)x}{b}\leq\frac{2a\left(\frac{b-x+x}{2}\right)^2}{b}=\frac{ab}{2}.$$
The equality occurs for $b-x=x,$ which says that we got a maximal value.
Now, we see that in the optimal case $KL=\frac{b}{2}$ and $NK=a.$
