<s>[INST] Solution for approximating square roots? I just saw a post on instagram which said that
$$\sqrt{x}\approx \frac{x+y}{2\sqrt{y}}$$
I tried it out on a few values, and surprisingly, it came within 1 decimal point of the actual answer. Is there a reason for this or is it coincidental?
y is the closest perfect square to x
 [/INST] Google AM–GM inequality.
If we square any real number $z$, which can be expressed as a difference of two other real numbers $x$ and $y$, the result is always greater or equal $0$, this means $\color{blue}{z^2 \geq 0}$, assume $z = x-y$, it follows $$\color{blue}{z^2} = (x-y)^2 = x^2 \color{red}{-2xy} + y^2 = x^2 \color{red}{+ 2xy} + y^2 \color{red}{- 4xy} =(x+y)^2-4xy\color{blue}{\geq 0} $$
$$\Rightarrow (x+y)^2-4xy\geq 0 \Leftrightarrow(x+y)^2\geq 4xy \Rightarrow x+y \geq \sqrt{4xy} \Leftrightarrow \frac{x+y}{2\sqrt{y}} \geq \sqrt{x}$$
The result is:
$$\sqrt{x} \leq \frac{x+y}{2\sqrt{y}}  $$
If $x = y$, then
$$\sqrt{x} =\frac{x+y}{2\sqrt{y}}  $$
Example: $$\sqrt{4} =\frac{4+4}{2\sqrt{4}} = 2$$
</s>