In the common time meter, one bar of music consists of note values equivalent to 4 quarter notes. Using the note value system, 1 whole note is equivalent to 2 half notes, 1 half note is equivalent to 2 quarter notes, 1 quarter note is equivalent to 2 eighth notes, and 1 eighth note is equivalent to 2 sixteenth notes. (For our British friends, a whole note is a semibreve, a half note is a minim, a quarter note is a crotchet, an eighth note is a quaver, and a sixteenth note is a semiquaver.)
An example of a rhythm in one bar of common time meter with 1 quarter note, 2 sixteenth notes, 1 eighth note, and 1 half note is shown below.
Using only whole notes, half notes, quarter notes, eighth notes, and sixteenth notes (with no rests or dotted modifiers), how many unique rhythms can be made in one bar of common time meter?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Great solution! I actually did it yet a different way, but it also required a lot of "grunt work" and isn't any faster than either of your methods. (I listed the variations from longest length to shortest length first using just whole notes (1 way - (16)), then just using whole notes and half notes with at least one half note (1 way - (8, 8)), then just using whole notes and half notes and quarter notes with at least one quarter note (2 ways - (8, 4, 4), (4, 4, 4, 4)), and so on, found the permutations of each, and added them up.)
Log in to reply
Thanks, and and thanks for posting the question, I really enjoyed working through it even though it was a bit of a slog. It's the first time I've really used the multinomial theorem in a solution, so I posted it even though it ended up being the longer of the two methods by quite a bit. The recursive one was fun to figure out too, even if the periodic tweaks forced me to do the calculations by hand instead of just plugging the formula into Excel.
First off, nice write-up.
My solution (which got bogged down proving my generating function was correct) was similar to "method 1": I just had my computer tell me what the coefficient of x 1 6 is in the expansion of 1 − ( x + x 2 + x 4 + x 8 + x 1 6 ) 1 (I try to avoid the slog)
Log in to reply
To check, are you clear why your generating function is correct? It's a typical technique used for such problems.
(The hard part is calculating the coefficient manually.)
Log in to reply
Yes, I have a proof of its correctness, but couldn't find a good way to type it up in a solution here. Here's the rough idea:
In order to sum all the terms of degree 1 6 , it's simply easier to replace the multiple variables given with powers of a single variable x to which we assign degree 1 . This forces the generating function to have the form I gave.
Also, certainly it's harder to calculate the coefficient manually. However, for me, the most important skill in practice has been the ability to turn a problem into a form that the computer can evaluate.
Log in to reply
@Brian Moehring – You have the right ideas, but it's much easier than that.
The number of ways to use exactly
n
approved notes (order matters) to create one bar is the coefficient of
x
1
6
in
(
x
1
+
x
2
+
x
4
+
x
8
+
x
1
6
)
n
.
Hence, the number of ways to use any number of approved notes (order matters) to create one bar is the coefficient of
x
1
6
in
n
=
0
∑
∞
(
x
1
+
x
2
+
x
4
+
x
8
+
x
1
6
)
n
=
1
−
(
x
1
+
x
2
+
x
4
+
x
8
+
x
1
6
)
1
.
That's a nice clear write up. Like Brian I got the computer to do the grunt work. "coefficient ( (sum of (x+x^2+x^4+x^8+x^16)^r from r =1 to 16),x^16)" gets Wolfram Alpha to do your method one.
Log in to reply
Very nice way of counting the distinct rythms using wolfram alpha.
FYI Per Arjen's solution, in your method 2, what you want is to set t 0 = 1 and t i = 0 for i < 0 . There is 1 way to fill to create a string of 0's, which is the empty string (which is what you're concatenating with). This is a pretty common procedure.
E.g. In Fibonacci's sequence, if use the intepretation of climbing up staircases with step sizes of 1 and 2, then there is 1 way to climb up a 0 staircase, 1 way to climb up a 1 staircase (0 steps + 1 step) and 2 ways to climb up a 2 staircase (0+2, 1+1).
So I got a different result with a different technique but I don't know where my reasoning is wrong. Could someone help? Here is my (wrong) solution:
I thought of this problem as counting different ways of grouping 16 notes of 1/16th. For this purpose I lined them all out and left spaces for separators between them. In my approach the example above would be written like this :
o o o o | o | o | o o | o o o o o o o o
The four first o represent the four 1/16th notes that group together form a quarter note. the pipes separate the groupings, so after two individual 1/16th notes we have two grouped ones representing the eigth note, and after the last pipe we would get 8 1/16th notes representing the half note.
Now I can change this into a string of 15 1s and 0s representing the presence of a pipe separator or not. The example above would translate into:
000111010000000
Following that I concluded that there are 2^15=32768 possible rhythms.
Why is this wrong? Can someone help me see where my mapping went wrong?
Log in to reply
What is the mapping that corresponds to:
o o o | o o o o o | o o o o o o o | o
You have created a surjection , which gives us an upper bound on the number of possibilities, but it may not be the actual number of possibilities.
Log in to reply
I see, this would be a dotted eigth at the beginning. I didn't stop to consider that. Thanks for the answer.
I tried enumeneration of all the configurations which sum to unit time. Represent w-1, h-(1/2), q-(1/4), e-(1/8), s-(1/16). Then count as below for unit time. String length is given along with string name in table-1 below:
Table-1 Configuration and Rythms
w-1, (1),
hh-2, (1),
hqq-3, (3!/2!=3),
hqee-4, (4!/2!=12),
hqsse-5, (5!/2!=60),
hqssss-6, (6!/4!=30),
heeee-5, (5!/4!=5),
heeess-6, (6!/3!2!=60),
heessss-7, (7!/4!2!=105),
hessssss-8, (8!/6!=56),
hssssssss-9, (9!/8!=9),
qqqq-4, (1),
qqqee-5, (5!/3!2!=10),
qqeeee-6, (6!/4!2!=15),
qeeeeee-7, (7!/6!=7),
qqqess-6, (6!/3!2!=60),
qqqssss-7, (7!/4!3!=35),
qqeeess-7, (7!/3!2!2!=210),
qqeessss-8, (8!/4!2!2!=420),
qqessssss-9, (9!/6!2!=252),
qqssssssss-10, (10!/8!2!=45),
qeeeeess-8, (8!/5!2!=168),
qeeeessss-9, (9!/4!4!=630),
qeeessssss-10, (10!/6!3!=840),
qeessssssss-11, (11!/8!2!=495),
qessssssssss,12, (12!/10!=132),
qssssssssssss-13, (13!/12!=13),
eeeeeeee-8, (1),
eeeeeeess-9, (9!/7!2!=36),
eeeeeessss-10, (10!/6!4!=210),
eeeeessssss-11, (11!/6!5!=462),
eeeessssssss-12, (12!/8!4!=495),
eeessssssssss-13, (13!/10!3!=286),
eessssssssssss-14, (14!/12!2!=91),
essssssssssssss-15, (15!/14!=15),
ssssssssssssssss-16, (1),
Thus, there are 36 different configurations and their distinct permutations are summing to 5272 as the correct sum.
Using these 36 configurations, one can make table based on string lengths from 1 to 16 from the above table-1 as follows in Table-2:
Table-2, String length and Rythms
1,
1,
3,
13,
75,
165,
357,
645,
927,
1095,
957,
627,
299,
91,
15,
1.
I had derived all the above earlier but counted 33rd wrongly as 1287 and entered wrong answer as 6073.
There is an interesting breakup of these 5272 distinct rythms,
Rythm with (whole note) : 1,
Number of distinct rythms with one or more (half note): 341,
Number of distinct rythms with at least one quarter note (no half note): 3333,
Number of distinct rythms with at least one 1/8 note ( no quarter note and no half note): 1596,
Purely 1/16 note rythm:1
Let R ℓ be the number of patterns with a total length of ℓ sixteenths notes. Each such pattern starts with a note of length a sixteenths, followed by a pattern of length ℓ − a , where a = 1 , 2 , 4 , 8 , 1 6 ; thus we have the recursion R ℓ = R ℓ − 1 6 + R ℓ − 8 + R ℓ − 4 + R ℓ − 2 + R ℓ − 1 . We set R 0 = 1 (there is one trivial valid pattern of zero length), and R ℓ = 0 for negative values of ℓ .
Once we implement this sequence, the answer to the problem is simply R 1 6 .
Dynamic programming implementation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
This is sequence A023359 of the OEIS . Hence, the answer is 5272.
The OEIS provides some interesting equivalent problems.
And A248377(n) = A023359(2^n) if only targetting at such music problems
Let P ( n ) be the number of rhythms occupying n sixteenth notes, and let P ( k , n ) be the number of rhythms occupying n sixteenth notes that use precisely k notes. Then P ( k , n ) = a + 2 b + 4 c + 8 d + 1 6 e = n a + b + c + d + e = k ∑ a ! b ! c ! d ! e ! k ! is the coefficient of x n in ( x + x 2 + x 4 + x 8 + x 1 6 ) k . Moreover P ( n ) = k ≥ 0 ∑ P ( k , n ) is the coefficient of x n in ∑ k ≥ 0 ( x + x 2 + x 4 + x 8 + x 1 6 ) k . Thus we have the generating function n ≥ 0 ∑ P ( n ) x n = 1 − x − x 2 − x 4 − x 8 − x 1 6 1 and hence P ( n ) = P ( n − 1 ) + P ( n − 2 ) + P ( n − 4 ) + P ( n − 8 ) + P ( n − 1 6 ) from which it is easy to calculate that P ( 1 6 ) = 5 2 7 2 .
Problem Loading...
Note Loading...
Set Loading...
Under the given conditions, rhythms can be represented as ordered strings of 1 6 1 's, 8 1 's, 4 1 's, 2 1 's and 1 's with a sum of 1 . The rhythm given in the question would be represented by the string ( 4 1 , 1 6 1 , 1 6 1 , 8 1 , 2 1 ) which has a sum of 1 .
To simplify the calculations, we note that this is the equivalent of ordered strings of 1 's, 2 's, 4 's, 8 's and 1 6 's with a sum of 16. This way, the rhythm given in the question would be represented by the string ( 4 , 1 , 1 , 2 , 8 ) which has a sum of 1 6 .
Two methods came to mind to find the number of such representations, both of which unfortunately required some "grunt" work.
filler filler
METHOD 1:
We can use the powers of the polynomial x 1 6 + x 8 + x 4 + x 2 + x to determine the number of such representations of fixed length. For example, the number of such strings with seven terms would be the coefficient of x 1 6 in ( x 1 6 + x 8 + x 4 + x 2 + x ) 7 . Here we'll make use of the Multinomial Theorem .
Unfortunately, we can have strings of any length from 1 to 1 6 , so we'd have to apply the theorem sixteen times. For some of the shortest and longest strings, we can find the number of representations more easily, e.g, it is clear that there is only one string with a single term ( 1 6 ) and one string with two terms ( 8 , 8 ) ; similarly, there is only one string with sixteen terms, consisting of sixteen 1 's, and fifteen strings with fifteen terms, namely all the permutations of one 2 and fourteen 1 's. That still leaves a number of applications of the multinomial theorem; we show one such example.
Length 7:
We seek the coefficient of x 1 6 in ( x 1 6 + x 8 + x 4 + x 2 + x ) 7 . We can factor out an x 7 from the polynomial, so effectively we are looking for the coefficient of x 9 in ( x 1 5 + x 7 + x 3 + x + 1 ) 7 . We then note that the x 1 5 cannot contribute to this coefficient, so we only need to look at ( x 7 + x 3 + x + 1 ) 7 .
The general term of this polynomial will have form
( α 1 , α 2 , α 3 , α 4 5 ) ( x 7 ) α 1 ( x 3 ) α 2 ( x ) α 3 ( 1 ) α 4
We know that α 1 + α 2 + α 3 + α 4 = 7 ; to find the coefficient of x 9 , we also need 7 α 1 + 3 α 2 + α 3 = 9 .
We can re-write the second condition as α 3 = 9 − 7 α 1 − 3 α 2 ; using this, we re-write the first condition as α 4 = 6 α 1 + 2 α 2 − 2 .
This means we have restrictions 7 α 1 + 3 α 2 ≤ 9 and 6 α 1 + 2 α 2 ≥ 2 .
Applying those restrictions to the conditions, we find that the four possible sets of values for ( α 1 , α 2 , α 3 , α 4 ) are ( 0 , 1 , 6 , 0 ) ; ( 0 , 2 , 3 , 2 ) ; ( 0 , 3 , 0 , 4 ) ; and ( 1 , 0 , 2 , 4 ) .
Then the coefficient of x 9 in ( x 7 + x 3 + x + 1 ) 7 is
( 0 , 1 , 6 , 0 7 ) + ( 0 , 2 , 3 , 2 7 ) + ( 0 , 3 , 0 , 4 7 ) + ( 1 , 0 , 2 , 4 7 ) = 7 + 2 1 0 + 3 5 + 1 0 5 = 3 5 7
and so there are 3 5 7 strings of length 7 .
Repeating this process for all other possible lengths yields the following table, where n is the length of a string, and s n the number of strings of length n :
n 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 s n 1 1 3 1 3 7 5 1 6 5 3 5 7 6 4 5 9 2 7 1 0 9 5 9 5 7 6 2 7 2 9 9 9 1 1 5 1
Adding these up gives a total of 5 2 7 2 rhythms.
filler filler
METHOD 2:
Rather than focusing specifically on strings with a sum of 1 6 , we consider strings with a sum of k for any k ∈ N , and look for a recursive formula for t k , the number of strings with sum k .
To simplify the reasoning, we first consider 9 ≤ k ≤ 1 5 . To make a string with sum k , we could take a string with sum k − 1 and append a 1 ; or we could take a string with sum k − 2 and append a 2 ; or we could take a string with sum k − 4 and append a 4 ; or we could take a string with sum k − 8 and append an 8 . This then leads to the recursion t k = t k − 1 + t k − 2 + t k − 4 + t k − 8 . We can extend this to lower values of k by using the convention t i = 0 whenever i ≤ 0 . However , we have to be a little more careful when k is a power of 2 .
Consider strings with a sum of 8 . We can make such strings by taking strings of length 7 and appending a 1 , or taking strings of length 6 and appending a 2 , or taking strings of length 4 and appending a 4 ; but we can also form one more string by using a single 8 . Thus whenever k is a power of 2 , we have to change the recursive formula slightly to t k = t k − 1 + t k − 2 + t k − 4 + t k − 8 + 1 .
The first few values of t k are easily found: t 1 = 1 ( the only possible string is ( 1 ) ); t 2 = 2 ( the strings are ( 2 ) or ( 1 , 1 ) ); and t 3 = 3 (the strings are ( 2 , 1 ) , ( 1 , 2 ) and ( 1 , 1 , 1 ) ). After that we apply the recursive formula, being careful to add the extra 1 whenever k is a power of 2. This yields the following table:
k 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 t k 1 2 3 6 1 0 1 8 3 1 5 6 9 8 1 7 4 3 0 6 5 4 2 9 5 6 1 6 9 0 2 9 8 3 5 2 7 2
and again we find that there are a total of 5 2 7 2 rhythms.