Prasanna mentioned to me that there are 34,776 theoretically possible *janya ragas* in the South Indian melakarta system and he asked if I could see how that number arises. I looked into the question and thought I’d post the details here for anyone who’s interested.

Recall that a janya raga is one that is somehow *derived* from one of the 72 melakarta ragas. The 34,776 figure refers to one specific class of janya ragas: those that are created by *omitting* notes from the parent. In forming such “varja” ragas, we can omit up to two notes from the arohanam (ascent), the avarohanam (descent), or both. (And it’s permissible to omit *different* notes in the ascent from those we omit in the descent.) We can’t apply other processes of derivation like reordering notes or borrowing notes from other ragas: these processes lead to many more possibilities!

So where does the number 34,776 come from? Well, if we decide to omit one note from the arohanam of a melakarta raga, there are 6 ways to do it: any note besides sa is fair game for omission. If we’re going to omit two notes, there are (6 choose 2) = 15 possibilities. And of course, if we omit no notes, there’s only 1 way to do that. This gives 6+15+1=22 options. The same 22 options exist for the avarohanam, giving 22*22=484 ways of omitting notes from a parent raga to create a janya. Except, we don’t want to count the case where no notes are omitted in the arohanam and the avarohaman both, because this leaves us with the original raga. So, the total number of janya possibilities for each melakarta raga is actually 484-1 = 483. Multiplying this by the total number of melakarta ragas, we get 483*72 = **34,776**. But there’s a catch…

The process of omitting notes from two distinct parent ragas can give us *two janya ragas with the same notes*. For example, we can get S R2 G3 P D2 (Mohanam), by omitting M1 and N2 from S R2 G3 M1 P D2 N2 (Harikambhoji), or by omitting M2 and N3 from S R2 G3 M2 P D2 N3 (Kalyani). In Western terms, one would say you can get 1 2 3 5 6 (major pentatonic) by omitting 4 and b7 from 1 2 3 4 5 6 b7 (Mixolydian) or by omitting #4 and 7 from 1 2 3 #4 5 6 7 (Lydian). So, the 34,776 figure contains many janya ragas that actually have identical swaras. Now, if the parent raga (including its mood, characteristic phrases, ornamentation patterns, and additional swaras) is kept in mind when performing the derived raga, then two ragas derived from different parents might be perceived as distinct even though the derived ragas happen to have the same notes. In this way of looking at raga derviation, 34,776 is a plausible theoretical count. However, if we’re only interested in janya possibilities that are *distinct in their notes*, and we’re not considering attachments to parent ragas, then 34,776 is an overcount.

Enumerating the janya possibilities that are note-wise distinct is more complicated. The rest of the post describes an approach I came up with when I first started thinking about the problem. After I published the post, I received a comment from Narayana Santhanam pointing out that the technique of generating functions from enumerative combinatorics is another, more compact approach to counting janyas; and, in searching further, I found a 2002 paper by K. Balasubramanian that uses this approach. Finally, I learned that P. Sriram and V. N. Jambunathan had investigated this question and published similar findings in a 1991 paper in the Journal of the Madras Music Academy. (See the notes and comments at the end of this post for more details.) Although the approach I present here is more verbose than some of the others, I hope it will be interesting to readers looking for insight into how all the possibilities arise.

In what follows, I assume R2=G1, R3=G2, D2=N1, and D3=N2 even though one could say those swaras would be performed with different ornamentation and/or intonation. In this count, for example, an arohanam of S R2 M1 P D2 S will be considered equivalent to S G1 M1 P D2 as since we treat R2=G1.

To organize our count, we’ll consider *how many notes occur in the union of the ascent and the descent* of a janya raga. This union might have 5, 6 or 7 notes.

