0% found this document useful (0 votes)
158 views9 pages

Aryabhata Algorithm - Vuppala

The document introduces the Aryabhata algorithm for finding multiplicative inverses using the least absolute remainders approach. It begins by explaining Euclid's algorithm for finding the greatest common divisor (GCD) of two numbers using least absolute remainders. This approach is then related to solving linear indeterminate equations and finding multiplicative inverses. The Aryabhata algorithm and an improved extended Euclid algorithm using least absolute remainders are presented.

Uploaded by

gaurnityananda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
158 views9 pages

Aryabhata Algorithm - Vuppala

The document introduces the Aryabhata algorithm for finding multiplicative inverses using the least absolute remainders approach. It begins by explaining Euclid's algorithm for finding the greatest common divisor (GCD) of two numbers using least absolute remainders. This approach is then related to solving linear indeterminate equations and finding multiplicative inverses. The Aryabhata algorithm and an improved extended Euclid algorithm using least absolute remainders are presented.

Uploaded by

gaurnityananda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

The Aryabhata Algorithm Using Least Absolute Remainders

Sreeram Vuppala

1 Introduction

The year 2006 has seen renewed interest in the mathematics of Aryabhata (473- c.550),
the great mathematician-astronomer of Classical India, for potential applications to
cryptography. Rao and Yang [1] recently published an analysis of the Aryabhata
algorithms for finding of multiplicative inverse of a group modulo a prime as well as the
solution to multiple congruences. The RSA 2006 Conference held in San Jose in
February also honored Aryabhata.

It is believed that Aryabhata was the kulapati (head) of the University at Nalanda in
Magadha. He wrote at least two books: the ryabhatiya and the ryabhata-siddhnta, of
which the latter is known only through references in other works. The ryabhatya
presented ryabhatas astronomical and mathematical theories, in which the earth was
taken to be spinning on its axis and the periods of the planets were given with respect to
the sun. The ryabhatya was translated into Arabic as Arajbahara, and in turn it
influenced Western astronomers.

For general background to Indian mathematical tradition, see the books by Datta and
Singh [2], Srinivasiengar [3], and Joseph [4]; and for its combinatoric and astronomical
motivations see the recent papers by Kak [5-10]. Almeida et al [11] argue that Indian
mathematics may have provided the spark that led to the scientific revolution in Europe,
and this issue, together with a fresh appraisal of the larger question, is discussed by
Pearce [12].

The ryabhatya presents a method to solve linear indeterminate equations, which may
be adapted to find the multiplicative inverse in a group that is of interest in cryptography,
signal processing, coding and computer design. Although Aryabhata calls this method the
Kuttaka (the pulverizer), it is now better known as the Aryabhata Algorithm [13].

This paper presents an introduction to the Aryabhata algorithm. We do so by the use of


the least absolute remainders, which can also be used to speed up the Extended Euclids
algorithm to obtain multiplicative inverses in a group. It may be noted that the Extended
Euclids algorithm is very similar to the Aryabhata algorithm, and historians believe that
Aryabhata was the first to solve linear indeterminate equations.

The exposition of the Aryabhata algorithm provided here can have performance that
could exceed what was described by Rao and Yang [1]. Section 2 presents the basic

1
Euclidean algorithm and the use of least absolute remainders as background. Section 4
and 5 present the Aryabhata algorithm with the least absolute remainders.

2 GCD of two numbers using least absolute remainders

Euclids algorithm gives a very simple and efficient method for the determination of the
greatest common divisor (g.c.d) of two numbers.

Let a, b be the two numbers whose g.c.d is to be computed. Since there is only the
question of divisibility, there is no limitation in assuming that a, b are positive and a b .
We divide a by b with respect to the least positive remainder.

a = q1b + r1 , 0 r1 < b
Next we divide b by r1 ,
b = q2 r1 + r2 , 0 r2 < r1

Then, continue the process on r1 and r2 .


a = q1b + r1
b = q2 r1 + r2
r1 = q3 r2 + r3



rn1 = qn+1rn

Stop when rn+1 = 0 . The g.c.d is the last non-vanishing remainder rn .


Now remove the condition of the remainder rn being positive. The conclusions are the
same except that rn may be a negative value of the g.c.d. It was shown by a German
mathematician Kronecker (1823-1891) that no Euclid algorithm can be shorter than the
one obtained by using the least absolute remainders [14].

We demonstrate these two methods using an example. Let a = 76, 084 and b = 63, 020 .

2
Method 1:

76, 084 = 63, 020 1 + 13, 064


63, 020 = 13, 064 4 + 10, 764
13, 064 = 10, 764 1 + 2,300
10, 764 = 2,300 4 + 1,564
2,300 = 1,564 1 + 736
1,564 = 736 2 + 92
736 = 92 8

Figure 1

This method uses the Euclids algorithm using least positive remainder.

Method 2:

