Prove that for any two positive real numbers $a,b$ we have $(ab)^{\frac{1}{2}} \leq \frac{a+b}{2}$ and moreover that equality occurs if and only if $a = b$.
My attempt at a solution (incomplete):
Suppose $(ab)^{\frac{1}{2}} \leq \frac{a+b}{2}$, then
$4ab \leq (a+b)^2$
$\Rightarrow 4ab \leq a^2 + 2ab + b^2$
$\Rightarrow 0 \leq a^2 - 2ab + b^2 \Rightarrow 0 \leq (a-b)^2$.
How would I come to the conclusion that $a = b$ here? Am I allowed to say that for $(a-b)^2$ to meet the requirement of being equal to zero, $a = b$?
Also, for the only if proof, would I just take the last statement of the if proof and reconstruct the original equation or do I prove it in some other way?