How well $\lfloor\sqrt{x}\rfloor + (x-\lfloor \sqrt{x}\rfloor^2)(2\lfloor \sqrt{x}\rfloor)^{-1}$ approximate $\sqrt{x}$?

82 Views Asked by At

How well $\lfloor\sqrt{x}\rfloor + \dfrac{x-\lfloor \sqrt{x}\rfloor^2}{2\lfloor \sqrt{x}\rfloor}$ approximate $\sqrt{x}$ ?

After some searching, I found this interesting formula. It can be shown easily that for $x$ a square number this formula will always work.

I don't know how well it is actually approximating the square root. With a graph, this formula seems to fit quite well with the square root. Especially for very large values or very close to square numbers.

And also, when this formula create the worst approximation ?

Thanks for the help !

1

There are 1 best solutions below

0
On BEST ANSWER

Note, the formula only makes sense when $x\ge1$ (since $\lfloor\sqrt x\rfloor=0$ for $0\le x\lt1$). Now let $\lfloor\sqrt x\rfloor=\sqrt x-r$ with $0\le r\lt1$. Then

$$\begin{align} \lfloor\sqrt x\rfloor+{x-\lfloor\sqrt x\rfloor^2\over2\lfloor\sqrt x\rfloor} &=(\sqrt x-r)+{x-(\sqrt x-r)^2\over2(\sqrt x-r)}\\ &=(\sqrt x-r)+{2r\sqrt x-r^2\over2(\sqrt x-r)}\\ &=\sqrt x+{r^2\over2(\sqrt x-r)}\\ &=\sqrt x+{r^2\over2\lfloor\sqrt x\rfloor} \end{align}$$

So we see that the error term is always non-negative (i.e., the formula always somewhat overestimates the actual square root), and always less than $1/2$ (which it approaches as $x\to4^-$). It is quadratically small when $r\approx0$ (i.e., when $x$ is slightly larger than a square integer), and close to $1/(2\sqrt x)$ when $x$ is slightly less than a square integer, which itself is small when $x$ is large. As noted, the approximation is worst when $x$ is slightly smaller than $4$.