So I was writing a computer program, which is supposed to check whether $x$, an approximation of $\sqrt{a}$, is close enough to $\sqrt{x}$. Since these definitions aren't very precise, I defined "close enough" as $$\left|a - x^2\right| \le \dfrac{1}{10^{100}}$$ However my code involves division. Since doubles/floats do not give the desired precision, I had to use the BigDecimal class which requires the programmer to specify the decimal place to which it should round the answer. Originally, I put 100. This worked for my original case of $a = 2$. However, I realized that simply running the code once would not work. Running the code more than once wouldn't work either, because Java would optimize producing inaccurate results. I decided to run the code for all $1 \le a \le 100$. $100$ didn't work for 5, however, so I put 101. This worked for more values of $a$, but then stopped working. I had no idea how to choose the right value of $n$ at which to round to, which is why I am posing the question here.
Find the least positive integer $n$ such that the statement
"For all real numbers $x$, if $\left|\sqrt{a}-x\right| \le \dfrac{1}{10^n}$, then $\left|a - x^2\right| \le \dfrac{1}{10^{100}}$"
holds true for all integers $1 \le a \le 100$
Actually, including the little correction: $$\begin{align*} |\sqrt x - a| & \leq 10^{-n} \\ \Leftrightarrow |\sqrt x - a||\sqrt x + a| & \leq 10^{-n} |\sqrt x + a| \\ \Leftrightarrow |x - a^2| & \leq 10^{-n} |\sqrt x + a| \end{align*}$$ This gives us $$10^{-n} |\sqrt x + a| \leq 10^{-100}$$ Which depends on the number whose square root you want to approximate. If you take $a = \sqrt x$ (the "ideal"), you'd need $$n \approx 100 -\log_{10} (\frac1{2\sqrt x}) = 100 + \log_{10}(2) + \frac12 \log_{10} x$$