----- Original Message -----

From: <graham@microtonal.co.uk>

To: <tuning-math@yahoogroups.com>

Sent: Monday, March 04, 2002 3:34 AM

Subject: [tuning-math] Re: help with ratio/vector algorithm

> In-Reply-To: <004101c1c32d$603c6540$af48620c@dsl.att.net>

> monz wrote:

>

> > > ratio r = 2^p * 3^q

> > >

> > > if q < 0

> > > then p = int((log(3^abs(q)) / log(2)) + 0.5)

> > > else p = (int((log(3^abs(q)) / log(2)) + 1.5)) * -1

> > > end if

> > >

> > > but it's not foolproof: sometimes the exponent of 2 is

> > > one less or one more than it should be. i've tried

> > > setting up further nested if-statements, to check if

> > > the absolute value of p is greater than that of q and

> > > adjust accordingly, but there's always an error somewhere.

> >

> >

> > the errors are occurring because the spreadsheet has to

> > check to see if n > d, and i can't figure out how to

> > implement that without getting a circular reference.

>

> I think =MOD(N20, 1)-N20 does it where N20 is the magnitude of the

> original interval in octaves. So you have to substitute that with

> log(3^abs(q)) / log(2).

thanks, Graham! (duh... of course i have to use MOD!)

i've implemented this in an Excel spreadsheet that assists

in finding the HEWM notation of a ratio:

http://www.ixpres.com/interval/dict/hewm.xls

color LEGEND:

cyan = data to be input by user

magenta = constants, used in calculations

orange = results of calculations on user data

at the top are a bunch of constants that i use in the

calculations.

below those...

on the left side, the user inputs the exponents of the

target ratio first, and then the exponent of 3 which gets

near it. the spreadsheet subtracts that, and indicates

the letter-name and any sharp or flat. (there's still

a bug here -- i don't know how to generate the negative

numbers when using MOD.) then the the user enters the

exponents of the notational "commas" from the magenta

table above until all exponents are zero. eventually,

i want to be able to have the spreadsheet determine all

of the accidental symbols from the exponents entered by

the user... but this is not implemented fully yet.

on the right side, the user inputs the exponents of the

target ratio, then directly enters the notational symbols

which eventually reduce all exponents to zero. the only

thing to be aware of here is that an apostrophe (') must

precede the minus and plus signs when entering them.

-monz

_________________________________________________________

Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com