Computational Thinking in the Indic Tradition K Gopinath IISc
Note Some of the photos or images are taken from sources on the web. I ack. specifically here: Trivedi, Visual Computer 1989 (for the temple images) Other images Chand Baori (stepwell), Abhaneri, Rajasthan Kandaariya mandir (Khajuraho): ASI monument number N-MP-15 Author:Kanika.mishra, 12 April 2015 Maadhava shloka Author: Doron, September 2003 Authors: K Ramasubrahmanyam, MD Srinivas Melakartas Author:Basavarajtalwar, 4 November 2009 Others inlined Happy to ack. any that have been missed!
Motivation A computational perspective on enquiry Mathematics/astronomy obvious Other areas of enquiry show substantial influence eg. (generative) linguistics music (raga simplistically a generative system over an alphabet with certain rules) architecture (space-filling curves, fractals, composition, juxtaposition) poetry (chandas, codes, binary notation) rasa theory ( state transition models?)
Computation Enquiry an Indic meme? द ग गण ण त क य drg.ganitaikya, the concordance between observed and the computed. Also, models useful but only contingent. Much earlier, Vrddha Garga (pre700 BCE?) says दर शर शन गण ण त च व य गपद य गस धकम (Observation and calculation when they go together is effective). Bhaaskara (11141185) from Karnataka Emphasized also in Kerala school of Mathematics
CS Two fundamental aspects develop techniques that make the elucidation of the computational structure of nature and the mind easier. create new computing algorithms and machines that have powerful cognitive and computational abilities: this includes development of new techniques of representing and manipulating knowledge, inference and deduction. Considered also by Grammarians Logicians However, some contemporary developments in formal logic, linguistics, and computer science a rediscovery of the work of these masters. Qn of a correct history of ideas Qn of significance to Sanskritists as well as cognitive and computer scientists: Are there other rules in ancient Indian logic and grammar that may be of use in making further advance in cognitive and computer sciences? [Bhate & Kak] Grammar ~ computation!
Composition/Iteration/Recursion Recursive nature of number system understood at least 2 millennia back एदश... = ए + द*10 + श*100... = ए + 10*(द + 10*(श+ )) A number s value is computable based on subnumbers within it Hence, mult/div algs developed then as we do them now Not avlbl in Greek/European system till Fibonacci introduced about 1200 CE from Indic sources Recursive nature of Sanskrit grammar much earlier (eg. Paanini) Numerical iteration Taitt. 1, 100,, 10^20 Buddhist counting: Lalitavistaara (koti 10^7 tallakshana 10^53) Jaina exampl: vargita-samvargita More interesting: iteration on algebraic forms! Jaina example: composition of exponentiation for fast growing functions Brahmagupta: composition of algebraic forms Bakshali: composition of algbraic formula for faster convergence: telescoping Convergent series for pi: iteration over algebraic structures for faster convergence
Invention of zero? Often Indians are said to have invented zero Poor way of explaining the actual contrib 1st stage: number concept (one, two, ) 2nd stage: notation: etc. 3rd stage: use of a base Egypt: symbols for 1, 10, 100, 1000, 10000, Greeks: To reduce many repeats, special symbols for 5, 50, 500,...: Romans: added subtractive principle: 9 = 10-1, 40=50-10, Ionians, Arabs, Hebrews: map numbers (1..9, 10, 20, 30,...) to alphabet 4th stage: China: 6705 => 6 (1000) 7(100) 5 (1) (abacus friendly) 123: (100) (10) (10) (1) (1) (1) Need special cases 5th stage: India: 6705! Mayan civ. had bases 20, 360! instead of 20, 400,...
Happines levels: त त तर य मन ष य 1१ मन षग ध वर व 100 १०० द वग धवर व 10000 १०^४ प त 10^6 १०^६ आज नज द व 10^8 १०^८ कर मर व द व 10^10 १०^१० द व 10^12 १०^१२ इन द र 10^14१०^१४ ब हस पत त 10^16 १०^१६ प रज पत त 10^18 १०^१८ (2^64=9223372036854775808) Approx 9*10^18. For a 64b machine,overflow here! ब रह म 10^20 १०^२०
Jainas... Vargita-samvargita (vs): Let x^x be x` (x`)` = (x^x)^(x^x). Example for x=2: First vs: 2` = 2^2 = 4 2nd vs: (2`)` = 4^4 = 2^8 = 256 3rd vs: ((2`)`)` = (2^8) ^ (2^8) = 256 ^ 256 4th? (((2`)`)`)` =? Jaganya-pariita-asamkyhaata Primitive recursive function (can be written using doloops with fixed bounds) but extremely fast growing approx. 10^260 digits! Knuth ( 76): a b = a^(a^(a^(a^(a^ )) b times; 617 digits! Needs around 2048+ bits! a b = a (a (a )) b times; similarly a b, etc. Primitive recursive! Ackerman s function (1928) First known non-primitive recursive function Cannot be realized with do loops
The Two A s of Computational Thinking (from J. Wing'06) Abstraction C.T. operates in terms of multiple layers of abstraction simultaneously C.T. defines the relationships the between layers Automation C.T. thinking: mechanizing abstraction layers and their relationships Mechanization: due to precise & exacting notations and models some machine below (human or computer, virtual or physical) Computational Thinking Abstraction, Mechanization, Recursion & Bootstrapping They give us the ability and audacity to scale. Interestingly, many of these handled in our tradition
Algorithmic Thinking Considerable tradition in India in ``algorithmic'' thinking, so can see many elements of an informal ``programming'' style written in cryptic Sanskrit. Examples Multiplication, div, sqroot,... kuttaka chakravala solutions of a knight's tour on 4x8 board given by Vedanta Desikan (13th c.) in ``Paaduka Sahasram'' Backtracking algs?
``From the system of nine heavens [marked] with nine figures [God] cast the Indian numerals onto the earth board'' Nizami(?-1203 CE) Persia pati-ganita (arithmetic; ``board-computations'' for the dust board, or sandbox: perms/combinations, quadratic eqns, summing series) vs bija-ganita (algebra; ``seed-computations'' for the manipulation of equations involving an unknown or bija: solving eqns up to 2nd order in 1+ unknowns, and indeterminate eqns of 1st and 2nd degree.) (from Ency. Brit.) Multiplication in India: ``Precursor'' to a Turing Machine?
Multiplication Align lsb of one (B:b1b2) with the msb of the other (A:a1a2a3)): b2 with a1 Multiply B and a1 Can rub a1 out! Carry? Extend to left & add! Shift B right Multiply B and a2 Carry? Add to prev existing A2 also gone Shift B right Multiply B and a3 a3 also gone but now result avlbl
Division/Sqroot Division considered simple and just assumed by Aaryabhata and other great mathematicians of that time In Europe division alg only about 10 centuries later based on the Indian methods Square roots use a division like method Odd places: varga, even places: avarga Cube roots too! Always divide the nonsquare (even) place by twice the square root [already found]. Having subtracted the square [of the quotient] from the square (odd) place, the quotient gives the [digit in the] next place in the square root
(Aryabhata s Root Extraction Methods Abhishek Parakh)
History of Generative Linguistics Only started around 1920's in the West Most forcefully by Chomsky in '50s Also directly inspired by Sanskrit Earlier western linguists due to their ignorance critiqued Paanini as being arcane, not realizing that a complete grammar of a sophisticated language needs many rules to capture it as complete as possible. We can now assert, with the power of hindsight, that Indian linguists in the fifth century B.C. knew and understood more than Western linguists in the nineteenth century A.D. Can one not extend this conclusion and claim that it is probable that Indian linguists are still ahead of their Western colleagues and may continue to be so in the next century? Quite possible; all we can say is that it is difficult to detect something that we have not already discovered ourselves. Frits Staal With CS, this aspect becoming clear. The very success of Asthadhyayi suggests that aspects of its structure will have implications for further advance in computer science, knowledge representation, and linguistics. [Bhate & Kak]
Some terms... भ वन (composition) प न करणम (iteration) प नर वर वर तर तनम (recursion) स ध रण करणम (generalization) अन व त त त त त (factoring) प रस त र (enumeration) नष टम उद द द द द ष ट न क Lookup and Indexing न त त न त न त (Diagonalization?)
Sqroot and approxs in Indic Tradition Possibly geometric methods (in Sulbasutra) Number theoretic and algorithmic methods of composition and recursion (bhaavanaa and chakravaala) Iteration on algebraic forms Bakshali Approx to pi
Sqroot(2) by श ल बक र (ब ध यन,...) 1.4142157 computed value with this approx 1.4142136 the actual value Connection with Vedic altars Seidenberg
Generalization of sqroot problem Solve N*y*y+1=x*x If N*y*y much larger than 1, then with an integer/rational solution for x, y, sqroot(n) = x/y For example for sqroot(2): 2*y*y+1=x*x say x betw 100 & 1000 for a desired accuracy sqroot(2) = 1.4142135623730951 2*2*2+1=3*3. Hence, 1st simple (non-)solution 3/2 (=1.5) Use composition (next slide!) to get 2*12*12+1=17*17. Hence 2nd (non-)solution 17/12 (=1.41666 ) Iterate one more time: 2*408*408+1=577*577. 3rd solution 577/408 (= 1.4142156862745099) Error about 2 parts in million Continued fraction form for sqrt(2): 1+1/2, 1+1/(2+1/(2+1/2)), 1+1/(2+1/(2+1/(2+1/(2+1/2))))
Composition and Recursion Composition: Brahmagupta s bhaavanaa Compose 2 algebraic forms to produce another Brahmagupta's identity: (x12-n*y12)(x22-n*y22) = (x1x2+ny1y2)2-n(x1y2+x2y1)2 Chakravaala: a recursive procedure based on bhaavanaa to solve N*y*y + 1 = x*x starting with simpler N*y*y+z=x*x
CALCULATING pi Claims of using octagondoubling or hexagon-doubling seem a bit doubtful as the computation is unstable julia> pisqrt(8) 3.141602510241972 julia> pisqrt(9) pi ~ (2**k)*side 3.1415951177183654 k increases and side decreases rapidly julia> pisqrt(10) function pisqrt(n) 3.1415932696317452 julia> pisqrt(11) a=1.0 3.1415928083796847 for i in 1:n julia> pisqrt(12) a = (1.0/a)*(sqrt(a*a + 1.0) - 1.0) end return (2^(n+1))*a*2 NEED BETTER METHODS! 3.141592690962969 julia> pisqrt(13) 3.141592675570453 julia> pisqrt(14) 3.1415926909629683
Recitation vakya, pada, krama, jata, mala, sikha, rekha, dhvaja, danda, ratha, ghana स ह ह त व क पद क रम: 12, 23, 34,... जट: 122112, 233223, 344334,... म ल श ख र ख ध वज द ड रथ घन: 1221123321123, 2332234432234,... Also क रमम ल and प ष पम ल 2(n-1) errors correctable in 4n symbols
Codes or Vikratis Kashyap/Bell formulate Krama-maala as a rate 1/4 linear block code over a finite Galois field Req why these specific codes? Preserve order of words Errors to be detected: Add/delete of a syllable/word in a word/sentence Avoid long jumps A (in verse x) similar to B (in verse y) ; Consider chanting of...ac... ;...BD... Problem: during chanting mistakenly...ad... or...bc... Handled by codes such as avichakra ratha (Kashyap) RV 1.1.1.... C ratnadhatamam (A) RV 1.20.1... E ratnadhatamah (B) D Chanting st A chained to C and B to E to prevent jump from C to B and E to A
Chand Baori (Rajasthan)
Kandaariya Mahadev
Melakarta scheme with Katapayaadi naming, indexing, lookup!
de Bruijn seqs यम त र जभ नसलग म 01110100 01 Earliest known de Bruijn (1946) seq (a memory wheel ): sequence of letters drawn from some alphabet such that every combination of n letters occurs exactly once if we allow wraparound (0 laghu 1 guru)
K.Trivedi: Hindu Temples: Models of a Fractal Universe, Visual Computer ( 89)
Dineshkannambadi
fractalization
Conclusions... A computational perspective helps understand Indic tradition in many disciplines A meme? Without this, it seems to be just a jumble of tricks as described by those outside the tradition.
Sanskrit World The extent and diversity of literature produced in Sanskrit, the long temporal span of its use, and the breadth of the use of the language throughout the Indian subcontinent and Southeast Asia are unparalleled. Indeed, extant literature in Sanskrit constitutes the largest body of literature in the world prior to the invention of the printing press Scharf/Heyman, Linguistic Issues in Encoding Sanskrit, 2012 Extant manuscripts in Sanskrit number over 30 million - one hundred times those in Greek and Latin combined - constituting the largest cultural heritage that any civilization has produced prior to the invention of the printing press. Pawan Goyal, Gérard Huet, Amba Kulkarni, Peter Scharf, Ralph Bunker, COLING 2012 30M manuscripts extant compared to 1/2M of Greek/Latin David Pingree s estimate; 10M-20M estimate more common Much of Sanskrit literature is non-religious Indic system was the most productive economic system till 1000CE when it was disrupted; same with S&T Indic science and mathematics needs to be properly assessed and made better known...