Mathematical algorithms in prosody and music treatises

François Patte

Université Paris Descartes

Kyoto University September 2009

Paris Descartes Mathematical algorithms 14th WSC – September 2009 1/19 1, 2, 3, 6, 10, 19, 33, 60, 106, 191, 340, 610, ···

Paris Descartes Mathematical algorithms 14th WSC – September 2009 2/19 The sources

S´ar¯ ngadeva:˙ Sam. g¯ıtaratnakara¯ (13th century) Chapter five: Tal¯ adhyaya¯

Paris Descartes Mathematical algorithms 14th WSC – September 2009 3/19 The sources

S´ar¯ ngadeva:˙ Sam. g¯ıtaratnakara¯ (13th century) Chapter five: Tal¯ adhyaya¯

Com.: Kalanidhi¯ by Kallinatha¯ (15th century) (ed. Anand¯ ¯srama´ – 1896 and Adyar – 1951) Sudhakara¯ by Sim. habhup¯ ala¯ (14th century) (ed. Adyar – 1951)

Paris Descartes Mathematical algorithms 14th WSC – September 2009 3/19 Notations

druta o unit of measure semi-short laghu I = 2 druta ♩ short guru S = 2 laghu = 4 druta long pluta S` = 3 laghu = 6 druta · protracted

Paris Descartes Mathematical algorithms 14th WSC – September 2009 4/19 The prastara¯ algorithm

Prastara¯

How to build exhaustively all variations (bheda) for one musical measure of a given length.

Paris Descartes Mathematical algorithms 14th WSC – September 2009 5/19 The prastara¯ algorithm

Prastara¯

How to build exhaustively all variations (bheda) for one musical measure of a given length.

Example: o S ( ) I I o (♩♩ ) o I o o ( ♩ ) o o o o o ( ) Four variations for a five druta (o, ) measure

Paris Descartes Mathematical algorithms 14th WSC – September 2009 5/19 The prastara¯ algorithm Rule

nyasyalpam¯ ady¯ an¯ mahato ’dhastac¯ ches.am. yathopari prag¯ une¯ vamasam¯ . stham¯ . s tu sam. bhave mahato likhet alpan¯ asam. bhave tala-¯ purtyai¯ bhuyo¯ ’py ayam. vidhih. sarvadrutavadhih¯ . karyah¯ . prastaro¯ ’yam. laghau gurau plute vyaste samaste na tu vyaste drute ’sti sah.

A smaller one being set down under the first greater one, what is left is as above. If there is a deficiency in the opposite way, in order to complete the measure, one will write greater ones on the left, if possible; if impossible, smaller ones. This rule, the end of which is [a musical measure] wholly [made of] drutas, must be carried out many times.

Paris Descartes Mathematical algorithms 14th WSC – September 2009 6/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

o S 5

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

A smaller one being set down under the first greater one, what is left is as above.

o S 5

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

A smaller one being set down under the first greater one, what is left is as above.

o S 5 I 2

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

If there is a deficiency in the opposite way, in order to complete the measure, one will write greater ones on the left, if possible; if impossible, smaller ones.

o S 5 I 2

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

If there is a deficiency in the opposite way, in order to complete the measure, one will write greater ones on the left, if possible; if impossible, smaller ones.

o S 5 o I I 5

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

This rule, the end of which is [a musical measure] wholly [made of] drutas, must be carried out many times.

o S 5 o I I 5

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

A smaller one being set down under the first greater one, what is left is as above.

o S 5 o I I 5 o 1

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

A smaller one being set down under the first greater one, what is left is as above.

o S 5 o I I 5 o I 3

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

If there is a deficiency in the opposite way, in order to complete the measure, one will write greater ones on the left, if possible; if impossible, smaller ones.

o S 5 o I I 5 o I 3

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

If there is a deficiency in the opposite way, in order to complete the measure, one will write greater ones on the left, if possible; if impossible, smaller ones.

o S 5 o I I 5 I o I 5

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm Example: five druta prastara¯ o I = 2 o S = 4 o S` = 6 o

This rule, the end of which is [a musical measure] wholly [made of] drutas, must be carried out many times.

o S 5 o I I 5 I o I 5 o o o I 5 S o 5 I I o 5 o o I o 5 o I o o 5 I o o o 5 o o o o o 5

