maximum area of a rectangle inscribed in a semi - circle with radius r. 
A rectangle is inscribed in a semi circle with radius $r$ with one of its sides at the diameter of the semi circle. Find the dimensions of the rectangle so that its area is a maximum. 

My Try: 
Let length of the side be $x$,
Then the length of the other side is $2\sqrt{r^2 -x^2}$, as shown in the image.

Then the area function is 
$$A(x) = 2x\sqrt{r^2-x^2}$$
$$\begin{align}A'(x) &= 2\sqrt{r^2-x^2}-\frac{4x}{\sqrt{r^2-x^2}}\\
&=\frac{2}{\sqrt{r^2-x^2}} (r^2 - 2x -x^2)\end{align}$$
setting $A'(x) = 0$,
$$\implies x^2 +2x -r^2 = 0$$
Solving, I obtained:
$$x = -1 \pm \sqrt{1+r^2}$$
That however is not the correct answer, I cannot see where I've gone wrong? Can someone point out any errors and guide me the correct direction. I have a feeling that I have erred in the differentiation. 
Also how do I show that area obtained is a maximum, because the double derivative test here is long and tedious. 
Thanks!


Eqn of circle: x^2 + y^2 = r^2
|
area of rectangle = a = 2xy
==> a^2 = 4 x^2 y^2
==> a^2 = 4 x^2 (r^2 - x^2)
==> a^2 = 4 (x^2 r^2 - x^4)
|
differentiating:
==> 2a da/dt = 4 (2x r^2 - 4x^3)
since, da/dt=0
==> 2 x r^2 = 4 x^3
==> x = r/sqrt(2)
|
second derivative test:
==>4 (2 r^2 - 12 x^2)
==>8 r^2 - 24 r^2
==>(-16) r^2
==> -ve
therefore, maximum area for  x= r/sqrt(2)
|
finding y:
==>y^2 = r^2 - x^2
==>y^2 = r^2 - (r^2)/2
==>y=r/sqrt(2)
