129 registered members (8ude, Alex C, ando, Animisha, almo82, A Guy, anotherscott, Andy001, 30 invisible),
1,471
guests, and 7
spiders. 
Key:
Admin,
Global Mod,
Mod



Re: A mathematical question
[Re: dire tonic]
#2352694
11/20/14 09:13 AM
11/20/14 09:13 AM

Joined: Feb 2013
Posts: 25 Italy
eulerdisk
Full Member

Full Member
Joined: Feb 2013
Posts: 25
Italy

3892357470806552 vs 3.8824182e+15
There shouldn't be an error on the third significant digit.
Depends on how Google truncate the results during the various calculation steps. Your calculations involve divisions ?? If yes Google thinks you want floating point numbers so it switch to them and you start to lose precision.
Last edited by eulerdisk; 11/20/14 09:14 AM.



Re: A mathematical question
[Re: eulerdisk]
#2352695
11/20/14 09:14 AM
11/20/14 09:14 AM

Joined: Jul 2011
Posts: 3,085 uk south
dire tonic
3000 Post Club Member

3000 Post Club Member
Joined: Jul 2011
Posts: 3,085
uk south

Sequence of rests are not counted, two consecutive 8th rests is considered the same as a 4th rest.  quite. So consecutive rests don't need to be considered at all, not even as a 4th rest. Clearly, the two methods produce results close enough to show they 'work' but I wonder why there's any discrepancy.



Re: A mathematical question
[Re: dire tonic]
#2352699
11/20/14 09:20 AM
11/20/14 09:20 AM

Joined: Feb 2013
Posts: 25 Italy
eulerdisk
Full Member

Full Member
Joined: Feb 2013
Posts: 25
Italy

Clearly, the two methods produce results close enough to show they 'work' but I wonder why there's any discrepancy.
Read one of my previous posts. Limited precision floating point numbers and summation of big and little numbers produces bad results.



Re: A mathematical question
[Re: eulerdisk]
#2352703
11/20/14 09:25 AM
11/20/14 09:25 AM

Joined: Jul 2011
Posts: 3,085 uk south
dire tonic
3000 Post Club Member

3000 Post Club Member
Joined: Jul 2011
Posts: 3,085
uk south

3892357470806552 vs 3.8824182e+15
There shouldn't be an error on the third significant digit.
Depends on how Google truncate the results during the various calculation steps. Your calculations involve divisions ?? If yes Google thinks you want floating point numbers so it switch to them and you start to lose precision. It does involve division but the numerator will always be divisible by the denominator to an integral value. there are only 9 terms 1 +(empty bar) 88 + (first note only  no rests allowed) [7!/[6!*1!)]*(88^2)+ (2 notes) [7!/(5!*2!)]*(88^3)+ (3 notes) [7!/(4!*3!)]*(88^4)+ (4 notes) [7!/(3!*4!)]*(88^5)+ [7!/(2!*5!)]*(88^6)+ [7!/(1!*6!)]*(88^7)+ [7!/(0!*7!)]*(88^8) (all 8 notes played) *edit* missed out the 88^2 term
Last edited by dire tonic; 11/20/14 09:36 AM.



Re: A mathematical question
[Re: dire tonic]
#2352710
11/20/14 09:50 AM
11/20/14 09:50 AM

Joined: Feb 2013
Posts: 25 Italy
eulerdisk
Full Member

Full Member
Joined: Feb 2013
Posts: 25
Italy

I just coded your formula, and that gives me 3892357470806553, so it's right. You have considered the "empty" bar, I didn't cause I removed spaces entirely so you have 1 more than mine. Now we can sleep in peace. It does involve division but the numerator will always be divisible by the denominator to an integral value. Yes but Google doesn't know that
Last edited by eulerdisk; 11/20/14 09:51 AM.



Re: A mathematical question
[Re: eulerdisk]
#2352711
11/20/14 09:54 AM
11/20/14 09:54 AM

Joined: Jul 2011
Posts: 3,085 uk south
dire tonic
3000 Post Club Member

