11
Binary Powering in Ancient India J. B. Thoo Mathematics Department Yuba College 2088 North Beale Road Marysville, CA 95901-7605 [email protected] March 1, 2013 Abstract Mathematics is a human endeavor, and the story of mathematics is part of the larger story of mankind. There are many opportunities for us to use the history of mathematics, either as a vehicle for presenting topics or as a sidebar, to draw our students into the larger story of mathematics and, thereby, increase their interest in our subject. It works because, after all, there is nothing like a good story to get one’s attention. We present one example from the history of mathematics, Pigala’s method, that can be used as a sidebar in a variety of courses, from college arithmetic to elementary or intermediate algebra to linear algebra. The problem is simple: How can we find a n if a is a real or complex number without having to find n - 1 products (or, worse, A n if A is a square matrix)? 1 Introduction It seems that many students, particularly basic skills students—those in intermediate algebra (high-school algebra II) or below—believe that mathematics is a static subject that was etched in stone millennia ago. Worse, for many basic skills students, their mathematics course is only an obstacle that they have to overcome on their way toward their educational or professional goals. While they understand a need to know the basic arithmetical operations and the use of

Binary Powering in Ancient India - YCCD Powering in Ancient India J. B. Thoo ... newspapers, television ... The beginnings of civilization in the Indian subcontinent extend as far

Embed Size (px)

Citation preview

Binary Powering in Ancient India

J. B. ThooMathematics Department

Yuba College2088 North Beale Road

Marysville, CA [email protected]

March 1, 2013

Abstract

Mathematics is a human endeavor, and the story of mathematics is part of the larger story of mankind. There are many opportunities for us to use the history of mathematics, either as a vehicle for presenting topics or as a sidebar, to draw our students into the larger story of mathematics and, thereby, increase their interest in our subject. It works because, after all, there is nothing like a good story to get one’s attention.

We present one example from the history of mathematics, Piṅgala’s method, that can be used as a sidebar in a variety of courses, from college arithmetic to elementary or intermediate algebra to linear algebra. The problem is simple: How can we find an if a is a real or complex number without having to find n� 1 products (or, worse, An if A is a square matrix)?

1 Introduction

It seems that many students, particularly basic skills students—those in intermediate algebra (high-school algebra II) or below—believe that mathematics is a static subject that was etched in stone millennia ago. Worse, for many basic skills students, their mathematics course is only an obstacle that they have to overcome on their way toward their educational or professional goals. While they understand a need to know the basic arithmetical operations and the use of

percents, for example, “higher” mathematics like algebra seems to many basic skills students to have little or no relevance to occupations such as social work, law enforcement, physical therapy, nursing, or preschool teaching; and we have to admit that we are hard pressed to offer meaningful examples of the everyday use of algebra (solving equations, for instance) in these occupations. How, then, can we convince our students, particularly our basic skills students, that it is worthwhile to learn a little mathematics?

We may tell them,

• It is good for you. It builds character.

• You may not use the specific skills that are taught in this course, but you will use the analytical and critical thinking skills that you will develop.

• You will have demonstrated that you are capable of learning something hard successfully, and that you have the perseverance to accomplish difficult tasks.

Now, while these may be good reasons, they do not seem to raise the students’ interest in learning mathematics. So, instead, we use the history of mathematics to draw them into the subject.

Mathematics is a human endeavor, and the story of mathematics is part of the larger story of mankind. The history of mathematics, either as a vehicle for presenting topics or as a sidebar, exposes students to the human side of mathematics. It works because, after all, there is nothing like a good story to get one’s attention. As George Gheverghese (1991, p. 1) puts it,

An interest in history marks us for life. How we see ourselves and others is shaped by the history we absorb, not only in the classroom but from films, newspapers, television programmes, novels and even strip cartoons. From the time we first become aware of the past, it can fire our imagination and excite our curiosity: we ask questions and then seek answers from history. As our knowledge develops, differences in historical perspectives emerge. And, to the extent that different views of the past affect our perception of ourselves and of the outside world, history becomes an important point of reference in understanding the

clash of cultures and of ideas. Not surprisingly, rulers throughout history have recognized that to control the past is to master the present and thereby consolidate their power.

Mathematics has played a prominent role throughout all of history.

We present one example from the history of mathematics that can be used as a sidebar in a variety of courses, from college arithmetic to elementary or intermediate algebra to linear algebra. The problem is simple: How can we find an if a is a real or complex number without having to find n� 1 products (or, worse, An if A is a square matrix)?

