Preprint
Article

This version is not peer-reviewed.

Transformed Bakshali Square-Root Algorithm with Higher Orders of Convergence

Submitted:

12 August 2026

Posted:

13 August 2026

You are already at the latest version

Abstract
Bakshali square root formula is an amazing achievement of ancient Indian Mathematics. Exploring the logic behind the Bakshali formula, an extended Bakshali algorithm in two variables for square root extraction is presented. The algorithm leads to Bakshali-type formulas of high orders of convergence that goes as 2n, where n=1,2,3, …. . Further, a transformed Bakshali algorithm is presented which ensures fast convergence with just one division operation per iteration. Just in a few iterations square roots can be computed with millions of digits of accuracy. Algorithms with 8-fold and 16-fold convergences are demonstrated.
Keywords: 
;  ;  ;  

1. Introduction

The time tested method of computing the square root of a number is Newton’s method which is based on the Newton-Raphson iterative scheme,
x n + 1 = x n   -   f ( x n ) f   ( x n ) ----------
While finding the square root of a number N, this becomes,
x n + 1 = 1 2 x n + N x n ----------
Iteration of this formula will give better and better approximations to N ​. The historically important Babylonian and Heron’s methods are identical to Newton’s method as given in eq. (2).[1,2,3,4]
Newton’s method is quadratically converging; after each iteration the number of correct digits doubles. The method is computationally very simple; it has just one addition, one division and one multiplication by half in each iteration. With a suitable choice for initial guess, Newton’s method converges fairly fast to the square root, with minimum utilization of computer resources.[2]
The ancient Bakshali manuscript found in 1881 in the village of Bakshali, approximately 80 km northwest of Peshawar gives an interesting formula for finding the square root of a number. The Bakshali formula is,
N = a + r 2 a r 2 a 2 2 a + r 2 a ----------
In eq.(3), a is such that its square a2 is close to N. Then r is the remainder such that N=a2+r.The effectiveness of this formula is demonstrated in the Bakshali manuscript itself by finding the square root of a number with 12 significant digit accuracy. It is truly amazing that calculations with such precision were carried out in ancient times (c.400 CE).[5,6,7,8,9,10]
Bailey and Borwein showed that the Bakshali formula given in eq. (3) can be cast as an iterative formula.[7]
P n =   N x n 2 2 x n
                        x n + 1   =   x n + P n P n 2 2 ( x n + P n )
They have shown that this is a quartically convergent scheme. Each iteration approximately quadruples the number of correct digits. They have also shown that this follows naturally from the fact that the scheme is equivalent to performing two consecutive iterations of the Newton–Raphson equation, which is quadratically convergent.
Let us look at the process through which the Bakshali formula was most probably arrived at. It is proposed to find the square root of a positive real number N greater than 1. The first step is to guess a square number a2 close to N, such that N=a2+r, where r is the remaining part of N once a2is removed from it. The first approximation to the square root of N is,
x 1 = a + r 2 a ------------
This approximation was probably known right from the early part of the 2nd millennium BCE. The Babylonian tablet YBC 7289 shows the value of 2 ​ with some remarkable accuracy for that time.[3]
Eq.(4) is equivalent to the Newton’s method formula given in eq.(2).
x 1 = a + N a 2 2 a                           ( r = N a 2 )
= a + N 2 a a 2
= 1 2 ( a + N a )
If we take x1 as given in eq.(4), as the approximate value of square root of N, the error can be calculated as,
e 1 = x 1 2 N
= a + r 2 a 2 N
=   a 2 + r + r 2 a 2 N
= r 2 a 2
Let us define a new variable y1 which will be applied as a correction to x1 to reduce the error.
y 1 = e 1 2 x 1 = r 2 a 2 2 ( a + r 2 a )
The new, corrected, approximation to the square root is,
x 2 = x 1 y 1
i e               x 2 =   a + r 2 a r 2 a 2 2 ( a + r 2 a ) ------------
When x2 is considered as the square root of N, the error e2 can be calculated as,
e 2   =   x 2 2 N
= a + r 2 a r 2 a 2 2 ( a + r 2 a ) 2 N
= a + r 2 a 2 r 2 a 2 + r 2 a 2 2 ( a + r 2 a ) 2 N
= a 2 + r + r 2 a 2 r 2 a 2 + r 2 a 2 2 ( a + r 2 a ) 2 N
= r 2 a 2 2 ( a + r 2 a ) 2 = e 1 2 ( a + r 2 a ) 2
                                e 2       e 1 2 N 2             ( a + r 2 a is our first approximation to N   )