Paris Descartes Mathematical algorithms 14th WSC – September 2009 7/19 The prastara¯ algorithm One to seven druta prastaras¯ o S` o I S I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 8/19 The sam. khya¯ algorithm

Sam. khya¯ Counting

Or how to count the number of variations (bheda) built with the prastara¯ .

Paris Descartes Mathematical algorithms 14th WSC – September 2009 9/19 The sam. khya¯ algorithm Rule

ekadvyankau˙ kraman¯ nyasya yuñj¯ıtantyam¯ . puratanaih¯ . dvit¯ıyaturyas.as.t.ha¯nkair˙ abhave turyas.as.t.hayoh. tr.t¯ıyapañcama¯nk˙ abhy¯ am¯ . kramat¯ tam. yogam agratah. likhed daks.in. asam. sthaivam anka˙ sren´ .¯ıvidh¯ıyate

Having laid down successively the numbers one and two, the last one is added, as far as possible, to the second, the fourth and the sixth preceeding numbers; in the absence of the fourth and sixth numbers, to the third and fifth ones. One will write this sum gradually in the beginning. A sequence of numbers standing together on the right is thus established.

Paris Descartes Mathematical algorithms 14th WSC – September 2009 10/19 The sam. khya¯ algorithm Rule

Having laid down successively the numbers one and two, the last one is added, as far as possible, to the second, the fourth and the sixth preceeding numbers; in the absence of the fourth and sixth numbers, to the third and fifth ones. One will write this sum gradually in the beginning. A sequence of numbers standing together on the right is thus established.

1, 2, 3, 6, 10, 19,

Paris Descartes Mathematical algorithms 14th WSC – September 2009 11/19 The sam. khya¯ algorithm Rule

Having laid down successively the numbers one and two, the last one is added, as far as possible, to the second, the fourth and the sixth preceeding numbers; in the absence of the fourth and sixth numbers, to the third and fifth ones. One will write this sum gradually in the beginning. A sequence of numbers standing together on the right is thus established.

1, 2, 3, 6, 10, 19,

Paris Descartes Mathematical algorithms 14th WSC – September 2009 11/19 The sam. khya¯ algorithm Rule

Having laid down successively the numbers one and two, the last one is added, as far as possible, to the second, the fourth and the sixth preceeding numbers; in the absence of the fourth and sixth numbers, to the third and fifth ones. One will write this sum gradually in the beginning. A sequence of numbers standing together on the right is thus established.

1, 2, 3, 6, 10, 19,

Paris Descartes Mathematical algorithms 14th WSC – September 2009 11/19 The sam. khya¯ algorithm Rule

Having laid down successively the numbers one and two, the last one is added, as far as possible, to the second, the fourth and the sixth preceeding numbers; in the absence of the fourth and sixth numbers, to the third and fifth ones. One will write this sum gradually in the beginning. A sequence of numbers standing together on the right is thus established.

1, 2, 3, 6, 10, 19,

Paris Descartes Mathematical algorithms 14th WSC – September 2009 11/19 The sam. khya¯ algorithm Rule

Having laid down successively the numbers one and two, the last one is added, as far as possible, to the second, the fourth and the sixth preceeding numbers; in the absence of the fourth and sixth numbers, to the third and fifth ones. One will write this sum gradually in the beginning. A sequence of numbers standing together on the right is thus established.

1, 2, 3, 6, 10, 19,

Paris Descartes Mathematical algorithms 14th WSC – September 2009 11/19 The sam. khya¯ algorithm Rule

Having laid down successively the numbers one and two, the last one is added, as far as possible, to the second, the fourth and the sixth preceeding numbers; in the absence of the fourth and sixth numbers, to the third and fifth ones. One will write this sum gradually in the beginning. A sequence of numbers standing together on the right is thus established.

1, 2, 3, 6, 10, 19, 33,

Paris Descartes Mathematical algorithms 14th WSC – September 2009 11/19 The sam. khya¯ algorithm Rule

Having laid down successively the numbers one and two, the last one is added, as far as possible, to the second, the fourth and the sixth preceeding numbers; in the absence of the fourth and sixth numbers, to the third and fifth ones. One will write this sum gradually in the beginning. A sequence of numbers standing together on the right is thus established.

1, 2, 3, 6, 10, 19, 33, 60, 106, 191, 340, 610, ···

Paris Descartes Mathematical algorithms 14th WSC – September 2009 11/19 Explanation for the sam. khya¯ algorithm Some mathematics

Problem: how to count all the possible ways to split a given musical measure lasting 7 drutas into a combination of the four note values: druta, laghu (=2d.), guru (=4d.) and pluta (=6d.).

Paris Descartes Mathematical algorithms 14th WSC – September 2009 12/19 Explanation for the sam. khya¯ algorithm Some mathematics

Problem: how to count all the possible ways to split a given musical measure lasting 7 drutas into a combination of the four note values: druta, laghu (=2d.), guru (=4d.) and pluta (=6d.).

Mathematical point of view: how to count all possible ways to write a given number (7) as a sum of the integers: 1, 2, 4 and 6 (partitions of the integer 7).

Paris Descartes Mathematical algorithms 14th WSC – September 2009 12/19 Explanation for the sam. khya¯ algorithm Some mathematics

Problem: how to count all the possible ways to split a given musical measure lasting 7 drutas into a combination of the four note values: druta, laghu (=2d.), guru (=4d.) and pluta (=6d.).

Mathematical point of view: how to count all possible ways to write a given number (7) as a sum of the integers: 1, 2, 4 and 6 (partitions of the integer 7).

7 = 1 + 2 + 4 = 6 + 1 = 1 + 1 + 1 + 2 + 1 + 1 = ···

Paris Descartes Mathematical algorithms 14th WSC – September 2009 12/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I 7 = x + ··· + 1 o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I 7 − 1 = x + ··· o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I u7 = u6 + o o o I I S o I I I o I 7 − 1 = x + ··· o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I u7 = u6 + o o o I I S o I I I o I 7 = x + ··· + 2 o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I u7 = u6 + u5 + o o o I I S o I I I o I 7 − 2 = x + ··· o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I u7 = u6 + u5 + o o o I I S o I I I o I 7 = x + ··· + 4 o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I u7 = u6 + u5 + u3 + o o o I I S o I I I o I 7 − 4 = x + ··· o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I u7 = u6 + u5 + u3 + o o o I I S o I I I o I 7 = x + ··· + 6 o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I u7 = u6 + u5 + u3 + u1 o o o I I S o I I I o I 7 − 6 = x + ··· o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Explanation for the sam. khya¯ algorithm o S` o I S o = 1 I = 2 S = 4 S` = 6 I o S o o o S o S I o I I I I o I I u7 = u6 + u5 + u3 + u1 o o o I I S o I = + + + I I o I un un−1 un−2 un−4 un−6 o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I o o I I o o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o S o o S o o o I I o I I o o I I o o I o I I o I o I o I o o o o o I o o o I o o o o I o o S S o S o o S o o o II I I o I I o o I I o o o o o I o o I o o o I o o o o I o o o o I o I o o I o o o I o o o o I o o o o I I o I o o I o o o I o o o o I o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 1 2 3 4 5 6 7

Paris Descartes Mathematical algorithms 14th WSC – September 2009 13/19 Nas. .ta

Nas.t.a Disappearance

Or how to retrieve a deleted line in the prastara¯

Paris Descartes Mathematical algorithms 14th WSC – September 2009 14/19 Nas. .ta The lexicographic order Some mathematics

Order allowing to compare words, using an ordered alphabet: a < b < c < ··· < y < z

Paris Descartes Mathematical algorithms 14th WSC – September 2009 15/19 Nas. .ta The lexicographic order Some mathematics

Order allowing to compare words, using an ordered alphabet: a < b < c < ··· < y < z Words are compared letter by letter in the same position.

Paris Descartes Mathematical algorithms 14th WSC – September 2009 15/19 Nas. .ta The lexicographic order Some mathematics

Order allowing to compare words, using an ordered alphabet: a < b < c < ··· < y < z Words are compared letter by letter in the same position.

A word B is greater than a word A if:

Paris Descartes Mathematical algorithms 14th WSC – September 2009 15/19 Nas. .ta The lexicographic order Some mathematics

Order allowing to compare words, using an ordered alphabet: a < b < c < ··· < y < z Words are compared letter by letter in the same position.

A word B is greater than a word A if: ◮ There is a letter in B greater than a letter in A in the same position, ◮ Letters before that position are the same in B and A, ◮ Whatever the letters after this position are.

Paris Descartes Mathematical algorithms 14th WSC – September 2009 15/19 Nas. .ta The lexicographic order Some mathematics

Order allowing to compare words, using an ordered alphabet: a < b < c < ··· < y < z Words are compared letter by letter in the same position.

A word B is greater than a word A if: ◮ There is a letter in B greater than a letter in A in the same position, ◮ Letters before that position are the same in B and A, ◮ Whatever the letters after this position are.

Paris Descartes Mathematical algorithms 14th WSC – September 2009 15/19 Nas. .ta The lexicographic order Some mathematics

Order allowing to compare words, using an ordered alphabet: a < b < c < ··· < y < z Words are compared letter by letter in the same position.

A word B is greater than a word A if: ◮ There is a letter in B greater than a letter in A in the same position, ◮ Letters before that position are the same in B and A, ◮ Whatever the letters after this position are.

Paris Descartes Mathematical algorithms 14th WSC – September 2009 15/19 Nas. .ta The lexicographic order Some mathematics

Order allowing to compare words, using an ordered alphabet: a < b < c < ··· < y < z Words are compared letter by letter in the same position.

A word B is greater than a word A if: ◮ There is a letter in B greater than a letter in A in the same position, ◮ Letters before that position are the same in B and A, ◮ Whatever the letters after this position are.

a**** ≺ b**** ≺···≺ g**** ≺···

Paris Descartes Mathematical algorithms 14th WSC – September 2009 15/19 Nas. .ta The lexicographic order Some mathematics

Order allowing to compare words, using an ordered alphabet: a < b < c < ··· < y < z Words are compared letter by letter in the same position.

A word B is greater than a word A if: ◮ There is a letter in B greater than a letter in A in the same position, ◮ Letters before that position are the same in B and A, ◮ Whatever the letters after this position are.

a**** ≺ b**** ≺···≺ g**** ≺··· alpha ≺ alphabet ≺ alphabetic ≺ alphabetical ≺ alphabetize

Paris Descartes Mathematical algorithms 14th WSC – September 2009 15/19 Nas. .ta Prastaras¯ are lexicographically ordered Some mathematics

In our case, the ordered alphabet is: o < I < S < S`