3000 Post Club Member
Joined: Jul 2011
Posts: 3,085
uk south

I just coded your formula, and that gives me 3892357470806553, so it's right. You have considered the "empty" bar, I didn't cause I removed spaces entirely so you have 1 more than mine. Now we can sleep in peace. It does involve division but the numerator will always be divisible by the denominator to an integral value. Yes but Google doesn't know that I see what you mean! ...thanks for doing the sums.



Re: A mathematical question
[Re: dire tonic]
#2352718
11/20/14 10:21 AM
11/20/14 10:21 AM

Joined: Feb 2013
Posts: 25 Italy
eulerdisk
Full Member

Full Member
Joined: Feb 2013
Posts: 25
Italy

Only when I calculated 3892357470806552 I removed completely the rest possibilities from the code, so no rest of any length (so no "empty" bar) The original code has the rest management.
Last edited by eulerdisk; 11/20/14 10:23 AM.



Re: A mathematical question
[Re: eulerdisk]
#2352732
11/20/14 10:45 AM
11/20/14 10:45 AM

Joined: Jul 2011
Posts: 3,085 uk south
dire tonic
3000 Post Club Member

3000 Post Club Member
Joined: Jul 2011
Posts: 3,085
uk south

Only when I calculated 3892357470806552 I removed completely the rest possibilities from the code, so no rest of any length (so no "empty" bar) The original code has the rest management. Understood. What we need now is a means of formulating 'beauty' so we can filter out all the rubbish tunes and arrive at a meaningful number. I'm happy to leave that to you and Python.



Re: A mathematical question
[Re: Retsacnal]
#2352973
11/20/14 10:21 PM
11/20/14 10:21 PM

Joined: Oct 2013
Posts: 3,735 Kuwait
PhilipInChina
OP
3000 Post Club Member

OP
3000 Post Club Member
Joined: Oct 2013
Posts: 3,735
Kuwait

I tried python but it ate my labrador.
Currently working towards "Twinkle twinkle little star"



Re: A mathematical question
[Re: eulerdisk]
#2352993
11/20/14 10:55 PM
11/20/14 10:55 PM

Joined: Mar 2013
Posts: 623
Dwscamel
500 Post Club Member

500 Post Club Member
Joined: Mar 2013
Posts: 623