76, 084 = 63, 020 1 + 13, 064 76, 084 = 63, 020 1 + 13, 064
63, 020 = 13, 064 5 2,300 63, 020 = 13, 064 5 + (2,300)
13, 064 = 2,300 6 736 13, 064 = (2,300) (6) + (736)
2,300 = 736 3 + 92 2,300 = (736) (3) + 92
736 = 92 8 736 = 92 8

(a) (b)
Figure 2

The second method shows the Euclids algorithm using least absolute remainders. In
Figure 2, you see two representations of the equations. It can be easily seen [13] that the
negative signs for the quotients can be dropped in the calculation of the g.c.d. In Figure
2.b, the representation keeps in mind of the negative signs of the quotients during the
computations.

3. Linear Indeterminate Equations and Multiplicative Inverses

Theorem 1: When a and b are relatively prime, it is possible to find such other integers x
and y that
a x + b y =1 (1)

In other words, unity is a linear combination of a and b.

3
Given positive pair wise prime integers a and b, it is very often necessary to find the
multiplicative inverses a1 mod b and b1 mod a . The inverses can be solved by
solving equation (1).

3.1. Solving Linear Indeterminate Equations using Euclids algorithm:

We suppose that a > b . To make the notation more systematic, we write a = r1 and
b = r2 in stating the algorithm.

r1 = q1r2 + r3
r2 = q2 r3 + r4

rn3 = qn3 rn2 + rn1 1 = rn3 qn2 + (1 + qn2 qn3 ) rn2
rn2 = qn2 rn1 +1 1 = rn2 qn2 rn1

(a) (b)
Figure 3

We shall obtain a representation in Equation (1) by a stepwise process derived from


Figure 3(a). This is shown in Figure 3(b).

3.2. Extended Euclid Algorithm:

A straight-forward modification of the above method is the The Extended Euclid


Algorithm (which is really a version of Aryabhatas Kuttaka algorithm that will be
described formally later) that is used for the computation of multiplication inverses
commonly used in cryptographic algorithms like the RSA encryption system. The
multiplicative inverse is denoted as a 1 mod b , where a > b .

The simpler version of Euclidean algorithm from [1] will illustrate the principle.

Example 1:
Let a = 137 and b = 60 .

i ri qi xi yi
-1 137 - 1 0
0 60 - 0 1
1 17 2 1 -2
2 9 3 -3 7
3 8 1 4 -9
4 1 1 -7 16
5 0
Table 1

4
qi quotient (ri2 / ri1 ), ri ri2 mod ri1
xi xi2 qi xi1 , yi yi2 qi yi1

From the table 1, we have x = 7 mod 60 = 53 and y = 16 . Therefore,


1371 mod 60 = 53 and 601 mod137 = 16 .

3.3. The Improved Extended Euclid Algorithm:

This method uses the extended Euclid algorithm but uses least absolute remainders to
solve for inverses. The list of quotients will use list obtained from Method 2(b) instead
and method 2(a) and then use an iterative method to solve xi and yi .

Using Example 1 in the previous section:

Let a = 137 and b = 60 .

i ri qi xi yi
-1 137 - 1 0
0 60 - 0 1
1 17 2 1 -2
2 -8 4 -4 9
3 1 -2 -7 16
4 0
Table 2
qi quotient (ri2 / ri1 ), ri ri2 mod ri1
xi xi2 qi xi1 , yi yi2 qi yi1

In some cases, the last remainder could be -1. If this is the case, then the initial conditions
for xi = 1, 0 and yi = 0, 1 .

Note: In Method 2, we can find the g.c.d of two numbers by neglecting the negative signs.
In the case of multiplicative inverses, the negatives signs of the quotients should not be
neglected.

5
Example 2:

We show another example to prove that the improved Extended Euclids algorithm
performs much when the least absolute remainders are used.

Let a = 249 and b = 181 .

i ri qi xi yi
-1 249 - 1 0
0 181 - 0 1
1 68 1 1 -1
2 45 2 -2 3
3 23 1 3 -4
4 22 1 -5 7
5 1 1 8 -11
5 0
Table 3

This EEA took 5 steps to compute the inverses.

Using the improved Extended Euclids algorithm:

i ri qi xi yi
-1 249 - -1 0
0 181 - 0 -1
1 68 1 -1 1
2 -23 3 3 -4
3 -1 -3 8 -11
3 0
Table 4

The improved algorithm solved the problem in 3 steps.

4. Aryabhata Algorithm Kuttaka

The algorithm written by Aryabhata as found in his book, the Aryabhatiya, is called The
Kuttaka (the pulverizer). In [13], this method was introduced as the Aryabhata algorithm,
to conform to the convention of associating the person with his result. This algorithm for
the solution of a linear indeterminate equation appears to be the earliest recorded
anywhere.

In the Aryabhata Algorithm, the list of quotients is called the Valli. The second column
in Table (5.a) is the Valli.