Paris Descartes Mathematical algorithms 14th WSC – September 2009 16/19 Nas. .ta Prastaras¯ are lexicographically ordered Some mathematics

In our case, the ordered alphabet is: o < I < S < S`

Reading each "word" from right to left: ooooooo ≺ Iooooo ≺ oIoooo ≺···≺ oS`

Paris Descartes Mathematical algorithms 14th WSC – September 2009 16/19 Nas. .ta Prastaras¯ are lexicographically ordered

o S` Some mathematics o I S I o S o o o S o S I o I I I I o I I o o o I I S o I In our case, the ordered alphabet is: I I o I o o I o I ` o I o o I o < I < S < S I o o o I o o o o o I S` o Reading each "word" from right to left: I S o o o S o ooooooo ≺ Iooooo ≺ oIoooo ≺···≺ oS` S I o I I I o o o I I o o I o I o and from bottom to top: I o o I o o o o o I o o S o o o I I o o I o I o o o o o I o o S o o o I I o o o o o I o o o o I o o o o I o o o o o o o o o o o o

Paris Descartes Mathematical algorithms 14th WSC – September 2009 16/19 Nas. .ta Application to the nas. .ta

o S` o I S I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` o I S o o o S o S I o I I I o ? ? ? ? ? ? 20 o I o I o I o o I o o o o o I o o S o o o I I o o I o I o o o o o I o o S o o o I I o o o o o I o o o o I o o o o I o o o o o o o o o o o o