As N is a positive real number greater than 1, e2 is always less than e1. The error decreases, and it justifies the correction term y1.
Equation (5) is exactly the Bakshali formula given in eq.(3). The process of error reduction we followed here can be extended to obtain a recursive algorithm to find better and better approximations to the square root of any positive real number. Since the process is in the spirit of the Bakshali formula, we call it the Bakshali algorithm.

2. Bakshali Algorithm

To find the square root of N, we first write N=a2+r, where a2 is a square number close to N. It is best to choose a2 as the greatest square number less than N. At each step, we find the approximation to N   and compute the error. Based on this error, a correction is applied in the next step, to obtain a better approximation to N     .   The algorithm n proceeds as follows:
The expression for N   obtained in the nth step is,
x n = a + r 2 a y 1 y 2 y 3 - --------- y n 1
The error in the nth stage can be calculated as,
e n = x n 2 N
= x n 1 y n 1 2
= x n 1 2 2 x n 1 y n 1   + y n 1 2 N
= x n 1 2 N y n 2 2 + y n 1 2
= e n 1 y n 2 2 + y n 1 2
i . e .   e n = y n 1 2 ..................
But y n 1 = y n 2 2 2 x n 1   =   e n 1 2 x n 1
i . e .   e n = e n 1 2 x n 1 2
As the denominator is 2 N  ,
                        e n   e n 1 2 N 2 ...............
We can see that en is always less than en-1. The error is progressively decreasing. This ensures the convergence of the algorithm to the true value of N The first three approximations to N in Table1 actually give the following expressions:
x 1 = a +   r 2 a
  x 2 = a + r 2 a r 2 a 2 2 ( a + r 2 a ) ,
                x 3 = a + r 2 a r 2 a 2 2 ( a + r 2 a ) r 2 a 2 2 a + r 2 a 2 2   a + r 2 a r 2 a 2 2 ( a + r 2 a )
The following points may be noted about the xn​ values given in the algorithm.
  • Each xn​ gives a better approximation to the square root than given by the previous expression, xn−1​.
  • Each expression for xn​ can be used as an iterative formula for getting better and better values of N
3.
Step1 is the same as Newton’s method whose quadratic convergence is well established. Step2 is the Bakshali formula whose quartic(4-fold) convergence is also established previously.
4.
In general the order of convergence gets multiplied by 2 as we go from one step to the next. The order of convergence should be 2n if we use the formula xn​ in the nth step for iteration.
Computationally, using these expressions as iteration formulas don’t give any advantage over the standard Newton’s method. For example, if we use the level 3 formula (x3) for iteration, we get convergence 23=8. Each iteration will multiply the number of correct digits by 8. But within each iteration the number of operations will be the same as 3 repeated applications of Newton’s method.
In order to reduce the computational complexity of operations, we now recast the Bakshali algorithm in a different manner. Especially we want to limit the number of divisions to a minimum, as the computational cost of division is much more than other mathematical operations, addition, subtraction, and multiplication.

3. Transformed Bakshali Algorithm

We can recast the first three square root values of the Bakshali algorithm of Table 1 in the following manner.
x 1 = a + r 2 a = 2 a 2 + r 2 a = z 1 2 a
x 2 =   x 1 y 1
= z 1 2 a r 2 a 2 2 x 1
= z 1 2 a r 2 4 a 2 × 2 z 1 2 a
= z 1   2 a r 2 2 a × 2 z 1
= 2 z 1 2 r 2 2 a × 2 z 1 = z 2 2 a × 2 z 1
x 3 =     x 2 y 2
=   z 2 2 a × 2 z 1 y 1 2 2 x 2
=   z 2 2 a × 2 z 1 r 4 2 a × 2 z 1 2 × 2 z 2 2 a × 2 z 1
=   z 2 2 a × 2 z 1 r 4 2 a × 2 z 1 × 2 z 2
=   2   z 2 2 r 4 2 a × 2 z 1 × 2 z 2 =   z 3 2 a × 2 z 1 × 2 z 2
In this manner we can recast the whole Bakshali algorithm. The transformed Bakshali algorithm thus obtained is given below.
This algorithm can be implemented for various orders of convergence. Iteration of operations in step 1 will give x1,​ with 2-fold (quadratic) convergence. Iterating the operations of steps 1 and 2 together will give x2 values with 4-fold (quartic) convergence (x1​ need not be computed). Iteration of steps 1, 2, and 3 together (without computing x1​ and x2) will give x3 values with 8-fold convergence. Putting n steps together in a loop and iterating, we will get 2n-fold convergence directly for xn.