The paper is organized as follows. In section 2 we provide a vignette of ancient India that leads to a method for finding an or An more efficiently. We discuss this method, Piṅgala’s method, in section 3, and explain why the method works in section 4. We conclude in section 5 by once more making a case for using the history of mathematics, either as a vehicle for introducing topics or as a sidebar, to draw students into the subject.

2 Vignette

The beginnings of civilization in the Indian subcontinent extend as far back as 3000 BC, with the great Indian civilization developing in the Indus Valley around 2500 BC. Sometime before 1700 BC, however, the civilization went into decline. The demise of this great Indian civilization was later erased by a group of migrants from the northwest that were known as Aryans around 1500 BC. It is with the Aryans that we associate the development of the Indo-Aryan languages, including Sanskrit, Hindi, Bengali, and Marathi, and a large body of Vedic texts called Vedas around 900 BC, which are among the most ancient works of literature in the world (Cooke, 2005).

Most of the mathematics that we have come to ascribe to the Indians of South Asia were written in Sanskrit on birch bark in the north and palm leaves in the south.1 As a result, unlike the durable Babylonian clay tablets, nearly all of the extant manuscripts written on these are of relatively recent date. According to

1 “Indian mathematics” is also called “Hindu mathematics” by some historians of mathematics.

Plofker (2007, pp. 385–386), “[the] first known texts … are the ‘Vedas’ (literally ‘knowledge’), a canon of hymns, invocations, and procedures for religious rituals. The Vedic texts (generally composed in verse or in short prose sentences called sūtras to make them easier to memorize) were carefully learned, recited, and handed down orally.” The best preserved and handed down Vedas were the ones that were most important for religious sacrifices. In addition to the Vedic hymns, other texts that were carefully handed down because of their importance were on the six subjects called the “limbs of the Vedas,” which Plofker lists as:

1. phonetics, which preserved the correct pronunciations of the archaic Sanskrit invocations;

2. grammar, which explained how its sentences would be understood;

3. metrics, which preserved the structure of its verses;

4. etymology, which explained its vocabulary;

5. astronomy and calendrics, which ordered the timing of the sacrifices; and

6. ritual practice, which preserved the sacrificial tradition.

It is from the Vedas and the limbs of the Vedas that we have obtained glimpses of the earliest Indian mathematics. For example, the limb of ritual practice includes the Śulbasūtras (“Cord-Rules,” which reminds us of the ancient Egyptian harpedonáptai or “rope stretchers” (Cooke, 2005)) that was written sometime in the first half of the first millennium BC, and that describes rules for finding areas and volumes for building brick altars. Perhaps not too surprisingly, the limb of the Vedas that led to most of ancient Indian mathematics was the one on astronomy and calendrics. (Here we obtain a hint of Babylonian influence on early Indian mathematics. The way linear proportion was used for finding daylight length is similar to a common Babylonian method. Also, references to gnomons and water clocks, and the use of similar time units add to the evidence (Plofker, 2007).) However, even the limb of metrics contains some mathematics, and it is here that we peer through the history glass at one bit of ancient Indian mathematics.

3 Piṅgala’s method

Metrics or prosody classifies and describes different verse meters. In his work Chandahsūtra, Piṅgala (dated prior to 200 BC) gives the following method for computing the number of different syllable patterns that can be formed in a line containing n syllables, where each syllable can be either heavy or light (Plofker, 2007, p. 393):

When halved, [record] two. When unity [is subtracted, record] zero. When zero, [multiply by] two; when halved, [it is] multiplied [by] so much [i.e., squared].

Typical of the mathematics in the Vedas, this verse is rather cryptic. We learn from the commentaries that what Piṅgala intends is this: If n is even, halve it and record a 2; if n is odd, subtract 1 from it and record a 0; repeat for the number that results from either halving or subtracting 1; stop when the number that results from subtracting 1 is 0. Now, to determine the number of different syllable patterns, note in reverse order the numbers that were recorded: beginning with the number one, for every 0 that was recorded, double the present result, and for every 2 that was recorded, square it.

As an example, we follow the method to find the number of different syllable patterns that can be formed in a line containing 13 syllables.

Number Parity Action New number Record

13 odd subtract 1 12 0

12 even halve 6 2

6 even halve 3 2

3 odd subtract 1 2 0

2 even halve 1 2

1 odd subtract 1 0 0

0 0 marks the end0 marks the end0 marks the end0 marks the end

Now, to determine the number of different syllable patterns, we note in reverse order the numbers that were recorded, to wit,

0, 2, 0, 2, 2, 0.

Then, beginning with the number one, for every 0 that was recorded, we double the present result, and for every 2 that was recorded, we square it.

1⇥2��!0

2( )2��!2

4⇥2��!0

8( )2��!2