Paris Descartes Mathematical algorithms 14th WSC – September 2009 17/19 Nas. .ta Application to the nas. .ta

o S` o I S 1, 2, 3, 6, 10, 19, 33 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` o I S o o o S o S I o I I I o ? ? ? ? ? ? 20 o I o I o I o o I o o o o o I o o S o o o I I o o I o I o o o o o I o o S o o o I I o o o o o I o o o o I o o o o I o o o o o o o o o o o o

Paris Descartes Mathematical algorithms 14th WSC – September 2009 17/19 Nas. .ta Application to the nas. .ta

o S` o I S 1, 2, 3, 6, 10, 19, 33 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` o I S o o o S o S I o I I I o ? ? ? ? ? ? 20 o I o I o I o o I o o o o o I o o S o o o I I o o I o I o o o o o I o o 33 − 20 = 13 S o o o I I o o o o o I o o o o I o o o o I o o o o o o o o o o o o

Paris Descartes Mathematical algorithms 14th WSC – September 2009 17/19 Nas. .ta Application to the nas. .ta

o S` o I S 1, 2, 3, 6, 10, 19, 33 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` o I S o o o S o S I o I I I o ? ? ? ? ? ? 20 o I o I o I o o I o o o o o I o o S o o o I I o o I o I o o o o o I o o 33 − 20 = 13 < 19 S o o o I I o o o o o I o o o o I o o o o I o o o o o o o o o o o o