4. Implementation of Transformed Bakshali Algorithm

Let us write down the 3-step iteration scheme for 8-fold convergence.
To calculate N ​, assumeN=a2+r
Input:   N, a
r(1) = N−a2, a(1) = a
For i=1 to n
y(1) = r(i)
z(1) = 2a(i)2+y(1)
t(1) = 2a
y(2) = y(1)2
z(2) = 2z(1)2−y(2)
t(2) = t(1)×2z(1)
y(3) = y(2)2
z(3) = 2z(2)2−y(3)
t(3) = t(2)×2z(2)
x(i) = z ( 3 ) t ( 3 ) a(i+1) = x(i)
r(i+1) = N−a(i+1)2
Each iteration of this loop ensures 8-fold increase in correct decimal places in the square root of N. There is only one division operation, and the multiplication operations are mostly squaring. This should result in reduced execution times, especially when the number of precision digits becomes large.
The following table gives the results of running the above program implemented in Python language. The results are for a randomly chosen number N=37957. The accuracy of a root obtained is verified by looking at the remainder r=N−a2. The number of correct digits after the decimal point in the root is almost the same as the number of leading zeroes in r, the difference being only one digit or two at the most. The correctness of the result was verified by comparing the digits of the square root obtained, with standard library sqrt(N) values.
In just 7 iterations a square root with more than 3.6 million correct digits are extracted by this level-3 Bakshali algorithm. As the iterations progress, the convergence ratio approaches very fast to the number 8. But the ratio is always a little more than 8 due to the presence of few extra digits.
The standard Newton–Raphson method takes 21 iterations to reach the same level of precision. The precision achieved in a single Bakshali iteration will be achieved by 3 iterations of Newton–Raphson. Each iteration of Newton–Raphson implements a division. As the iterations move ahead, these divisions become multi-million digit operations. The Bakshali algorithm of 8-fold convergence condenses the entire algebraic expansion (equivalent to three Newton–Raphson iterations) into a single unified mathematical structure. It achieves 8-fold jump in accuracy using only one final division operation at the very end.
The Bakshali algorithm eliminates the intermediary division operation via the introduction of squaring operations. Modern high performance math libraries use fast multiplication algorithms. Bakshali algorithm is ideally suited to execute these fast squaring operations to achieve high-speed convergence, especially at multi-million digit accuracy.
The remainder term r=N−a2 plays a crucial role in the Bakshali algorithm. It is calculated at the end of each iteration and becomes the basis for the calculations in the next iteration. The remainder term provides the exact measurement of the algorithm’s real accuracy. Because the remainder is explicitly calculated at the end of each iteration, it acts as a data anchor which pulls the algorithm back to the correct path if unwanted effects try to limit its efficiency. Normally floating- point calculations across a number of steps cause tiny round-off errors which can compound and degrade the performance of an algorithm. The explicit calculation of the remainder r at the end of each iteration eliminates the possibility of compounding and amplification of errors.

5. Error analysis

Let us see how the 3-stage Bakshali algorithm diminishes error.
Let the initial value of the square root be a.
Let e0 be the absolute error in our current value of the root.
N = a + e 0
N = a 2 + 2 a e 0 + e 0 2
The algorithm operates by sequentially transforming this starting error e0 in to higher powers through three structural squaring levels.
Level 1
Remainder r is calculated.
r = N a 2 = 2 a e 0 + e 0 2
y 1   = r = 2 a e 0 + e 0 2
t1 = 2a
z 1 = 2 a 2 + r = 2 a 2 + 2 a e 0 + e 0 2
Level 2
Remainder is squared.
y 2 = y 1 2 = 2 a e 0 + e 0 2 2
= 4 a 2 e 0 2 + 4 a e 0 3 + e 0 4
Next, the first correction envelope z2 is computed.
                            z 2 = 2 z 1 2 y 2