64( )2��!2

4096⇥2��!0

8192

This yields

213 = 2((2(22))2)2 = 8192.

Thus, we conclude that we can form 8192 different syllable patterns in a line containing 13 syllables, where each syllable can be either heavy or light.

What is remarkable is that we found 213 with a total of five operations instead of 12 (if we do not count the first step, 1⇥ 2 ), a savings of more than half the number of operations.

Moreover, we may apply Piṅgala’s method to find a13 (or A13) for any real or complex number a (or square matrix A).

1⇥a��!0

a( )2��!2

a2⇥a��!0

a3( )2��!2

a6( )2��!2

a12⇥a��!0

a13

I⇥A��!0

A( )2��!2

A2 ⇥A��!0

A3 ( )2��!2

A6 ( )2��!2

A12 ⇥A��!0

A13

Here, I is the n⇥ n identity matrix. Hence, we find that

a13 = a((a(a2))2)2 and A13 = A((A(A2))2)2.

Therefore, Piṅgala’s method provides us a more efficient way to evaluate an for any real or complex number a and positive integer n , or An for any square matrix A and positive integer n.

4 Piṅgala’s method = binary powering

How can we understand Piṅgala’s method? Kalman (2009, pp. 7–13) provides an answer: apply Horner’s method to the binary expansion of n , a scheme that Golub and Van Loan (1983) discuss under the heading “binary powering.” Binary powering in ancient India!

What is Horner’s method? Consider a typical polynomial in x, say,

p(x) = 3x4 + 2x3 � 4x2 + x+ 7.

Now, suppose that we wish to find p(5) . If done directly, to find p(5) would require finding 9 products and 4 sums, a total of 13 operations. Horner’s method provides a way to find p(5) with only 4 products and 4 sums, a total of eight operations—remarkable! This is done by writing

p(x) = 3x4 + 2x3 � 4x2 + x+ 7

= (3x3 + 2x2 � 4x+ 1)x+ 7

= ((3x2 + 2x� 4)x+ 1)x+ 7

= (((3x+ 2)x� 4)x+ 1)x+ 7.

Then,

p(5) = (((3 · 5 + 2)5� 4)5 + 1)5 + 7 = 2037

5⇥3�! 15

+2�! 17⇥5�! 85

�4�! 81⇥5�! 405

+1�! 406⇥5�! 2030

+7�! 2037

(The repeated factoring shown above is suitable for an elementary or intermediate algebra course. The interested reader may see Kalman (2009) for more on Horner’s method and its relation to synthetic division and differentiation.)

Returning to a13, we note that the binary expansion of 13 is

13 = 1 · 23 + 1 · 22 + 0 · 21 + 1 · 20,

that is, the binary representation of 13 is 1101 or “on-on-off-on”; thus, the base 2 Horner’s representation of 13 is

13 = ((2 + 1)2 + 0)2 + 1 = ((2 + 1)2)2 + 1.

Hence, applying the rules for exponents, we find that

a13 = a((2+1)2)2+1

= (a((2+1)2)2)a

= ((a(2+1)2)2)a

= (((a2+1)2)2)a

= ((((a2)a)2)2)a,

which is precisely the result provided by Piṅgala’s method.

5 Conclusion

There are many opportunities for us to use the history of mathematics, either as a vehicle for presenting topics or as a sidebar, to draw our students into the larger story of mathematics and, thereby, increase their interest in our subject. We showed how we may introduce Piṅgala’s method as a sidebar in a variety of mathematics courses.2 See any book on the general history of mathematics for ideas (for example, Katz, 2009).

2 Quadratic equations, for example, would be a topic that can be presented using the history of mathematics as a vehicle. One could begin with examples from clay tablets from the Old Babylonian period (1800–1600 BC) (Robson, 2007), then move to examples from Al-kitāb al-muẖtaṣar fī ḥisāb al-jabr wa’l muqābala (The Condensed Book on the Calculation of al-Jabr and al-Muqabala) by the Arab mathematician al-Khwārizmī (ca. 780–850) (al-Khwārizmī, 1831), and to examples from Víja-gańita (or Bījagaṇita) by the Indian mathematician Bhāskara II (1114–1185) (Brahmagupta and Bhāskara, 1817). Indeed, it is from the title word al-jabr of al-Khwārizmī’s book that the word “algebra” derives.

