Janya Ragas: 34,776 or 26,864?

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.)

// 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
deletionPairs = [deletions,deletions].combinations()

// 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()}"


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

16 thoughts on “Janya Ragas: 34,776 or 26,864?

  1. Why is there a 16200 above? I would point out where if your points had been enumerated 😉

    Anyway, this is good contribution. Some more readable formatting would be nice. This kind of stuff (mathematical calculation) doesn’t have to be essay-style.

    Something like this for example:

    S(J5) = 236

    S(J6) = S(J6-5/5) + S(J6-5/6) + S(J6-6/5) + S(J6-6/6)
    = 4080 + 1020 + 1020 + 204 = 6324

    S(J7) = S(J7-5/5) + S(J7-5/6) + S(J7-5/7) + S(J7-6/5) + S(J7-6/6) + S(J7-6/7) + S(J7-7/5) + S(J7-7/6)
    = 6480 + 4320 +1080 + 4320 + 2160 + 1080 + 432 + 432 = 20304

    S(J) = S(J5) + S(J6) + S(J7) = 26864

    wheree S(Jn) stands for strength of the set of all unique Janya ragas with n notes total
    S(Jn-p/q) stands for the strength of the set of all unique Janya ragas with n notes total
    where p are used in the ascend and q are used in the descend

    Explanation for individual sets:
    S(J5): blah blah
    S(J6): blah blah blah

  2. i got to this blog off prasanna’s facebook post. there is an elegant trick to calculating the 5/5 6/6 or 7/7 numbers, which can then be extended to get the number of janya ragas.

    the number of ways you could obtain r/r notes (r notes going up, same r notes coming down) is just the coefficient of x^r in the product (1+4x+6x^2)^2 (1+2x)(1+x). You “automagically” get 5/5 to be 236, 6/6 to be 204 and 7/7 to be the well known 72.

    I sometimes give this as a problem to my students studying probability or combinatorics. bonus points for figuring out how to do the asymmetrics—5/6 5/7, etc by the same approach :). i didn’t know this was not very well known, but i suspect most, if not all my math-oriented friends know this.

    1. Thanks for the comment. I’m wondering if we’re working with different definitions of acceptable janya ragas. You’re speaking of the r/r notes as “r notes going up, same r notes coming down.” In my count, I am also allowing janyas ragas that have different notes in the ascent and the descent. For example, taking S R1 G3 M1 P D1 N3 as the parent raga, I would allow [S R1 M1 P D1] [N3 P G3 R1 S] as a janya: the ascent and descent have 5 notes each, but those 5 are not identical, and in fact there are 7 notes in the union.

      I get 236 possibilities in the 5/5 case where same notes are used in the ascent and descent, but I also consider the 5/5 case where different notes are used on each side, leading to many additional possibilities. Does your approach consider this?

      1. Patience, friend! 🙂 I just started with the symmetric case since it is the simplest. For this case the approach is perhaps transparent. But this exact approach can be used for any other constraint (as in 5 notes up 6 notes down, or 5 notes up 5 notes down but not the same—as you asked). In fact there is one line that simultaneously gives you all the answers above, obtained in exactly the way I stated above.

        Do you want to give it a shot? Hint: use a polynomial in two variables, x and y instead of just one in the symmetric case.

        Btw, if you want all janya ragas with 5 up and 5 down (not necessarily the same, but the union must be less than or equal to 7—the normal definition), the answer is 10796. The following give you numbers for other combinations: (all janya ragas, no simplification): 5 up and 6 down is 5340, while 5 up and 7 down is as you calculated to be 1080. 6 up and 6 down is 2364 while 6 up and 7 down is 432 (which I think you probably have counted).

        Total is 26864 as you calculate. But you get it error free in one (albeit elaborate) line.

        PS: if you allow 4 notes up and 4 notes down, the number of such janya ragas is 10540 :). For the day when we expand our repertoire.

        PPS: These polynomials are called generators. Let me know and i can give you the generator for janya ragas in general :). But try it out first—they are a very effective and elegant way to count.

  3. The “Janya Polynomial” is [ (1+4y+6y^2) + 4x(1+4y+3y^2) + 6x^2(1+2y+y^2) ]^2 (1+2x+2y+2xy) (1+x+y+xy)

    If you want the number of janya ragas that have r+1 notes going up and k+1 notes going down, it is given by the coefficient of x^r y^k in the polynomial above.

    But if you want to figure out how and why it works, think about the symmetric case in my previous example first :). You can multiply out the polynomial by hand if you are careful, but most off-the-shelf scientific computing tools would multiply it out for you.

    1. Narayana,

      Thank you very much for sharing this!

      In my previous comment I did not mean to convey impatience, I only wanted to check that we were working with the same definition, which I see that we are. I see that generating functions are a more compact and general purpose way of approaching problems of this sort. On the other hand, I’ve left my original, verbose reasoning in place in this post as I’ve always found that comparing multiple pathways to a solution is a good way of building intuition into the dynamics of a problem. For what it’s worth, the numbers I calculated match those you gave in your previous comment. For example, you gave 10796 as the number of all pentatonic janyas (union size <= 7), and that can also be see in my calculations as 236 (case 5/5 where union size is 5) + 4080 (case 5/5 where union size is 6) + 6480 (case 5/5 where union size is 7).

      You mentioned that you have sometimes used this problem in your university classes. Since I think the question of Janya ragas is of interest to people with all different backgrounds (some mathematical, some not), I would also invite you to mention any references that might be useful for less mathematical readers looking to interpret the "Janya polynomial" you provided, and build their understanding of how generating functions can be used in enumeration problems in general. (I would post such material myself, but that requires that I solidify my own knowledge first, which I might not be able to do in a satisfactory way in the next couple of days 🙂 So, I'd invite you to provide whatever tips and reference materials have been useful in your teaching experience. Thanks again,


      1. Rudi, no worries at all. Didn’t mean “patience” in a accusatory tone—it is just the way I talk :). I would be glad to write something down with references.

        And don’t get me wrong—I enjoyed your writeup. It is very carefully done and well written, and most definitely must remain. Often understanding something is usually equivalent to seeing it in many ways, so the more ways we have at getting this, the better we will do—I was just contributing one more way to do it that I think is exciting :).

  4. Dear Rudi:
    I came here from Prasanna’s FB post and I am really thrilled to see this explanation/ discussion. Though Narayanan mentioned it as a fairly well known problem/ solution in mathematical circles, musicians like me had no insight on how to eliminate the redundancies and arrive at unique number of Janyas. So this link should be preserved for posterity and perhaps popular carnatic forums across the web should be alerted of this. (I am doing my bit on this straight away).

    Also the argument of Mohanam’s swaras sung as a derivative of Hari kambodhi can sound different when sung as a derivative of Kalyani is true in some cases. For example, When the note Ma is not sung at all and if I do an aalapana with just Sa Ri Ga Pa Dha Ni, One can still make out if I am singing Sankarabharanam (Over emphasize on Sa Ri Ga) of Kalyani (repeated gamakam on Ni touching the adjacent Sa). So there is surely some merit in this “Raaga Bhavam” argument, but surely it cannot be extrapolated as true for differentiating redundant janyas. Regardless, this is a subjective discussion and travels tangential to the world of mathematics.

    For authoritarian discussions on unique janyas, now I can sleep with peace that what I (may have hyperbolically) considered as Riemann’s hypothesis of carnatic music is solved. Thanks again.

    ~ Vicky

    1. Dear Vicky,

      Thank you so much for your comment. I’m glad that this post has been informative!

      Actually, I have been meaning to credit you here, and I’m happy that you’ve given me this opportunity to do so. You see, when Prasanna first mentioned the 34,776 figure, I searched around the web to find references to it. I couldn’t find a definitive source for the figure, but I saw it mentioned on a number of Carnatic music blogs and information sites. One of the sites I stumbled upon was this blog where you posted a comment in 2005 asking about the problem of redundancies:

      It was your comment there (assuming you’re the same Vicky) that got me thinking about how the redundancies could be removed from the count. (You also mentioned the question of Mohanam’s parentage, which I came across again in further investigation and incorporated into my post.) So, thank you for providing the inspiration to look more closely into this problem!

      Regarding the 34,776 figure, I’m interested to know the original source. You mention Sangeeta Sastra by A. S. Panchapakesa Iyer, which I haven’t been able to track down. Do you know if that’s where the figure was first presented? I also came across it at the following link, where it seems to be attributed to Shri S. Rajam:


      1. Dear Rudi:
        Wow, that was indeed me who posted those question on redundancies in Chinmayi’s blog. That was quite a while ago and its a small world !! I had tried in the meanwhile to find the answer to this question on my own with no significant success 🙂

        Sangeeta Sastra that I mentioned is at least published in 1989 (May be a previous edition existed). Iyer himself was the principal of musical school in Mylapore, Chennai, as early as 1942. So while it is not that old/ authoritative in stating the figure of 34776, it is credible enough. I do have the abridged version of that book provided as an appendix to the “Ganamrudha Varna malika” book by the same author (One of the widely used text books for learning varnams). If you are interested I can scan those pages and post it here.

        And yes, Shri. Rajam is an authoritative figure in music theory as well. So the reference you provided on his source should be official enough as well.


  5. I worked on this issue some years ago and published my result (26864) in the Journal of the Madras Music Academy in 1991. Scanned copy of this issue can be found at I had a nice camera ready manuscript, unfortunately the Academy was still typesetting, so my 26864 shows up as several different numbers. And all my nice tables (referred to in the text of the paper) disappeared; in the words of the Editor, tables were too expensive to typeset.

    1. Prof. Sriram,

      Thank you so much for sharing the link to your work from 1991! Your paper must have been the first time the 26864 figure was published.

      Wow — tables too expensive to typeset — how times have changed! Another sign of changing times: you verified your result with a Fortran program that ran for a few minutes on a Macintosh II. For this post, I used a Groovy 2.1.0 script that ran on a MacBook Air in a little under 5 seconds. One thing that didn’t change in all those years: the number 26864 🙂

      For the convenience of anyone who follows the link above, the article “How Many Janya Ragas Are There?” begins on page 144 of the Journal, which is page 149 of the scanned document.

      Thanks again,

  6. Wonderful explanation. I liked the way you explained the duplication (through a Audava Audava) raga like Mohanam and clearly explained the calculations and arrived at 26,864.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s