= 2 2 a 2 + 2 a e 0 + e 0 2 2 ( 4 a 2 e 0 2 + 4 a e 0 3 + e 0 4
)
= 2 ( 4 a 2 + 4 a 2 e 0 2 + e 0 4 + 8 a 3 e 0 + 4 a e 0 3 + 4 a 2 e 0 2 ) 4 a 2 e 0 2 + 4 a e 0 3 + e 0 4
= 8 a 4 + 16 a 3 e 0 + 12 a 2 e 0 2 + 4 a e 0 3 + e 0 4
t2 = 2a × 2z1
= 2 a × 2 2 a 2 + 2 a e 0 + e 0 2
= 8 a 3 + 8 a 2 e 0 + 4 a e 0 2
Level 3
y 3 = y 2 2 = 4 a 2 e 0 2 + 4 a e 0 3 + e 0 4 2
= 16 a 4 e 0 4 + 32 a 3 e 0 5 + 24 a 2 e 0 6 + 8 a e 0 7 + e 0 8
z 2 2 = 8 a 4 + 16 a 3 e 0 + 12 a 2 e 0 2 + 4 a e 0 3 + e 0 4 2
= 64 a 8 + 256 a 7 e 0 + 448 a 6 e 0 2 + 448 a 5 e 0 3 + 288 a 4 e 0 4 + 128 a 3 e 0 5 +                                                                                                                                                                                             40 a 2 e 0 6 + 8 a e 0 7 + e 0 8
z 3 = 2 z 2 2 y 3
= 128   a 8 + 512 a 7 e 0 + 896 a 6 e 0 2 + 896 a 5 e 0 3 + 576 a 4 e 0 4 + 256 a 3 e 0   5 +                                         80 a 2 e 0 6 + 16 a e 0 7 + 2 e 0 8 16 a 4 e 0 4 + 32 a 3 e 0 5 + 24 a 2 e 0 6 + 8 a e 0 7 +                                           e 0 8
                        = 128   a 8 + 512 a 7 e 0 + 896 a 6 e 0 2 + 896 a 5 e 0 3 + 560 a 4 e 0 4 + 224 a 3 e 0   5 +                                               56 a 2 e 0 6 + 8 a e 0 7 + e 0 8
t3 = t2× 2z2
= 16 a 3 + 16 a 2 e 0 + 8 a e 0 2 × ( 8 a 4 + 16 a 3 e 0 + 12 a 2 e 0 2 + 4 a e 0 3 + e 0 4 )
= 128 a 7 + 384 a 6 e 0 + 512 a 5 e 0 2 + 384 a 4 e 0 3 + 176 a 3 e 0 4 + 48 a 2 e 0   5 +                                         8 a e 0 6
Square root R = Z 3 t 3
=           128   a 8 + 572 a 7 e 0 + 896 a 6 e 0 2 + 896 a 5 e 0 3 + 560 a 4 e 0 4 + 224 a 3 e 0   5 +   56 a 2 e 0 6 + 8 a e 0 7 + e 0 8   128 a 7 + 384 a 6 e 0 + 512 a 5 e 0 2 + 384 a 4 e 0 3 + 176 a 3 e 0 4 + 48 a 2 e 0   5 +     8 a e 0 6
= a + e 0   +     e 0 8       128 a 7 + 384 a 6 e 0 + 512 a 5 e 0 2 + 384 a 4 e 0 3 + 176 a 3 e 0 4 +   48 a 2 e 0   5 +     8 a e 0 6
        a + e 0   + e 0 8 128 a 7       (Neglecting the lower order terms in the denominator)
= N   + e 0 8 128 a 7
The error in this is e 0 8 128 a 7 There is order of 8 reduction in error. Due to the factor 128a7 in the denominator there are some extra digits of precision.

6. Transformed Bakshali Algorithm with 16-fold convergence

To further demonstrate the validity of the transformed Bakshali scheme, we have also implemented a Level-4 Bakshali algorithm, which ensures 16-fold convergence. Here, the first four levels of the transformed Bakshali algorithm of Table 2 are taken as a unit and iterated. The results are shown in Table 4.
Table 2. Transformed Bakshali Algorithm.
Table 2. Transformed Bakshali Algorithm.
Step y(n) z(n) t(n) x(n)
1 y1= r z1= 2a2+y1 t1= 2a x1= z 1 t 1
2 y2= y 1 2 z2= 2   z 1 2   -y2 t2= t1×2z1 x2= z 2 t 2
3 y3 = y 2 2 z3= 2   z 2   2 -y3 t3= t2×2z2 x3= z 3 t 3
4 y4 = y 3 2 z4=   2   z 3   2 -y4 t4= t3×2z3 x4= z 4 t 4
. ---------- ------------- ------------- -------
. ---------- ------------- ------------- -------
n yn= y n 1 2 zn= 2   z n 1 2 -yn tn= tn-1×2zn-1 xn= z n t n
Table 3. Square root extraction of 37957 by Level-3 (8-fold convergence) Bakshali algorithm.
Table 3. Square root extraction of 37957 by Level-3 (8-fold convergence) Bakshali algorithm.
Iteration No. Estimated numberof precision digits in the square root Magnitudeof remainder(only5 significant digits are shown with normal rounding off) Convergence ratio
1 P1=15 r =6.2706×10-17 _____
2 P2=115 r =1.1155×10-116 P 2 P 1 =7.6666
3 P3=881 r =3.2077×10-882 P 3 P 2 =7.6608
4 P4=7088 r =6.0273×10-7089 P 4 P 3 =8.0454
5 P5=56741 r =9.3654×10-56743 P 5 P 4 =8.0052
6 P6=453972 r =3.1825×10-453973 P 6 P 5 =8.0007
7 P7=3631816 r =5.6596×10-3631817 P 7 P 6 =8.00008
Table 4. √37957 calculated using Bakshali Level-4 algorithm with 16-fold convergence.
Table 4. √37957 calculated using Bakshali Level-4 algorithm with 16-fold convergence.
Preprints 228081 i002
The algorithm extracts the square root with more than 2.8 million correctdigits in just five iterations. The convergence ratio approaches 16 very fast.

