Welcome to the Piano World Piano Forums
Over 2.7 million posts about pianos, digital pianos, and all types of keyboard instruments
Join the World's Largest Community of Piano Lovers (it's free)
It's Fun to Play the Piano ... Please Pass It On!

SEARCH
Piano Forums & Piano World
(ad)
Best of Piano Buyer
 Best of Piano Buyer
(ad)
Piano Life Saver - Dampp Chaser
Dampp Chaser Piano Life Saver
Find a Professional
Our Classified Ads
Find Piano Professionals-

*Piano Dealers - Piano Stores
*Piano Tuners
*Piano Teachers
*Piano Movers
*Piano Restorations
*Piano Manufacturers

Advertise on Piano World

(ad)
Accu-Tuner
Sanderson Accu-Tuner
Who's Online Now
104 registered members (aqwerse, AnnInMiami, 36251, AnthonyPaulO, AWilley, astrotoy, AlphaBravoCharlie, atcsam, baudelairepianist, anotherscott, 29 invisible), 1,067 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
(ad)
Estonia Pianos
Estonia Pianos
Quick Links to Useful Piano & Music Resources
Quick Links:
*Advertise On Piano World
*Free Piano Newsletter
*Online Piano Recitals
*Piano Recitals Index
*Piano & Music Accessories
*Live Piano Venues
*Music School Listings
* Buying a Piano
*Buying A Acoustic Piano
*Buying a Digital Piano
*Pianos for Sale
*Sell Your Piano
*How Old is My Piano?
*Directory/Site Map
*Virtual Piano
*Music Word Search
*Piano Videos
*Virtual Piano Chords & Scales
Previous Thread
Next Thread
Print Thread
Page 3 of 3 1 2 3
Re: A mathematical question [Re: dire tonic] #2352694
11/20/14 10:13 AM
11/20/14 10:13 AM
Joined: Feb 2013
Posts: 25
Italy
E
eulerdisk Offline
Full Member
eulerdisk  Offline
Full Member
E

Joined: Feb 2013
Posts: 25
Italy
Originally Posted by dire tonic
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 10:14 AM.
(ad)
Piano & Music Accessories
piano accessories music gifts tuning and moving equipment
Re: A mathematical question [Re: eulerdisk] #2352695
11/20/14 10:14 AM
11/20/14 10:14 AM
Joined: Jul 2011
Posts: 3,087
uk south
D
dire tonic Offline
3000 Post Club Member
dire tonic  Offline
3000 Post Club Member
D

Joined: Jul 2011
Posts: 3,087
uk south
Originally Posted by eulerdisk
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] #2352696
11/20/14 10:17 AM
11/20/14 10:17 AM
Joined: Feb 2013
Posts: 25
Italy
E
eulerdisk Offline
Full Member
eulerdisk  Offline
Full Member
E

Joined: Feb 2013
Posts: 25
Italy
Yes, no combination with consecutive rests is generated. Only single (on any length) rests surrounded by notes (or at begin/end of bar).

Re: A mathematical question [Re: dire tonic] #2352699
11/20/14 10:20 AM
11/20/14 10:20 AM
Joined: Feb 2013
Posts: 25
Italy
E
eulerdisk Offline
Full Member
eulerdisk  Offline
Full Member
E

Joined: Feb 2013
Posts: 25
Italy
Originally Posted by dire tonic

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 10:25 AM
11/20/14 10:25 AM
Joined: Jul 2011
Posts: 3,087
uk south
D
dire tonic Offline
3000 Post Club Member
dire tonic  Offline
3000 Post Club Member
D

Joined: Jul 2011
Posts: 3,087
uk south
Originally Posted by eulerdisk
Originally Posted by dire tonic
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 10:36 AM.
Re: A mathematical question [Re: dire tonic] #2352710
11/20/14 10:50 AM
11/20/14 10:50 AM
Joined: Feb 2013
Posts: 25
Italy
E
eulerdisk Offline
Full Member
eulerdisk  Offline
Full Member
E

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.

Quote
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 cool

Last edited by eulerdisk; 11/20/14 10:51 AM.
Re: A mathematical question [Re: eulerdisk] #2352711
11/20/14 10:54 AM
11/20/14 10:54 AM
Joined: Jul 2011
Posts: 3,087
uk south
D
dire tonic Offline
3000 Post Club Member
dire tonic  Offline
3000 Post Club Member
D

Joined: Jul 2011
Posts: 3,087
uk south
Originally Posted by eulerdisk
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.

Quote
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 cool


I see what you mean! ...thanks for doing the sums.

Re: A mathematical question [Re: PhilipInChina] #2352714
11/20/14 11:04 AM
11/20/14 11:04 AM
Joined: Jul 2011
Posts: 3,087
uk south
D
dire tonic Offline
3000 Post Club Member
dire tonic  Offline
3000 Post Club Member
D

Joined: Jul 2011
Posts: 3,087
uk south
...one thing still puzzles me. If you didn't consider the empty bar, how did you end up with an odd number for the case of the 32nds but an even number for the 8ths. Both should be even (the plot thickens....).