It is particularly interesting to see the same methods used in different parts of the world around the same time or at different times. For example, the rule of three for solving proportion problems was used widely in ancient Egypt (in the Rhind Mathematical Papyrus, ca. 1650 BC (Cooke, 2005)), China around 200 BC (in the Jiuzhang suan shu (Shen et al., 1999)), India in the 7th century AD (in Bhāṣya by Bhāskara I (Plofker, 2007)), Europe in the 13th century (in Liber Abaci by Leonardo of Pisa (Fibonacci) (2002)), and the United States as late as the 19th century (in Daboll’s Schoolmaster’s Assistant by Nathan Daboll (1825)). Of course, we all know that the calculus was discovered independently in the late 17th century by the well-known British mathematician and physicist Isaac Newton (1643–1727) and the great German mathematician and philosopher Gottfried Wilhelm Leibniz (1646–1716) (Hall, 1980), but perhaps less well known is that logarithms were invented independently around the same time by the Scottish baron John Napier (1550–1617) and the Swiss craftsman Joost Bürgi (or Jost Bürgi; 1552–1632) (Clark and Montelle, 2010).

Here, we showed how ancient Indians computed 2n efficiently in their very practical problem of determining the number of different syllable patterns that can be formed in a line containing n syllables. We also saw that, while Piṅgala’s method provides us a more efficient way to evaluate an for real or complex numbers a, a greater advantage is achieved when one uses this method to compute An for square matrices A .3 Piṅgala would surely be surprised to find that the method he used continues to find application today in the age of high-speed computers.

Acknowledgement. We thank Brian Winkel for a critical reading of the ms. and his numerous suggestions that improved it immensely. Any remaining shortcomings are entirely our fault.

References

3 Multiplying two m⇥m matrices directly requires m3 products and m2(m� 1) sums of the matrix components; thus, carrying out n matrix multiplications directly would require a total of n(2m3 �m2) operations. For example, if A is a 5⇥ 5 matrix, then finding A13 directly by carrying out 12 matrix multiplications would require a total of 2700 operations; on the other hand, using binary powering (Piṅgala’s method) would require only 5 matrix multiplications and, thus, would require a total of only 1125 operations.

al-Khwārizmī, M. (1831). The Algebra of Mohammed ben Musa. J. Murray, London. Edited and translated by Frederic Rosen.

Brahmagupta and Bhāskara (1817). Algebra, with Arithmetic and Mensuration, from the Sanscrĭt of Brahmagupta and Bhascara. John Murray, London. Translated by Henry Thomas Colebrooke, Esq. <http://books.google.com/ books?id=QJ5BAAAAYAAJ>.

Clark, K. and Montelle, C. (2010). Logarithms: the early history of a familiar function. Loci, DOI: 10.4169/loci003495:1–11. <http://mathdl.maa.org/ mathDL/46/?pa=content&sa=viewDocument&nodeId=3495>.

Cooke, R. (2005). The History of Mathematics: A Brief Course. Wiley-Interscience. John Wiley & Sons, Inc., Hoboken, 2nd edition.

Daboll, N. (1825) Daboll’s Schoolmaster’s Assistant: Improved and Enlarged, Being a Plain Practical System of Arithmetic Adapted to the United States. E. & E. Hosford, Albany. With the addition of The Practical Accountant; Instruction of Youth by Samuel Green. <http://books.google.com/books? id=rWEVAAAAYAAJ>.

Golub, G. E. and Van Loan, C. F. (1983). Matrix Computations. Johns Hopkins, Baltimore.

Hall, A. R. (1980). Philosophers at War: The Quarrel between Newton and Leibniz. Cambridge University Press, Cambridge.

Joseph, G. G. (1991). The Crest of the Peacock: non-European Roots of Mathematics. I. B. Tauris, London.

Kalman, D. (2009). Uncommon Mathematical Excursions: Polynomia and Related Realms, volume 35 of Dolciani Mathematical Expositions. Mathematical Association of America, Washington, D.C.

Katz, V. J. (2009). A History of Mathematics: An Introduction. Pearson Education, Inc., Boston, 3rd edition.

Leonardo of Pisa (Fibonacci) (2002). Fibonacci’s Liber Abaci: A Translation into Modern English of Leonardo Pisano’s Book of Calculation. Springer, New York. Translated by L. E. Sigler.

Plofker, K. (2007). Mathematics in India. In Katz, V. J., editor, The Mathematics of Egypt, Mesopotamia, China, India, and Islam: A Sourcebook. Princeton University Press, Princeton.

Robson, E. (2007). Mesopotamian Mathematics. In Katz, V. J., editor, The Mathematics of Egypt, Mesopotamia, China, India, and Islam: A Sourcebook. Princeton University Press, Princeton.

Shen, K., Corssley, J. N., Lun, A. W.-C., and Hui, L. (1999). The Nine Chapters on the Mathematical Art: Companion and Commentary. Oxford University Press, Oxford.