# Correct decimal places in the Bakhshali approximation

The Bakhshali manuscript gives a formula for calculating square roots: $$\sqrt Q=\sqrt{A^2+b}\approx A+\frac b{2A}-(\frac b{2A})^2\cdot\frac1{2\left(A +\frac b{2A}\right)}$$

For example:

√487
Bakhshali formula gives 22.068076490965
Here 9 decimal places are correct
√889
Bakhshali formula gives 29.816105242176
Here 5 decimal places are correct


I doubt if there is any relation between $Q$ and the number of correct decimal places given by the approximation.

• Please check if my edit is correct. – Parcly Taxel Oct 8 '16 at 6:04
• @ParclyTaxel yes is correct, thanks! – exsnake Oct 8 '16 at 6:12
• The explanation is that $487=22^2+3$ i.e., close to an exact square, whereas $889=29^2+46$ is very far from an exact square. Thus the "b" term has much importance. Of course, $889=30^2-11$ but I imagine Mr. Bakshali was using mainly positive numbers... – Jean Marie Oct 8 '16 at 7:09
• It seems interesting to plot $\log_{10}(\text{error})$ between the roots of two perfect squares. They all show the same trend (increasing function). Notice that in the first case, you start just below (higher accuracy); in the second case, you start from rather far away (much lower accuracy). – Claude Leibovici Oct 8 '16 at 7:34
• As said in previous comments, try with $30^2+3=903$, the error is $2.9\times 10^{-11}$ while for $487$ the error is $2.5\times 10^{-10}$. – Claude Leibovici Oct 8 '16 at 7:40

As JeanMarie commented, we can suppose that only positive numbers were considered for the $b$ term.

In any manner, the formula you give can write $$\sqrt Q\approx\frac{Q}{4 \left\lfloor \sqrt{Q}\right\rfloor }+\left\lfloor \sqrt{Q}\right\rfloor \left(\frac{Q}{\left\lfloor \sqrt{Q}\right\rfloor ^2+Q}+\frac{1}{4}\right)\tag1$$ Using negative $b$, we could also write $$\sqrt Q\approx\frac{Q}{4 \left\lceil \sqrt{Q}\right\rceil }+\left\lceil \sqrt{Q}\right\rceil \left(\frac{Q}{\left\lceil \sqrt{Q}\right\rceil ^2+Q}+\frac{1}{4}\right)\tag2$$ Now, let us consider the error for your two numbers, namely $487$ and $889$.

Using $(1)$, the errors are respectively $$\frac{1885673}{85448}-\sqrt{487}\approx 2.51 \times 10^{-10}$$ $$\frac{747937}{25085}-\sqrt{889}\approx 2.21 \times 10^{-6}$$

Using $(2)$, the errors are respectively $$\frac{515687}{23368}-\sqrt{487}\approx 8.07 \times 10^{-6}$$ $$\frac{6400921}{214680}-\sqrt{889}\approx 5.33 \times 10^{-9}$$ So, you need to check which of the formulae has to be used (starting from above or below). Consider the two terms $$\Delta_1=\left|Q-\left\lfloor \sqrt{Q}\right\rfloor ^2\right| \qquad \Delta_2=\left|Q-\left\lceil \sqrt{Q}\right\rceil ^2\right|$$ If $\Delta_1<\Delta_2$ select $(1)$; otherwise select $(2)$.

As compromise, we take the mean of $(1)$ and $(2)$ and use as an approximation for $\sqrt Q$ $$\frac{1}{8}\left(\frac{Q}{\left\lceil \sqrt{Q}\right\rceil }+\frac{Q}{\left\lfloor \sqrt{Q}\right\rfloor }+\left\lceil \sqrt{Q}\right\rceil \left(\frac{4 Q}{\left\lceil \sqrt{Q}\right\rceil ^2+Q}+1\right)+\left\lfloor \sqrt{Q}\right\rfloor \left(\frac{4 Q}{\left\lfloor \sqrt{Q}\right\rfloor ^2+Q}+1\right)\right)\tag 3$$ which will give, as an error for your two numbers $$\frac{688506480}{31199201}-\sqrt{487}\approx 4.04 \times 10^{-6}$$ $$\frac{64226843689}{2154099120}-\sqrt{889}\approx 1.11 \times 10^{-6}$$

Concerning the error, it is quite interesting to plot its logarithm over the range $\left(\left\lfloor \sqrt{Q}\right\rfloor,\left\lceil \sqrt{Q}\right\rceil\right)$. It is a monotonic function. Just play with it. Using the formula you gave, for the error $$\Delta=A+\frac{b}{2 A}-\frac{b^2}{8 A^2 \left(A+\frac{b}{2 A}\right)}-\sqrt{A^2+b}$$ and expanding as a Taylor series around $b=0$, we should get $$\Delta=\frac{b^4}{128 A^7}-\frac{3 b^5}{256 A^9}+O\left(b^6\right)$$ which grows quite fast when $b$ increases. Back to the floor function, we have $$\Delta\approx \frac{\left(Q-\left\lfloor \sqrt{Q}\right\rfloor ^2\right)^4}{128 \left\lfloor \sqrt{Q}\right\rfloor ^7}$$ and considering $-\log_{10}(\Delta)$ this will give the number of significant figures (for your numbers, $9.6$ and $5.6$).

For illustration purposes, I give below the number corresponding to the number related to errors for small values of $Q$. $$\left( \begin{array}{cccc} Q & -\log_{10}(\Delta_1) &-\log_{10}(\Delta_2)&-\log_{10}(\Delta_3)\\ 25 & \infty & \infty & \infty \\ 26 & 7.03 & 3.35 & 3.65 \\ 27 & 5.85 & 3.56 & 3.86 \\ 28 & 5.17 & 3.79 & 4.07 \\ 29 & 4.69 & 4.04 & 4.25 \\ 30 & 4.33 & 4.33 & 4.33 \\ 31 & 4.03 & 4.66 & 4.24 \\ 32 & 3.79 & 5.07 & 4.07 \\ 33 & 3.58 & 5.59 & 3.87 \\ 34 & 3.39 & 6.31 & 3.69 \\ 35 & 3.23 & 7.54 & 3.53 \\ 36 & \infty & \infty & \infty \\ 37 & 7.57 & 3.53 & 3.83 \\ 38 & 6.39 & 3.70 & 4.00 \\ 39 & 5.70 & 3.88 & 4.17 \\ 40 & 5.22 & 4.08 & 4.35 \\ 41 & 4.84 & 4.30 & 4.49 \\ 42 & 4.54 & 4.54 & 4.54 \\ 43 & 4.29 & 4.83 & 4.48 \\ 44 & 4.08 & 5.16 & 4.34 \\ 45 & 3.89 & 5.56 & 4.18 \\ 46 & 3.72 & 6.07 & 4.02 \\ 47 & 3.57 & 6.79 & 3.87 \\ 48 & 3.43 & 8.01 & 3.73 \\ 49 & \infty & \infty & \infty \end{array} \right)$$