An Analysis On Extracting Square and Cube Roots by Aryabhata's Methods

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

ADBU-Journal of Engineering Technology

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.

(Article history: Received 12 November 2016 and accepted 30 December 2016)

In this paper, the algorithms for extraction of square root and


I. INTRODUCTION cube root using Aryabhata’s methods are analyzed and
Aryabhatta is one of the most revered ancient Indian improved so that it gives for correct results while computing
mathematicians who made significant contributions in various the roots. The paper is divided into four sections. Section II
fields of mathematics and astronomy [1, 2]. His contribution discusses algorithm for extraction of square root and section
in mathematics has also been studied for possible applications III discusses the algorithm to compute cube root. A short
in cryptography [3]. He also contributed methods of finding conclusion is given in section IV.
square root and cube root of a number in his book Ganitpada.
The methods are translated into English and explained with II. SQUARE ROOT EXTRACTION ALGORITHM
examples [1,2]. The methods are similar in approach to the In this section, the algorithm or method of extracting square
long division method of extracting square root but not exactly root by using Aryabhata’s method as explained in [1,2] fails to
the same. It seems to be simpler as compared to long division work for some numbers whose square root has 1 as the first
method especially the way how the next digit of the root is digit. The square root algorithm given in [1] is reproduced
computed from the knowledge of previously computed digits here for discussion.
of the root. However, the ways methods have been explained
or algorithms have been designed have limitations in the sense Algorithm:
that the method gives incorrect results. The explained methods Represent the given number as a series of indexed digits, i.e.,
fail to give the correct values of the square root or cube root of 𝑑𝑛 𝑑𝑛 −1 ⋯ ⋯ 𝑑2 𝑑1 𝑑0 , where 𝑑0 is the digit in unit’s place, 𝑑1 is
some of the numbers such as square root of 841 or cube root the digit in ten’s place, 𝑑2 is the digit in hundred’s place and so
of 17576. The reason might be missing of some points in the on. Let R be the final root and n be the index of the leftmost
translation of Aryabhata’s methods. In [1], the author tried to digit in the number.
explain the methods in binomial expansion of power 2 and 3 𝑖
i.e., (𝑎 + 𝑏)2 and (𝑎 + 𝑏)3 in the same way some 1. Pick 𝑑𝑖 such that = integer,
2
𝑖+𝑘 𝑖 𝑖−𝑘
mathematicians try to explain long division method of Where ≠ 𝑖𝑛𝑡𝑒𝑔𝑒𝑟 and > , 𝑘 = 1,2,3, ⋯
2 2 2
computing square roots in terms of polynomial expansion of 𝑛−1
power of 2. But a multi-digit number is very different from a 2. 𝑝=
2
polynomial; a binomial and a 2-digit number are different 3. If 𝑑𝑖+1 exists 𝑎 = 10 × 𝑑𝑖+1 + 𝑑𝑖 else 𝑎 = 𝑑𝑖
entities. Elements in a polynomial do not have place value 4. Choose A such that 𝐴2 ≤ 𝑎 and 𝑎 − 𝐴2 is
whereas digits in numbers have place values. For example, minimum
(1 + 6)2 and (6 + 1)2 will give 49, where as (16)2 gives 256 5. 𝑆 = 𝑎 − 𝐴2
and (61)2 gives 3721. More correct ways of explaining long 6. 𝑅=𝐴
division of extracting square root is given in [5] and the 7. 𝑦 = 10 × 𝑆 + 𝑑𝑖−1
extension of long division method for computing cube root is 8. 𝑆 = 𝑦 𝑚𝑜𝑑 (2 × 𝑅)
given in [4]. 𝑦
9. 𝐵=
2×𝑅

Singh, AJET, ISSN:2348-7305, Volume:5, Issue:2, December 2016, 00521204(04PP)


ADBU-Journal of Engineering Technology

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.

Singh, AJET, ISSN:2348-7305, Volume:5, Issue:2, December 2016, 00521204(04PP)


ADBU-Journal of Engineering Technology

6. 𝑅=𝐴 13. 𝑛 = 10 × 𝑆 + 𝑑𝑖−3