6
The improved Aryabhata algorithm (IAA) will be discussed here for solving the
multiplicative inverse a1 mod b by solving the equation a x + b y = 1 .

Example 3: Let a = 137 and b = 60

Using the recursive formula: Si = qi Si+1 + Si+2 We start with S5 = 1 , S 4 = q4

i qi Si
1 2 16
2 3 7
3 1 2
4 1 1
5 1
Table (5a)

We can conclude that with n = i 1 , y = (1) n S1 and x = (1) n S 2 . Therefore,


x = 7 and y = 16 .

5. A Faster Improved Aryabhata Algorithm

The IAA can be further improved by reducing the Valli by using the least absolute
remainders in Method 2. When the least absolute remainders method is used, the last
remainder can end with 1or -1.

Case -1: S1 = S1 (1)


Case 1: S 2 = S2 (1)
a1 mod b = S 2 , b1 mod a = S1
Using the same example:

i ri qi Si
1 17 2 -16
2 -8 4 -7
3 1 -2 -2
4 1
Table (5b)

In this case, the last remainder is 1, so S 2 = S 2 (1) (7) (1) = 7


There fore, y = (1) n S1 and x = (1) n S 2 y = (1)3 S1 = 16, x = (1)3 S 2 = 7

7
Example 4: Let a = 249 and b = 181

i qi Si
1 1 11
2 2 8
3 1 3
4 1 2
5 1 1
6 1
Table (6a)
Therefore, x = 8 and y = 11 .
The faster method:

i ri qi Si
1 68 1 -11
2 -23 3 -8
3 -1 -3 -3
4 1
Table (6b)

Since the last remainder is -1, S1 = S1 (1) (11) (1) = 11


Therefore, y = (1) n S1 and x = (1) n S 2 y = (1)3 S1 = 11, x = (1)3 S 2 = 8 .

Conclusions

The use of least absolute remainders can improve both the standard Aryabhata algorithm
and the extended Euclid algorithm in performance.

Rao and Yang stated [1] that the number of computations required to solve for
multiplicative inverses is reduced using the Aryabhata algorithm, though the backdrop is
that it needs extra memory to store all the quotients. With the use of the least absolute
remainders, we have a best case scenario where the extra memory and computations is
reduced by at least half. The worst case scenario using least absolute remainders will be
the same as using the least positive remainders. Since, we know that multiplicative
inverses are necessary in both the Chinese Remainder Theorem and the Aryabhata
Remainder Theorem; the execution times can be greatly reduced when using the least
absolute remainders.

References

[1]. T.R.N. Rao and C.-H. Yang, 2006. Aryabhata remainder theorem: relevance to
crypto-algorithms, Circuits, Systems, and Signal Processing, 25: 1-15.

[2] B. Datta and A.N. Singh, 1962. History of Hindu Mathematics, A Source Book, Parts
1 and 2, (single volume). Bombay: Asia Publishing House.

8
[3] C.N. Srinivas Iyengar, 1967. The History of Ancient Indian Mathematics. Calcutta:
The World Press Private.

[4] G. G. Joseph, 2000. The Crest of the Peacock, Non-European Roots of Mathematics.
Princeton: Princeton University Press.

[5] S. Kak, 2005. Aristotle and Gautama on logic and physics. arXiv: physics/0505172

[6] S. Kak, 2004. The golden mean and the physics of aesthetics. arXiv: physics/0411195

[7] S. Kak, 2003. Indian Physics: Outline of Early History. arXiv: physics/0310001

[8] S. Kak, 2005. Greek and Indian Cosmology: Review of Early History. History of
Science, Philosophy & Culture in Indian Civilization, vol. 1, part 4 (A Golden Chain,
G.C. Pande, and ed.), pp. 871-894; arXiv: physics/0303001

[9] S. Kak, 2005. Babylonian and Indian Astronomy: Early Connections. History of
Science, Philosophy & Culture in Indian Civilization, vol. 1, part 4 (A Golden Chain,
G.C. Pande, and ed.), pp. 847-869; arXiv: physics/0301078

[10] S. Kak, 2000. Birth and Early Development of Indian Astronomy. In Astronomy
Across Cultures: The History of Non-Western Astronomy, Helaine Selin (ed), Kluwer, pp.
303-340. arXiv: physics/0101063

[11] D.F. Almeida, J.K. John and A. Zadorozhnyy, 2001. Keralese Mathematics: Its
Possible Transmission to Europe and the Consequential Educational Implications.
Journal of Natural Geometry 20, 77-104.

[12] I.G. Pearce, 2002. Indian mathematics: redressing the balance. http://www-
history.mcs.st-andrews.ac.uk/history/Projects/Pearce/index.html

[13] S. Kak, 1986. Computational Aspects of the Aryabhata Algorithm, Indian Journal of
History of Science, 21: 62-71.

[14] Oystein Ore, 1948. Number Theory and its History. McGraw-Hill.

Sreeram Vuppala
E-mail: [email protected]

You might also like