An Analysis On Extracting Square and Cube Roots by Aryabhata's Methods
An Analysis On Extracting Square and Cube Roots by Aryabhata's Methods
An Analysis On Extracting Square and Cube Roots by Aryabhata's Methods
Yumnam Kirani Singh, C-DAC, IIPC Building, NIT Campus, Silchar, Assam.
Email:yumnam.singh[@]cdac.in
Abstract— Finding accurate root of a number is still considered as challenging in computer science community. The only
popularly known method to compute root is the long division method of finding square root. Aryabhata contributed two methods
similar to long division method to compute square root and cube root. In recent years, his methods have also been studied,
explained and tried to implement as computer algorithms. The explained methods and proposed algorithms fail to give correct
results. Some analyses have been made on these methods in order to ascertain why the algorithms fail. Improved algorithms have
been provided to give correct result while computing square root or cube root using Aryabhata’s methods. .
Keywords—cube root, square root, Bino’s Model of multiplication, Large number manipulation, Long division method, Aryabhata’s
methods.
10. 𝑅 = 10 × 𝑅 + 𝐵 R=1
11. 𝑐 = 10 × 𝑆 + 𝑑𝑖−2 Step-7: Combining the first digit of the next segment with the
12. 𝑆 = 𝑐 − 𝐵2 difference in step-5.
13. 𝑖 =𝑖−2 𝑦 = 10 × 𝑆 + 𝑑𝑖−1 = 10 + 5 = 15
14. 𝑝=𝑝−1 Step-8: Finding the remainder when the number in step-7 is
15. If 𝑝 ≠ 0 go to 7, else quit. divided by twice the partial root obtained so far.
𝑆 = 𝑦 𝑚𝑜𝑑 2 × 𝑅 = 15 𝑚𝑜𝑑 2 = 1
Step-1 is to segment the given number into segments of two Step-9: Computing next digit of the square root.
digits starting from the right. Step-2 is to determine how many 𝑦 15
𝐵= = =7
digits would be computed after the first square root of the first 2×𝑅 2
segment is computed. Step-3 is to select the leftmost segment, Step-10: Updating the result of square root
which may consist of a single digit or 2-digits.Step-4 is to 𝑅 = 10 × 𝑅 + 𝐵 = 10 × 1 + 7 = 17
compute the first digit of the square root, i.e., the square root Step-11: combining the remainder in step-8 with second digit
of the first leftmost segment. Step -5 is to find the difference of the second segment.
between the leftmost segment and the square of the first digit 𝑐 = 10 × 𝑆 + 𝑑𝑖−2 = 10 × 1 + 6 = 16
of the root. Step-6 is to store the first digit of the root in the Step-12: Finding the difference between the number in step-
result. Step 7 to 14 is to compute the next digits of the square 11 and square of the digit of the square root computed last.
roots from next segments of the numbers under control of 𝑆 = 𝑐 − 𝐵2 = 16 − 49 = −33
Step-15. Step-13: Updating i index to process next two digits of the
Step-7 combines the difference from step-5 and first digit of next segment if any.
the next segment. Step-8 finds the remainder when the number 𝑖 =𝑖−2=0
in step-7 is divided by twice the result obtained so far. Step-9 Step-14: Updating the number of digits of the square root still
computes the next digit of the square root, which is the left for computation
quotient when the number in step-7 is divided by twice the 𝑝=𝑝−1=0
result of the root obtained so far. Step-10 stores the quotient Step-15: Check whether to proceed for computation of next
obtained in 9 as the next digit of the root. Step-11 combines digit of the square root or not. Since p=0, the algorithm exits
remainder obtained in step-8 with the second digit of the next here.
segment being processed. Step-12 finds the difference So, at the end of execution of the algorithm, 17 is given as the
between the number obtained in step-11 and the square of the square root of 256. Similarly, the algorithm gives square roots
digit of the root computed in step-9. Step-13, index for of numbers 225, 289, 324, 361 as 16, 19, 111, 113 instead of
choosing the segments of two digits from the number is 15, 17, 18 and 19. The reason why it fails to work is that when
updated by decrementing its value by 2. Similarly, the number the second digit is greater than 4, some carry was added in the
of digits of roots required to be computed is updated by first segment during the multiplication process. This was not
decrementing its value by 1. Step-5 checks whether all the considered when determining the second digit of the root in
required number of digits for the square root are computed. If step-9. In other words, the relation given in step-9 to compute
not, computation next digit of the root is repeated. the next digit of the root does not guarantee that it is will
Let us analyze the reason why the above algorithm fails to always be a digit and the computed digit will be the correct
work when the first digit of the root is 1 and the second digit is digit. So, in order to make the algorithm work for all numbers,
greater than 4. we need to check whether the computed value from the step-9
could be a correct digit for the square root. This can be done
Example: Square root of 256. by checking whether the value in step-12 is negative or not. If
By the above algorithm, the square root is given as 17. Let us the value is negative, the value of the root computed in step-9
analyze, why this happens. should be continuously reduced by 1, until the value in step-12
Step-1: The given number is divided into two segments as 2, becomes greater than or equal to zero. The improved
56. First segment is 2, and second segment is 56 and we have algorithm to compute the square root by Aryabhata’s method
to pick the last digit in the first segment, so i=2. is given below.
Step-2: Number of digits in the square root after first digit.
There is minor correction in the evaluation of number digits to Improved Algorithm: (Square root extraction by Aryabhatta’s
be computed after the square root of the first segment of the method)
given number. Input: A positive integer within byte size limitation
𝑝 = 𝑛/2 = 2/2 =1 Output: A positive integer representing integer part of cube
Step-3: Getting the first segment, a=2 root of the given number.
Step-4: Integer part of square root of first segment, 𝐴 = 𝑛
1. 𝑝 =
2
2 = 1, which is first digit of square root of the number. 2. Pick 𝑑𝑖 such that 𝑖 = 2 ∗ 𝑝
Step-5: Finding difference between the first segment and 3. If 𝑑𝑖+1 exists 𝑎 = 10 × 𝑑𝑖+1 + 𝑑𝑖 else 𝑎 = 𝑑𝑖
square of the first digit of the root. 4. Choose A such that 𝐴2 ≤ 𝑎 and 𝑎 − 𝐴2 is minimum
𝑆 = 𝑎 − 𝐴2 = 2 − 1 = 1 5. 𝑆 = 𝑎 − 𝐴2
Step-6: Putting the first digit of the square root in the result.
𝑙 = 10 × 𝑆 + 𝑑𝑖−1 = 10 × 1 + 7 = 17 16. 𝑅 = 10 × 𝑅 + 𝐵
Step-8:𝑆 = 𝑙 𝑚𝑜𝑑 3 × 𝑅2 = 17 𝑚𝑜𝑑 3 = 2 17. 𝑖 = 𝑖 − 3
Step-9: combining the remainder in 8 with the second digit of 18. 𝑝 = 𝑝 − 1
the segment being processed, i.e., second segment i.e., 744. End while
𝑚 = 10 × 𝑆 + 𝑑𝑖−2 = 10 × 2 + 4 = 24
Step-10: computing next digit of the cube root. In the above algorithm, the way in which digits of a given
𝑙 17 number is grouped into three’s starting from the right has been
𝐵= 2
= =5 simplified. The estimated value of next digit of cube root is
3×𝑅 3
Step-11: tested for correction before adding to the result.
𝑆 = 𝑚 − 3 × 𝑅 × 𝐵2 = 24 − 3 × 1 × 52 = 24 − 75 = −51 Also, note that the improved algorithms given in Section II
Step-12: Updating cube root with next digit computed in step- and III can be used for computation of square root or cube root
10 of a number within the maximum limit an integer variable can
𝑅 = 10 × 𝑅 + 𝐵 = 10 × 1 + 5 = 15 have in a programming language. To make the algorithms
Step-13: Combining the remainder in step-11 with next digit works for any arbitrarily large number, the algorithm must be
of the root. modified in representa arithmetic as in [4,5, 6].
𝑛 = 10 × 𝑆 + 𝑑𝑖−3 = 10 × −51 + 4 = −506
Step-14: Combining the remainder in step-13 with the third IV. CONCLUSIONS
digit of the group being processed, i.e., 3 rd digit in 744. The algorithms in [1] for Aryabhata’s methods of
𝑆 = 𝑛 − 𝐵3 = −506 − 53 = −506 − 125 = −631 extraction of square root and cube root have been analyzed
Step-15: updating i for processing next three digits of the next and traced the shortcomings why the algorithms fail to give
group if any.
correct results for some numbers. Improved algorithms have
𝑖 = 𝑖 − 3 = 3 − 3 = 0;
been provided to give correct results while computing square
Step-16: Updating p to determine, whether more digits of
or cube root for any positive integer that can be processed in a
cube root need to computed.
computer. The algorithms can be extended to find the square
𝑝 =𝑝−1= 1−1= 0
Step-17: Since 𝑝 = 0, exit. root or cube root of any arbitrarily large integers by
So, the result of the computation of the cube root by the above implementing it in representa arithmetic.
algorithm is 15 instead of 14. The reason why this happens is
that the digit of the cube root by step-10 does not guarantee
that the digit would be the correct digit of the cube root. Also, REFERENCES
in the process that follows does not check bout the correctness [1] Abhishek Parakh, “Aryabhata’s root extraction methods”,
of the computed digit of the cube root in step-10. Indian Journal of History of Science, Vol. 42, No.2, pp.
149-161, 2007
Improved Algorithm: (Aryabhatta’s method to compute cube [2] David H. Bailey, Jonathan M Borwein, “Ancient Indian
root) Square roots: An Exercise in Forensic Paleo
Input: Positive integer within byte size limitation, Mathematics”
𝑑𝑛 𝑑𝑛 −1 ⋯ ⋯ 𝑑2 𝑑1 𝑑0 https://www.carma.newcastle.edu.au/jon/india-sqrt.pdf
Output: integer part of the cube root of the number (square root and cube root, aryabahatta)
𝑑𝑛 𝑑𝑛 −1 ⋯ ⋯ 𝑑2 𝑑1 𝑑0 [3] T.R.N Rao and C.-H Yang, “Aryabhata remainder
Steps: theorem: relevance to crypto algorithms”, Circuits,
𝑛 Systems and Signal Processing, vol-25, pp. 1-15, 2006.
1. 𝑝 =
3 [4] Y. Kirani Singh, “Computing cube root of a positive
2. Pick 𝑑𝑖 where 𝑖 = 3 ∗ 𝑝 number” ADBU journal of Engineering Technology,
3. Let = 100 × 𝑑𝑖+2 + 10 × 𝑑𝑖+1 + 𝑑𝑖 . if does 𝑑𝑖+2 Special issue: pp. 85-89, Vol. 4, March 2016.
not exist, let 𝑑𝑖+2 =0; if 𝑑𝑖+1 does not exist, let [5] Y. Kirani Singh, “Computing square root of a large
𝑑𝑖+1 = 0 positive integer” ADBU Journal of Engineering
4. Choose A such that 𝐴3 ≤ 𝑘 and 𝑘 − 𝐴3 is minimum. Technology, Vol. 5, June-July, 2016.
5. 𝑆 = 𝑘 − 𝐴3 [6] Yumnam Kirani Singh , “On Some Generalized
6. 𝑅 = 𝐴 Transforms for Signal Decomposition and Reconstruction
7. While p>0 ----continue step 8 to 18 ” Ph.D. dissertation, CVPR Unit, ISI, Kolktata. 2006.
8. 𝑙 = 10 × 𝑆 + 𝑑𝑖−1
9. 𝑆 = 𝑙 𝑚𝑜𝑑 (3 × 𝑅2 )
10. 𝑚 = 10 × 𝑆 + 𝑑𝑖−2
𝑙
11. 𝐵 = 2
3×𝑅
12. 𝑆 = 𝑚 − 3 × 𝑅 × 𝐵2
13. 𝑛 = 10 × 𝑆 + 𝑑𝑖−3
14. 𝑆 = 𝑛 − 𝐵3
15. If 𝑆 < 0, 𝐵 = 𝐵 − 1 go to step-11