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"

Completing the square:
Maximize  $A:= 2x(-(a/b)x+a)$, where $0 \le x \le b$.
$A= 2x((-a/b)x+a)=$
$ -2(a/b)x^2 +2xa= $
$-2(a/b)(x^2-bx)=$
$ -2(a/b)[(x-b/2)^2-(b/2)^2]=$
$-2(a/b)(x-b/2)^2 + 2(a/b)(b/2)^2.$
Maximal area occurs for 
$x=b/2$ (why?) : $A_{max}= (ab)/2.$