If we take a 32th as the minimum note duration, there are: 244601842863053754340937981537651198832237890212083485501963127501261947397454705500426716559736743757454676068635596937635829273540930184903619841 possible 4/4 bars. For refere this is an estimate of the number of atoms on earth: 100000000000000000000000000000000000000000000000000I wrote a simple recursive function in Python that given the minimum note duration enumerate every possibile bar. It counts every combination of notes and pauses of every duration. !! WARNING NERDY STUFF !!
# Minum unit in quarter note subdivisions. 8 means 8th, 16 means 16th...
NOTE_MINIMUM_UNIT = 32
# Naturals + sharps
NOTE_NUMBER = 12
# This is simple but SLOW, it will run forever with the parameters above
def enumBars(previousNoteIsSilence, remainingTimeInUnit):
# Ends the recursion
if remainingTimeInUnit == 0:
return 1
tot = 0
# Here we iterate over all possibile note duration.
#
# if NOTE_MINIMUM_UNIT is 32
# from 1 (one 32th), 2 (one 16th), 3 (dotted 16th) ... to 32 (one quarter note)
for noteDuration in range(1, remainingTimeInUnit + 1):
if noteDuration <= remainingTimeInUnit:
# We chose a note (12 possibilities)
# then we recalculate the function recursively with the remaining time.
tot = tot + NOTE_NUMBER * enumBars(False, remainingTimeInUnit  noteDuration)
# Pause special case
# We can count "pause combination" only if the previus "note" is not a pause.
if previousNoteIsSilence is False:
tot = tot + enumBars(True, remainingTimeInUnit  noteDuration)
return tot
# This is the same but it cache subproblems so it's FAST.
def enumBarsOptimized(previousNoteIsSilence, remainingTimeInUnit, state):
# Ends the recursion
if remainingTimeInUnit == 0:
return 1
# We use emainingTimeInUnit  1 as the correct index in the array
table = state[0 if previousNoteIsSilence is True else 1]
if table[remainingTimeInUnit  1] != False:
return table[remainingTimeInUnit  1]
tot = 0
# Here we iterate over all possibile note duration.
#
# if NOTE_MINIMUM_UNIT is 16
# from 1 (one 16th), 2 (one 8th), 3 (dotted 8th) ... to 16 (one quarter note)
for noteDuration in range(1, remainingTimeInUnit + 1):
if noteDuration <= remainingTimeInUnit:
# We chose a note (12 possibilities)
# then we recalculate the function recursively with the remaining time.
tot = tot + NOTE_NUMBER * enumBarsOptimized(False, remainingTimeInUnit  noteDuration, state)
# Pause special case
# We can count "pause combination" only if the previus "note" is not a pause.
if previousNoteIsSilence is False:
tot = tot + enumBarsOptimized(True, remainingTimeInUnit  noteDuration, state)
table[remainingTimeInUnit  1] = tot
return tot
# (NOTE_MINIMUM_UNIT * 4) is one 4/4 bar, (NOTE_MIN.. * 3) is one 3/4 bar ...
DURATION = NOTE_MINIMUM_UNIT * 4
print enumBarsOptimized(False, DURATION, [[False] * DURATION for i in range (2)])
I knew someone would implement this in Python! You're the best . Would be nice to see it in a big compiled language with arbitrary precision, like Lisp or Java. But right now I have only a few interpreters.
Beethoven  Op.49 No.1 (sonata 19) Czerny  Op.299 Nos. 5,7 (School of Velocity) Liszt  S.172 No.2 (Consolation No.2)
Dream piece: Rachmaninoff  Sonata 2, movement 2 in E minor



Re: A mathematical question
[Re: PhilipInChina]
#2354095
11/23/14 09:55 PM
11/23/14 09:55 PM

Joined: Oct 2012
Posts: 3,768 ðŸŽ¹
Retsacnal

Joined: Oct 2012
Posts: 3,768
ðŸŽ¹

I confess...I like nerdy stuff. After posting in this thread the other day, I went to the gym and found myself thinking about the math. My probability theory is rusty, and I'm too lazy to look it up. What stymied me in the gym was that if the first "note" (quarter, sixteenth, whatever) can have up to five pitches. The first can be one in 12, the second one in 11, the third one in 10, etc. Except that it's actually one in 13 if you consider a rest one of the choices (and it should be). And if it was held over is a 14th option. But if the first is a rest, you don't subtract 1 from the next possibility. In other words, each finger that theoretically presses a note removes one from the choices for the subsequent finger, but not so if a rest is chosen. One key can be pressed by only one finger, but all five can "play" a rest. Anyway, I forget how to compute that sort of thing.
I pondered putting together a spreadsheet. It never even dawned on me to write a program to simply count 'em up (and I teach software engineering)! Anyway, not worth following up on, except that I was intrigued by the python program shown above.
"If it sounds good, it is good."  Duke Ellington P E R F O R M A N C E over p r o v e n a n c e



Re: A mathematical question
[Re: Retsacnal]
#2354149
11/24/14 02:41 AM
11/24/14 02:41 AM

Joined: Jul 2011
Posts: 3,085 uk south
dire tonic
3000 Post Club Member

3000 Post Club Member
Joined: Jul 2011
Posts: 3,085
uk south

That's the right idea and it is closely related to probability theory but the constraint isn't on the pitch at all (of which there are 12 rather than 5). Every note in the bar, no matter how many notes, can occupy the same pitch (e.g. one note samba), the constraint is only on the rhythm. Two notes can't be simultaneous, unless we allow chords. So, if the bar is to be subdivided into N parts:
The first note is constrained to the beginning of the bar (no rests) and only has 1 rhythmic option (but 12 pitch options). After that all other notes are free to be placed in any unoccupied slot. Clearly, as we add more notes the number of slots diminishes, i.e.the second note is free to occupy any one of the remaining N1 slots (but this is the rhythm, not the pitch). The third note can occupy N2 slots. You also have to eliminate doublecounting.