If the **union contains 5 notes**, then the ascent and descent must contain those same 5 notes. To find the number of janya ragas of this kind, we need to consider all the ways of choosing 4 notes from 11 possibilities without violating the melakarta rules. Note that we’re choosing 4 notes out of 11, not 5 out of 12, because one note, sa, is mandated. Unfortunately, we can’t use a simple formula for (11 choose 4) because this would count “illegal” cases where there are two ma’s, or where there are more than two notes betwen sa and ma. One way to count only the legal possibilities is to divide the scale above sa into four sections. The first section contains ri and ga. The second section contains ma. The third section contains pa. The fourth section contains da and ni. Now there are 6 ways of filling the first section (i.e. ri and ga can be R1/G1, R1/G2, R1/G3, R2/G2, R2/G3, or R3/G3), two ways of filling the second section (i.e. ma can be M1 or M2), one way of filling third section (pa is always Pa), and six ways of filling the fourth section. (This is how we get 6*2*1*6 = 72 melakarta ragas.) If we omit some notes, then one or more of the scale sections will no longer be full. (In particular, if the first section has only one note in it, there are 4 possibilities for its identity: R1, R2=G1, R3=G2, or G3.) If we write 2|1|1|2 to indicate a scale with all sections full, then here are the possibilities distributions of sections sizes for a five-note derived scale where the sections are not all full: 2|1|1|0, 2|0|1|1, 2|0|0|2, 2|1|0|1, 1|1|1|1, 1|0|1|2, 1|1|0|2, 0|1|1|2. Taking this list and substituting the sections sizes with the number of ways of filling each section to the designated size, we get the following count: 6*2*1*1 + 6*1*1*4 + 6*1*1*6 + 6*2*1*4 + 4*2*1*4 + 4*1*1*6 + 4*2*1*6 + 1*2*1*6 = **236**.