Re: A mathematical question [Re: dire tonic] #2352718
11/20/14 11:21 AM
11/20/14 11:21 AM
Joined: Feb 2013
Posts: 25
Italy
E
eulerdisk Offline
Full Member
eulerdisk  Offline
Full Member
E

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 11:23 AM.
Re: A mathematical question [Re: eulerdisk] #2352732
11/20/14 11:45 AM
11/20/14 11:45 AM
Joined: Jul 2011
Posts: 3,087
uk south
D
dire tonic Offline
3000 Post Club Member
dire tonic  Offline
3000 Post Club Member
D

Joined: Jul 2011
Posts: 3,087
uk south
Originally Posted by eulerdisk
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 11:21 PM
11/20/14 11:21 PM
Joined: Oct 2013
Posts: 3,780
Kuwait
PhilipInChina Offline OP
3000 Post Club Member
PhilipInChina  Offline OP
3000 Post Club Member

Joined: Oct 2013
Posts: 3,780
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 11:55 PM
11/20/14 11:55 PM
Joined: Mar 2013
Posts: 623
D
Dwscamel Offline
500 Post Club Member
Dwscamel  Offline
500 Post Club Member
D

Joined: Mar 2013
Posts: 623
Originally Posted by eulerdisk
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:
100000000000000000000000000000000000000000000000000

I 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 !!

Code

# 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 smile.

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 10:55 PM
11/23/14 10:55 PM
Joined: Oct 2012
Posts: 3,909
🎹
Retsacnal Online content

Platinum Supporter until Feb 18  2015
Retsacnal  Online Content

Platinum Supporter until Feb 18  2015


Joined: Oct 2012
Posts: 3,909
🎹
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 03:41 AM
11/24/14 03:41 AM
Joined: Jul 2011
Posts: 3,087
uk south
D
dire tonic Offline
3000 Post Club Member
dire tonic  Offline
3000 Post Club Member
D

Joined: Jul 2011
Posts: 3,087
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 N-1 slots (but this is the rhythm, not the pitch). The third note can occupy N-2 slots. You also have to eliminate double-counting.

Re: A mathematical question [Re: Dwscamel] #2354159
11/24/14 04:27 AM
11/24/14 04:27 AM
Joined: Sep 2013
Posts: 2,170
The Netherlands
W
WimPiano Offline
2000 Post Club Member
WimPiano  Offline
2000 Post Club Member
W

Joined: Sep 2013
Posts: 2,170
The Netherlands
Originally Posted by Dwscamel
Originally Posted by eulerdisk
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:
100000000000000000000000000000000000000000000000000

I 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 !!

Code

# 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 smile.

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.

Page 3 of 3 1 2 3

Moderated by  BB Player 

Shop Our Online Store!
Shop Our Store Online
Shop PianoSupplies.com

Did you know Piano World has an online store, and that it's loaded with goodies pianists and music lovers want?
Check it out and place your order.

Special Purchase!
Keyboard and Roses Piano Bench Cushion Keyboard & Roses 14"x30" piano bench cushions Regularly sold for $79 to $100, now only $39. (while supplies last)

(ad)
Pianoteq
PianoTeq Bechstein
(ad)
Faust Harrison Pianos
Faust Harrison 100+ Steinways
New Topics - Multiple Forums
Exercise books - Czerny etc.
by Moo :). 03/22/19 09:56 PM
Ordering a piano vs. buying what you try
by ASR. 03/22/19 07:15 PM
Piano With Humility
by Retsacnal. 03/22/19 06:43 PM
Piano in hospital
by CharlesXX. 03/22/19 06:38 PM
What's Hot!!
PIANO TEACHERS Please read this!
-------------------
European Tour for Piano Lovers
JOIN US FOR THE TOUR!
--------------------
Posting Pictures on the Forums
-------------------
Forums RULES & HELP
-------------------
ADVERTISE on Piano World
Forum Statistics
Forums41
Topics191,062
Posts2,809,623
Members92,847
Most Online15,252
Mar 21st, 2010
Please Support Our Advertisers
Faust Harrison 100+ Steinways

Dampp Chaser Piano Life Saver

Sweetwater

 Best of Piano Buyer

PianoTeq Bechstein
Visit our online store for gifts for music lovers


 
Help keep the forums up and running with a donation, any amount is appreciated!
Or by becoming a Subscribing member! Thank-you.
Donate   Subscribe
 
Our Piano Related Classified Ads
| Dealers | Tuners | Lessons | Movers | Restorations | Pianos For Sale | Sell Your Piano |

Advertise on Piano World
| Subscribe | Piano World | PianoSupplies.com | Advertise on Piano World |
| |Contact | Privacy | Legal | About Us | Site Map | Free Newsletter |


copyright 1997 - 2019 Piano World ® all rights reserved
No part of this site may be reproduced without prior written permission
Powered by UBB.threads™ PHP Forum Software 7.6.2