The maths in Melakartas and writing IF-THEN without writing IF-THEN

Jan 24, 2005 23:43

Note: this is more of a maths/computing post than a music related post.

To give a brief introduction: there are 72 different primary ragas or parent ragas (loosely you can call them as 'scales') that are nothing but the permutation and combination of the various notes that can appear in a scale (again they follow the rules -- see link). These 72 primary ragas are called the 'MelaKarta' ragas. All these are simply arranged in a nice fashion. see this.

Of the seven notes, the note that has frequency 'F' and f x 1.5 cannot take adjacent spaces. However 'Ri', 'Ga', 'Dha' and 'Ni' can occupy three positions and Ma takes two positions (Ma1 and Ma2) (in western terms, if Sa is C, then Ri1 is C#, Ri2 is D, Ri3 is D#... however Ga1 == Ri2, Ga2 == Ri3, etc.,. again, see this for a clearer explanation. After studying all these 72 "fundamental" scales, for just 'Ri' and 'Ga' we can come up with the following table:

G1G2G3
R11-67-1213-18
R2 - 19-2425-30
R3 - - 31-36

Then I decided to come up with a completely non-algorithmic (no, IFs and THENs) solution to knowing what Ri and Ga can take.

If you looked up the Melakarta list, you will note that the raga number 28 is Harikamboji. This scale has R2 and G3. From the above table it can be seen that the number 28 is in the second row third column (not counting the 'dark' cells).

When we were in college myself and my friends used to spend a good amount of time in doing maths puzzles. It will all be puzzles where the goal is to ultimately do an IF-THEN-ELSE statement in pure mathematical expressions. Here are the expressions that I came up with first:

def R(x):
return (1 - ((x - 18.001) / abs((x - 18.001)))) / 2 + 2 * (((x - 18.999) / (abs(x - 18.999))) - ((x - 30.001) / abs((x - 30.001)))) / 2 + 3 * (((x - 30.999) / (abs(x - 30.999))) - ((x - 36.001) / abs((x - 36.001)))) / 2

def G(x):
return 3 * ((((x % 12) - 0.999) / (abs((x % 12) - 0.999))) - (((x % 12) - 6.001) / abs((x % 12) - 6.001))) / 2 + ((((x - 30.999) / abs(x - 30.999)) + ((x - 36.0001) / -abs(x - 36.0001))) / 2) + 2 * (((x % 12) - 6.999) / (abs((x % 12) - 6.999)) + ((x % 12) - 12.001) / -(abs((x % 12) - 12.001))) / 2 + ((x - 6) / -(abs(x - 6)) + 1) / 2

Where x is the position of the said raga (x = 28 for 'Harikamboji').


(please use python :) )

a little bit of demo:

>>> R(29)
2.0
>>> G(29)
3.0
>>> R(15)
1.0
>>> G(15)
3.0
>>> R(49 % 36)
1.0
>>> G(49 % 36)
3.0
>>>


Now all those decimals is to circumvent a Division by zero problem. Lets look at the 'atomic' IF-THEN condition of the in the above expression:

Lets say our idea is to know if a number is greater than N. Then we can do so by doing:

(x - N) / | (x - N) |

lets say x = 8 and N = 4 then we get a '1' ...and When x is lesser than N, we get a -1. Now we can convert this to a 'zero' and 'one' by doing:

(1 + (x - N) / | (x - N) |) / 2

However, the problem here is that when x == N, then we get a Division by Zero problem! So to circumvent that we make N as a decimal while x, as given, is an int. (so this kind of stuff wont work with decimals! unless you make N a really high precision float while x is a not-so-high-precision float ;) ).

Some day, if we can have simple biological forms of living things that are good at simple mathematics (like addition, modulus, etc.,.) and no logic, we can still "program" them using maths like this or in other words, Charles babbage was doing nothing but reducing IF-THEN logics into mathematical expressions in terms of "gears" and "wheels". (atleast all this was our theory when we were in college. Too bad we didn't study Computer Science / Information Technology / whatever fundoo computing thingy ;/).

now its a different thing if I can memorize this "simple" formula :) but I think I now remember that table by heart ;)

geek, carnatic

Previous post Next post
Up