7. Conclusions

  • Following the logic of Bakshali square root formula, a general Bakshali algorithm for square root extraction is presented in Table 1.
  • From this general Bakshali algorithm, a transformed Bakshali algorithm is developed in Table 2.
  • Different levels of the transformed Bakshali algorithm can be used as iterative schemes for finding the square root of a positive real number.
  • The effectiveness of the transformed Bakshali algorithm is demonstrated for Level-3 and Level-4, which shows 8-fold and 16-fold convergences respectively. Millions of digits of precision are achieved in just a small number of iterations.
  • It is expected that the error-correcting, self-regulating and fast converging transformed Bakshali algorithm will become the basis for an efficient square-root engine which can produce square roots with arbitrarily large digits of precision with more efficient use of computational resources.
Equations
x n + 1 = x n   -   f ( x n ) f   ( x n ) ----------------------(1)
x n + 1 = 1 2 x n + N x n ----------------------(2)
N = a + r 2 a r 2 a 2 2 a + r 2 a --------------------(3)
x 1 = a + r 2 a --------------------(4)
x 2 = a + r 2 a r 2 a 2 2 ( a + r 2 a ) --------------------(5)
  • en = y n 1 2
-------------------- (6)
e n e n 1 2 N 2 ----------------------(7)

Acknowledgments

The author thanks the government of Kerala, India for financial support for the project “ A comparative study of development of calculus by the Kerala School and British/European school”. The author thanks Dr.K.Arjun of Srinivasa Ramanujan Institute for Basic Sciences (SRIBS), Kottayam, Kerala for help in implementing the computations.

References

  1. Gadner, Martin J; Henry, Philippe; Wanner, Gerhand. Landmarks in the history of iterative methods, SIAM. 2022. [CrossRef]
  2. Dellajustine, Fernanda Jaíara; Martins, Luciano Camargo. The hidden geometry of the Babylonian square root method. Appl. Math. 2014, 5, 2982–2987. [Google Scholar] [CrossRef]
  3. Fowler, David; Robson, Eleanor. Square root approximations in Old Babylonian Mathematics: YBC 7289 in context. Hist. Math. 1998, 25, 366–378. [Google Scholar] [CrossRef]
  4. Buckle, David. How the estimate of √2 on YBC 7289 may have been calculated. Hist. Math. 2023, 62, 3–18. [Google Scholar] [CrossRef]
  5. Shirali, Shailesh A. The Bakhshali square root formula. Resonance 2012, 884–892. [Google Scholar] [CrossRef]
  6. A. A. Krishnaswami Ayyangar, The Bakhshali manuscript. Math. Stud. 1939, Vol.VII, No.1, 1–15.
  7. Bailey, David H.; Borwein, Jonathan M. Ancient Indian square roots: An exercise in forensic paleomathematics. Available online: https://www.davidhbailey.com/dhbpapers/india-sqrt.pdf (accessed on 2/8/2026).
  8. Khatri, Vikash; Tiwari, Pankaj. Square root of 2-Extension of ancient Indian vedic method. [CrossRef]
  9. Channabasappa, M.N. Square root formula in Bakshali Manuscript. Indian J. Hist. Sci. 1976, Volume 11(Issue 2), 117–124. [Google Scholar]
  10. Casselman, Bill. Reading the Bakshali Manuscript; American Mathematical Society; Available online: https://www.ams.org/publicoutreach/feature-column/fc-2018-06.
Table 1. Bakshali Algorithm.
Table 1. Bakshali Algorithm.
Preprints 228081 i001
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.