Re: A mathematical question
[Re: Dwscamel]
#2354159
11/24/14 03:27 AM
11/24/14 03:27 AM

Joined: Sep 2013
Posts: 2,152 The Netherlands
WimPiano
2000 Post Club Member

2000 Post Club Member
Joined: Sep 2013
Posts: 2,152
The Netherlands

If we take a 32th as the minimum note duration, there are: 244601842863053754340937981537651198832237890212083485501963127501261947397454705500426716559736743757454676068635596937635829273540930184903619841 possible 4/4 bars. For refere this is an estimate of the number of atoms on earth: 100000000000000000000000000000000000000000000000000I wrote a simple recursive function in Python that given the minimum note duration enumerate every possibile bar. It counts every combination of notes and pauses of every duration. !! WARNING NERDY STUFF !!
# Minum unit in quarter note subdivisions. 8 means 8th, 16 means 16th...
NOTE_MINIMUM_UNIT = 32
# Naturals + sharps
NOTE_NUMBER = 12
# This is simple but SLOW, it will run forever with the parameters above
def enumBars(previousNoteIsSilence, remainingTimeInUnit):
# Ends the recursion
if remainingTimeInUnit == 0:
return 1
tot = 0
# Here we iterate over all possibile note duration.
#
# if NOTE_MINIMUM_UNIT is 32
# from 1 (one 32th), 2 (one 16th), 3 (dotted 16th) ... to 32 (one quarter note)
for noteDuration in range(1, remainingTimeInUnit + 1):
if noteDuration <= remainingTimeInUnit:
# We chose a note (12 possibilities)
# then we recalculate the function recursively with the remaining time.
tot = tot + NOTE_NUMBER * enumBars(False, remainingTimeInUnit  noteDuration)
# Pause special case
# We can count "pause combination" only if the previus "note" is not a pause.
if previousNoteIsSilence is False:
tot = tot + enumBars(True, remainingTimeInUnit  noteDuration)
return tot
# This is the same but it cache subproblems so it's FAST.
def enumBarsOptimized(previousNoteIsSilence, remainingTimeInUnit, state):
# Ends the recursion
if remainingTimeInUnit == 0:
return 1
# We use emainingTimeInUnit  1 as the correct index in the array
table = state[0 if previousNoteIsSilence is True else 1]
if table[remainingTimeInUnit  1] != False:
return table[remainingTimeInUnit  1]
tot = 0
# Here we iterate over all possibile note duration.
#
# if NOTE_MINIMUM_UNIT is 16
# from 1 (one 16th), 2 (one 8th), 3 (dotted 8th) ... to 16 (one quarter note)
for noteDuration in range(1, remainingTimeInUnit + 1):
if noteDuration <= remainingTimeInUnit:
# We chose a note (12 possibilities)
# then we recalculate the function recursively with the remaining time.
tot = tot + NOTE_NUMBER * enumBarsOptimized(False, remainingTimeInUnit  noteDuration, state)
# Pause special case
# We can count "pause combination" only if the previus "note" is not a pause.
if previousNoteIsSilence is False:
tot = tot + enumBarsOptimized(True, remainingTimeInUnit  noteDuration, state)
table[remainingTimeInUnit  1] = tot
return tot
# (NOTE_MINIMUM_UNIT * 4) is one 4/4 bar, (NOTE_MIN.. * 3) is one 3/4 bar ...
DURATION = NOTE_MINIMUM_UNIT * 4
print enumBarsOptimized(False, DURATION, [[False] * DURATION for i in range (2)])
I knew someone would implement this in Python! You're the best . Would be nice to see it in a big compiled language with arbitrary precision, like Lisp or Java. But right now I have only a few interpreters. If you really need it I can write it in Java, C, C++, C# or any other modern language.




Forums40
Topics189,603
Posts2,782,387
Members92,121

Most Online15,252 Mar 21st, 2010