Paris Descartes Mathematical algorithms 14th WSC – September 2009 17/19 Nas. .ta Application to the nas. .ta

o S` o I S 1, 2, 3, 6, 10, 19, 33 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` o I S o o o S o S I o I I I o ????? o 20 o I o I o I o o I o o o o o I o o S o o o I I o o I o I o o o o o I o o 33 − 20 = 13 < 19 S o o o I I o o o o o I o o o o I o o o o I o o o o o o o o o o o o

Paris Descartes Mathematical algorithms 14th WSC – September 2009 17/19 Nas. .ta Application to the nas. .ta

o S` o I S 1, 2, 3, 6, 10, 19 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o SI S I o III I I I o o o I I ????? o 20 o I o I o I o I o I o o I I o o I o o o o o I o o o o I o o S o o S o o o I I o o I I o o I o I o I o I o o o o o I o o o o I o o 33 − 20 = 13 < 19 S o o S o o o I I o o I I o o o o o I o o o o I o o o o I o o o o I o o o o I o o o o I o o o o o o o o o o o o o o o o o o

Paris Descartes Mathematical algorithms 14th WSC – September 2009 17/19 Nas. .ta Application to the nas. .ta

o S` o I S 1, 2, 3, 6 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o S SI S I o II III I I I o o o I o o I I ???? I o 20 o I o o I o I o I o I o I o o I o o I I o o I o o o o o o o o o I o o o o I o o S o o S o o o I I o o I I o o I o I o I o I o o o o o I o o o o I o o 33 − 20 = 13 < 19 S o o S o o o I I o o I I o o o o o I o o o o I o o o o I o o o o I o o o o I o o o o I o o o o o o o o o o o o o o o o o o

Paris Descartes Mathematical algorithms 14th WSC – September 2009 17/19 Nas. .ta Application to the nas. .ta

o S` o I S 1, 2 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o S SI S I o I II III I I I o o o o o I o o I I ??? I I o 20 o I o o I o I o I o I o I o o I o o I I o o I o o o o o o o o o I o o o o I o o S o o S o o o I I o o I I o o I o I o I o I o o o o o I o o o o I o o 33 − 20 = 13 < 19 S o o S o o o I I o o I I o o o o o I o o o o I o o o o I o o o o I o o o o I o o o o I o o o o o o o o o o o o o o o o o o

Paris Descartes Mathematical algorithms 14th WSC – September 2009 17/19 Nas. .ta Application to the nas. .ta

o S` o I S 1, 2 I o S o o o S o S I o I I I I o I I o o o I I S o I I I o I o o I o I o I o o I I o o o I o o o o o I S` S` o IS I S o o o S o o S o S SI S I o I II III I I I o o o o o I o o I I o o I I o 20 o I o o I o I o I o I o I o o I o o I I o o I o o o o o o o o o I o o o o I o o S o o S o o o I I o o I I o o I o I o I o I o o o o o I o o o o I o o 33 − 20 = 13 < 19 S o o S o o o I I o o I I o o o o o I o o o o I o o o o I o o o o I o o o o I o o o o I o o o o o o o o o o o o o o o o o o

Paris Descartes Mathematical algorithms 14th WSC – September 2009 17/19 Paris Descartes Mathematical algorithms 14th WSC – September 2009 18/19 References

Sam. g¯ıtasiroman´ . i ed. & trad.: Emmie te Nijenhuis E.J. Brill – Leiden, 1992 The Chhandas Shâstra Pingala˙ Tukârâm Jâvajî – Bombay, 1908

Vr.ttaratnakara¯ Kedarabhat¯ .t.a The Nirn. aya-Sâgara Press – Bombay, 1890 generatingfunctionology Herbert S. Wilf – University of Pennsylvania Academic Press, Inc. 1994 Recursion and Combinatorial Mathematics in Chandashastra¯ Amba Kulkarni – Department of Sanskrit Studies, University of Hyderabad Hyderabad – 2008 Permutations with strongly restricted displacements D. H. Lehmer Proc. Colloq., Balatonfured, 1969 (pp. 755-770) Fast Algorithms For Generating Integer Partitions Antoine Zoghbiu & Ivan Stojmenovicb’ Computer Science Department, SITE, University of Ottawa, 1998

Paris Descartes Mathematical algorithms 14th WSC – September 2009 19/19