7. While 𝑝 > 0 ---- continue step 8 to 16 14. 𝑆 = 𝑛 − 𝐵3
8. 𝑦 = 10 × 𝑆 + 𝑑𝑖−1 15. 𝑖 =𝑖−3
9. 𝑆 = 𝑦 𝑚𝑜𝑑 (2 × 𝑅) 16. 𝑝=𝑝−1
10. 𝑐 = 10 × 𝑆 + 𝑑𝑖−2 17. If 𝑝 ≠ 0 go to 7, else quit.
𝑦
11. 𝐵= Step-1 is to group the given number in terms of three digits
2×𝑅
12. 𝑆 = 𝑐 − 𝐵2 starting from the right side. Step-2 gives the number of digits
13. If 𝑆 < 0, 𝐵 = 𝐵 − 1, go to Step-11. in the cube root to be computed after the first digit of the cube
14. 𝑅 = 10 × 𝑅 + 𝐵 root. Step-3 gets the leftmost segment or group of the number.
15. 𝑖 =𝑖−2 Step-4 computes the first digit of the cube root. Step-5 finds
16. 𝑝=𝑝−1 the difference between the first segment and the cube of the
End While first digit of the cube root. The first digit of the cube root is
In the improved algorithm, the process of grouping of digits of put to the result in step-6. Step-7 combines the remainder in
the given number in two’s starting from the right end is step-5 and the first digit of the next group or segment. Step-8
simplified. Also, the computation of next digit of the root is finds the remainder of when the number in step-7 is divided by
performed only when required in while loop. Suppose, we thrice of the square of the result obtained so far. Step-9
want to compute square root of 81, we do not need to proceed combines the remainder with next digit (i.e., second digit) of
for computation for next digit. More importantly, the the segment being processed. Step-10, computes the next digit
estimated value of the root in step-11 is greater than the of the cube root, which is the quotient obtained when the
expected value of the next digit of the square root. If the value number in step-7 is divided by thrice of square of the result
is greater than the expected value, the estimated value is kept obtained so far. Step-11 finds the difference between the result
on reducing by 1. With these modifications, the algorithm will obtained in step-9 and multiplication of thrice the result and
square the digit of the root computed in step-10. In step-12,
give correct result of integer part when finding square root
the result is updated by incorporating the digit of the root
using Aryabhata’s method.
computed in Step-10. Step-13 combines the difference
obtained in step-11 with the third digit of the segment. In step-
III. COMPUTING CUBE ROOT 14, the difference between the number in step-13 and the cube
The algorithm given in [1] for extraction of cube root of a of the digit of the root is found. Step-15 updates the index to
positive number fails to works for numbers whose cube root get the next three digit of the next segment by reducing its
has 1 as first digit and a digit greater than 3 as the second value by 3. Step-16, updates the counter which indicates how
digit. The algorithm is reproduced here also for further many digits of the root are still left with for computation.
discussion. Step-17 checks whether any more digit is required to be
computed. If so steps the same process to compute next digit
Algorithm: of the root is repeated from step-7 onwards.
Represent the given number as a series of indexed digits, The above algorithm fails to work to find the cube roots of
i.e.,𝑑𝑛 𝑑𝑛−1 ⋯ ⋯ 𝑑2 𝑑1 𝑑0 , where 𝑑0 is the digit in units place, some of the numbers whose first digit in cube roots is 1 and
𝑑1 is the digit in tens place, 𝑑2 is the digit in hundreds place next digit is greater than 3. The reasons are the same as
and so on. Let the final root be R and𝑛 is the index of the left explained in the case of failures of extraction of square root.
most digit in the given number. Then the algorithm is as That is, the algorithm did not consider the cases of carries that
follows: has been transferred from right to left digits when cubing two
𝑖 or more digit number.
1. Pick the digit 𝑑𝑖 such that = integer,
3
𝑖+𝑘 𝑖 𝑖−𝑘
≠ integer and > , k =1,2,3, … . Example: Cube root of 2744.
3 3 3
𝑛−1 By the above algorithm, the cube root is given as 15. Let us
2. 𝑝=
3 analyze, why this happens.
3. Let = 100 × 𝑑𝑖+2 + 10 × 𝑑𝑖+1 + 𝑑𝑖 . if does 𝑑𝑖+2 Step-1: The number is divided in two segments: 2,744. The
not exist, let 𝑑𝑖+2 =0; if 𝑑𝑖+1 does not exist, let first segment is 2 and the second segment is 744. Also, i=3.
𝑑𝑖+1 = 0 Step-2:𝑝 = 𝑛/3 =Flooring of (3/3)=1,
4. Choose A such that 𝐴3 ≤ 𝑘 and 𝑘 − 𝐴3 is minimum. That is, one more digit of the root is required to be computed
5. 𝑆 = 𝑘 − 𝐴3 after the first digit of the root is computed from the first
6. 𝑅 = 𝐴 segment.
7. 𝑙 = 10 × 𝑆 + 𝑑𝑖−1 Step-3:Getting the first segment, k=2.
8. 𝑆 = 𝑙 𝑚𝑜𝑑 (3 × 𝑅2 ) Step-4:Integer part of cube root of first segment, A=1.
9. 𝑚 = 10 × 𝑆 + 𝑑𝑖−2 Step-5:𝑆 = 𝐾 − 𝐴3 = 2 − 13 = 1
𝑙
10. 𝐵 = 2 Step-6: Result R=1
3×𝑅
11. 𝑆 = 𝑚 − 3 × 𝑅 × 𝐵2 Step-7: combining the difference in 5 with first digit of next
12. 𝑅 = 10 × 𝑅 + 𝐵 group, i.e., 744

Singh, AJET, ISSN:2348-7305, Volume:5, Issue:2, December 2016, 00521204(04PP)


ADBU-Journal of Engineering Technology

𝑙 = 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

Singh, AJET, ISSN:2348-7305, Volume:5, Issue:2, December 2016, 00521204(04PP)

You might also like