Now if the **union of the ascent and descent contains 6 notes**, the respective sizes of the ascent/descent might be 6/6, 5/6, 6/5, or 5/5. The **6/6 case** is similar to above: we know the ascent and descent use the same six notes, and we need to consider the number of ways of choosing 5 out of 11 notes without violating the melakarta rules. Following the logic above, the possible distributions of section sizes are 1|1|1|2, 2|0|1|2, 2|1|0|2, and 2|1|1|1. This gives 4*2*1*6 + 6*1*1*6 + 6*2*1*6 + 6*2*1*4 = **204** possibilities. In the **5/6 or 6/5 case**, we can see that side containing 5 notes must be a proper subset of the side containing 6. The number of possibilities here can be calculated as (# ways of choosing 5 out of 11 notes legally)*(# ways of removing one of those 5 notes to create the smaller side) = 204*5 = 1020. Since we can make the smaller side the ascent or the descent, we multiply the last figure by two, giving **2040**. Finally, in the **5/5 case**, we can see that the ascent and descent must share precisely 4 notes including sa (each side contains a note that’s not in the other, creating a union of size 6). The number of possibilities can be calculated as (# ways of choosing 5 out of 11 notes legally, to create the 6-note union including Sa)*(# ways of picking 3 notes from those 5 to be shared by the ascent and descent)*(# ways of picking one of the remaining 2 notes to be in the ascent, while the other goes in the descent) = 204*(5 choose 3)*2 = **4080**.

The last situation is where the **union of the ascent and descent contains 7 notes**. Here, the respective sizes of the ascent/descent might be 5/5, 6/5, 5/6, 6/6, 5/7, 7/5, 6/7, or 7/6. In the **5/5 case**, the intersection must contain 3 notes. The number of possibilities is: (# of ways of choosing 6 out of 11 notes following the melakarta rules, to create a 7-note parent raga including Sa)*(# ways of choosing 2 out of those 6, to create a 3-note intersection including Sa)*(# ways of picking two from outside the intersection to be in the ascent, while the other 2 go in the descent) = 72*(6 choose 2)*(4 choose 2) = 72*15*6 = **6480**. In the **5/6 or 6/5 case**, the intersection is size 4, and we can choose 3 out of six notes to form it. By similar logic to the previous case, the number of possibilities is 72*(6 choose 3)*(3 choose 2) = 72*20*3 = **4320 for each case by itself**. In the **6/6 case** the intersection must be size 5, and the number of possibilities is 72*(6 choose 4)*2 = 72*15*2 = **2160**. In the **5/7 and 7/5 cases**, the smaller side of the scale must be a proper subset of the larger one, and we can form the smaller side by omitting two out of six notes from the larger. This gives 72*(6 choose 2) = **1080 possibilities for each case**. And in the **6/7 and 7/6 cases**, the smaller side again must be a proper subset of the larger one, so the number of possibilities is 72*(6 choose 1) = **432 for each case**.

Here’s a recap of the cases we considered and the possibilities that exist in each case:

**Union size 5.** Case 5/5: 236 possibilities.

**Union size 6.** Case 6/6: 204 possibilities. Cases 5/6 and 6/5: 2040 possibilities together. Case 5/5: 4080 possibilities.

**Union size 7.** Case 5/5: 6480 possibilities. Cases 5/6 and 6/5: 8640 possibilities together. Case 6/6: 2160 possibilities. Cases 5/7 and 7/5: 2160 possibilities together. Cases 6/7 and 7/6: 864 possibilities together.

The grand total is 236+204+2040+4080+6480+8640+2160+2160+864= **26864**.

Now, how can we be sure that 26864 correct? In fact, I made many calculation errors as I was working through this the first time, leaving me in a state of great suspicion. However, after I spotted and corrected my mistakes, I gained further confidence by writing a Groovy script that generates all distinct janya possibilities by brute force, and also yields… 26864! (Warning: this is script-style code, meant for one-time use and not designed to be maintainable or easy to read, but it gets the job done.)

[code language=“groovy”] // this script is written in Groovy 2.1.0

// generate all melakarta ragas, representing each // raga as a list of 11 ones and zeros melakartas = [] for (riGa in [1,1,0,0].permutations()) { for (ma in [0,1].permutations()) { for (daNi in [1,1,0,0].permutations()) { melakartas.add(riGa + ma + [1] + daNi) } } } assert melakartas.size()==72

// generate all ways of deleting up to two notes from // the ascent and descent of a raga deletions = ([0..5,0..5].combinations()).collect( {it as Set} ) as Set deletions.add([]) deletionPairs = [deletions,deletions].combinations() deletionPairs.remove([[],[]])

// generate all possible janyas as ascending/descending scale pairs, // by applying all possible deletions to each melakarta raga; // keep the janyas in a set so that identical janyas will // not be double-counted janyas = [] as Set for (mela in melakartas) { def noteIndices = (0..(mela.size()-1)).findAll({mela[it]==1}) for (deletionPair in deletionPairs) { def ascending = mela.clone() def descending = mela.clone() deletionPair[0].each { ascending[noteIndices[it]]=0 } deletionPair[1].each { descending[noteIndices[it]]=0 } janyas.add([ascending, descending]) } }

println “Number of Distinct Janyas: ${janyas.size()}” [/code]

**Notes:**

How many Janya ragas have actually been named and used in Carnatic music? I came across Raga Pravaham, a wonderful reference by musician, composer and musicologist D. Pattammal—the work includes over 5000 named ragas. At the end of the text, there is an appendix that places the number of janya possibilities at 126936, without eliminating duplicates. This count is so much larger than 34776 because it uses a looser definition of permissible janyas in which up to *five* notes may be deleted from the arohanam, avarohanam, or both.

See the comments by Narayana Santhanam below for an approach to counting janya ragas using generating functions. Also see Combinatorial Enumeration of Ragas by K. Balasubramanian, published in Journal of Integer Sequences Vol. 5, 2002 and How Many Janya Ragas Are There? by P. Sriram and V. N. Jambunathan in the Journal of the Madras Music Academy, 1991, pp. 144-155. See also a discussion of this topic at rasikas.org. ■