Transcript for:
5.7 Binary mathematics and combinatorial problems in Chandaḥ Śāstra

In this video we will see how a work which was done in second century BCE laid the foundations provided a lot of ideas about what you may call it as binary mathematics today in fact Pingala authored what is called Chanda Shastra he saw it in in a module on Vedic corpus. We saw Pingala's binary numbers and all that even in another module on number systems and so on. We are revisiting it now because here we will talk specifically about the binary mathematics and combinatorial problems. Earlier we just saw it as just how binary numbers are represented and so on. So that's what we will do now. Just to recollect, the meters in Sanskrit Chandas were analyzed by means of two kinds of syllables. One is Laghu and other is Guru from a prosody perspective. Any syllable meter, Varna Vrata, is characterized as a sequence of Laghus and Garhus in some ways. That's how finally a meter Chandas is formed. We saw some of them in the earlier videos. If we replace Laghu with 1 and Guru with 0, Then it transforms the metrical pattern into a binary sequence. That's what will happen actually. That's an interesting thing. What is a binary sequence? A binary sequence is a sequence composed of 1s or 0s. For example, if you say 1 0 0 1 or 0 1 0 0, these are examples of binary sequences of length 4. So a metrical structure can also be a binary sequence consisting of 0s and 1s. if we replace Laghu and Guru the way we have said. So that opens up a possibility of understanding whether binary mathematic ideas are there or not and that's what we actually are going to discuss here. So in chapter 8 of Chandrashtra, Pingala has analyzed a host of combinatorial problems relating to metrical patterns. And what it means is equivalently to the binary sequence because the metrical pattern is a binary sequence for us. So there are a few things that he has done, certain binary operations in Chandrashtra. Let me describe them. One is Prastara. Prastara is a procedure by which all possible metrical patterns or equivalently the binary sequences of a given length are generated sequentially as an array. What it means is if it is a three-digit, Then we are talking about 0 0 0, 0 0 1, 0 1 0, 0 1 1, 1 0 0, 1 0 1, 1 1 0 and 1 1 1. So you have a set now. There is an array of 8 numbers. So that procedure he has developed, that is called Prasthara. Then there is something called Sankhya. This is the process of finding the total number of binary sequences in a Prasthara. Then there is something called Nashta. What it means is for a given row number in an array, the process of identifying the corresponding binary sequence, what it means is, you know, if you have a four-digit binary number, then there are 16 possibilities are there. If you ask, what is the binary number on row 12? That is the question. Then he has developed a procedure called NASTA to find that. Now, there is something called UDHIShta, which is the reverse of it. If you give a binary sequence 1 0 0 0, then the question is where is this? In which row of this array it is there? So that is called a Udhishtha. So there is a procedure for that also. Then you have what is called Lagakriya. This is the process of finding the number of binary sequences in the array with a given number of 1's and 0's. So you know if you have 5 digit number 2 power 5, 32. or you know it's a eight digit then two power eight and so on then you have adva yoga the process of finding the space occupied by the array or the prasthara what you call it to determine the floor area needed so these kinds of operations are binary operations are available in chandashyatra so let us first start with this lagakriya or this this prastharas how these prastharas are created How this progressive generation of binary tables are made. So let us start with that first. So you have a pictorial representation of the issue here. Because the basic building block of binary analysis is the generation of these prastharas. So there are sutras 20 to 23 in chapter 8 of Chandrasastra which provides the details for the generation of the binary arrays. So let us start with it. The first set is 0 and 1, we all know. Just two rows and then arrays are 0 and 1. What it says is at every iteration, okay. The existing array is first replicated which means replicate 0 and 1. That's what we have done. You have replicated 0 and 1 and then add one more column. That's what it is saying. One more column to the replicated array. Fill the first set with 0 and the second set with 1. So now we have got the second array. You can repeat the same thing. Now this whole structure has been repeated twice here. You just see here. 0 0 1 0 0 1 1 1 repeated twice. One more column is added and then the first four are 0, the next four are 1. That is what it is saying. Now this whole thing has to be replicated. You see the whole thing has been replicated twice. Once here and once here and then add one more row. That is the algorithm. Then you populate the first half with 0 and the second half with 1. So one can keep on going like that. So this is exactly what is how the binary arrays are to be generated as per Pingala's algorithm that he has provided in his chapter 8 of Chandrashtra. Now let us understand this Nashta algorithm which means what is the binary sequence associated with a particular row number. And for the purpose of this illustration let us use a binary sequence of length 4 which means There are going to be 16 rows now because it is binary sequence of length 4. So let us see how to go about. So the algorithm says start with the desired row number, divide it by 2. If it is perfectly divisible, place 1 in the sequence. The number is not divisible by 2, place 0 in the sequence, add 1 to the number and divide and repeat the process until the binary sequence is obtained. So that is the algorithm. So let us see how the algorithm works now. So let us start with, we want to know what is the... binary sequence associated with row 13 that is what we are interested in now so as per this algorithm 13 is not divided by 2 so therefore we place a 0 in the sequence and when you divide it by 2 it doesn't work so add 1 to it becomes 14 so divided by 2 you get the number 7 now the algorithm continues 7 is again not usable by 2 so add another 0 because it is not usable by 2 add a 0 in the second digit Add a number to it so it becomes 8. 8 is divided by 2 we get the number 4. Now 4 is divided by 2. Since 4 is divided by 2 we place a sequence 1. The new number is 2 and the new number is also divisible by 2. So we place another number 1. So this is the binary sequence of the 4 digit number which will be available in row 13. So that is what Pingala is actually saying that the required sequence of length 4 is obtained. We stop the operation and so the answer to this question, what is the binary sequence in the 13th row 0011? So for the 13th row, we ask what is the sequence. So we progressively found 00111, although I wrote it from right to left. Actually, it should be written from left to right only. So finally, the answer is 0011 is the answer. And that is the binary sequence in the 13th row of this array. of a four digit binary sequence. So, that is what this algorithm is actually doing. Now, we will see the reverse problem and that is and that procedure is called Uddiyasta. That is, we start with the binary sequence and identify in which row this binary sequence is there. That is also an interesting problem which is the reverse of the earlier problem. So, let us try to understand how this algorithm works based on Pingala's algorithm. So, the procedure is as follows start with number 1. So, the current number is equal to 1 scanning the binary sequence from the right locate the first one in the sequence whenever you encounter the first one in the sequence multiply the current number by 2. So, the current number is 1 it will become 2 in case if you locate a number 1 move the next number to the left when a 1 is encountered double the current number if 0 is encountered double it and subtract 1 from it. So, that is the algorithm and continue till the end of the binary sequence. So, let us see how it works we will go by the steps of the algorithm. So, we want to understand what is the row number associated to this binary sequence. 0 1 1 so as per this algorithm we start with the number 1 so the first number is 1 therefore the current number is doubled as per this because we are going from right to left starting from the right only so the number will become 2 then we again move again there is a number 1 again a number 1 so there are 3 numbers which are followed one after another So, multiply it 3 times so 2 into 2 into 2 it becomes 8 that is where we are now we have reached 3 numbers now. Then the last number is 0 so what we do is we double it and then subtract it from 1 that is what the algorithm is saying double it and subtract 1 from it. So, we double 8 get it 16 subtract 1 from that 15. So now, we are saying this array 0 1 1 1 can be found in the 15th row. So, another interesting problem is to find out how many binary sequences of length n there are that contain r number of ones the remaining are 0. So, it becomes a combinatorial problem. Essentially, this boils down to a combinatorial problem of choosing r out of n which leads to actually the binomial coefficient ncr because here we want r number of ones out of the n number of the total length. So, it is basically we are asking for a binomial coefficient ncr. Pingala refers to this problem as Lagakriya. The procedure is best explained by Varnameru of Pingala. So, he has developed an algorithm for it. And let us see that algorithm of how to create that Pingala's Varnameru. So, what does it say? Start with a square. Place one there in the square. So, that is how we have started. We start with the first square. We have placed the 1 there. Then it says below this are successive rows with one more number of squares. So what it means is there is only one square here. So make two squares now. One more we have added. So that's what the step 2 is saying. Then it says the number to be placed inside any square is the sum of numbers contiguous to the square in the row above. So if you look at the row above, this is contiguous to this. So this number is 1. This is contiguous to this so this number is 1 so we have got 2 now we have got to the second row. Now add one more row by adding one more square so we have three squares now. You have come to the third stage now and use the same algorithm now. What is contiguous this is only this so you place a 1 here. This number is contiguous to both of these so that is why you have put the number 2 whereas this is contiguous to only this so we place the 1 here similarly what you see here. So, we have got now the third row is also in place. One can go on. So, let me demonstrate this for some more time. So, we have now come to the fourth. This is contiguous to it. This is contiguous to these two. This is contiguous to these two. This is contiguous to this. That is why you get 1331. Now, you have the fifth. This is contiguous to this. This is contiguous to these two. That is why the number 4 is coming. This is contiguous to these two. That's why number 6 is coming. This is contiguous to these two. That's why number 4 is coming. And this is contiguous to this. You get number 1. 5th row is done. Similarly, you get the 6th row. So, this is the algorithm, Lagacria algorithm, which Pingala talked about. Now, the same triangle of binomial coefficients was rediscovered by the French mathematician Pascal in 1655 CE. This is 2nd century BCE. We are talking about 1655 CE, a good 1800 years between these two. That's what we are talking about actually. So, therefore, you know, we all have learnt it as Pascal's triangle. Pingala's Lagakriya is nothing but a mechanism to generate the Pascal triangle. In fact, Varaha Mihira's Brihasa Mita, which is 550 CE, mentions 18820 different combinations that can be obtained by choosing ... four perfumes from a set of 16 basic perfumes. It is actually 16C4, which is 1820. So, these permutation combination, these kinds of things were all addressed fairly well by the ancient Indian mathematicians. What we know as Pascal triangle is because we never knew Pingala. So, today maybe we have to call it as Pingala's triangle or Varna Meru, as he calls it, which is exactly this generation of the binomial coefficients that... the ncr that we need as we keep increasing the n progressively so this is all about binary mathematics that the rudiments and the building blocks of binary mathematics that we see in pingalas chandashastra which is a second century bce world now we will conclude this discussion on mathematics with one more module which is on this very interesting idea of magic squares so we will see that as a last piece in this discussion on mathematics Thanks