Question :
If $\sqrt x + \sqrt y = \sqrt {135}$ for $x,y \in Z_{\ge 0}$
Find $max ~(xy)$
My first approach :
suppose $a = \sqrt{x}$ , $b = \sqrt{y}$
$ ab = \left(xy\right)^\frac{1}{2}, ~ a+b = \left(135\right)^\frac{1}{2}$
usage of AM-GM , equality hold if (and only if ) $a=b$:
$$ 0 \le \sqrt{ab} \le \frac{a+b}{2}$$
$$ 0 \le \left(xy\right)^{\frac{1}{2} \cdot \frac{1}{2}= \frac{1}{4}} \le \frac{135^{\frac{1}{2}}}{2}$$
$$ max~(xy) = \frac{135^2}{2^4}$$
My second approach:
$$\sqrt{y} = \sqrt{135}-\sqrt{x}$$
Square both sides : $$ y = 135 -2\sqrt{135x}+x $$
Maximizing the function :
$$f(x) = (x)(135-2\sqrt{135x}+x)$$
$$f’(x) = \frac{d}{dx}(x)[135-2\sqrt{135x}+x] + [x] \frac{d}{dx}(135-2\sqrt{135x}+x) $$
$$ f’(x) = 135+2x-3\sqrt{135x}$$
Solving for critical points :
$$ 2x-3\sqrt{135x}+135 = 0$$
$$ x = \frac{135}{4} , x= {135}$$
$$ f \left(\frac{135}{4}\right) = \frac{135^2}{4^2} = \frac{135^2}{2^4} , ~~ f\left(135\right) = 0 $$
Hence,
$$ max~(xy) = \frac{135^2}{2^4}$$
Though both approaches gave the same answer, I still want to validate my approaches. Please guys if you could validate the solution
$$y = 135 -2\sqrt{135x}+x$$ So $x=15k^2$ ( where $k$ is a non negative integer) because $135x$ is a perfect square
$$\sqrt{y} = \sqrt{135}-\sqrt{x}=(3-k)\sqrt{15}$$ $$\implies y=15(3-k)^2$$ (Note: $k\le3$ otherwise $\sqrt{y}$ will be negative)
So the general solution is $(x,y)=(15k^2,15(3-k)^2)$
$$\implies xy=225(3k-k^2)^2$$ $0\le k\le3$, so $(3k-k^2)^2$ is maximum when $k=1$ or $2$.
Therefore $\max(xy)=225\cdot4=900$