I've Got Rhythm

In the common time meter, one bar of music consists of note values equivalent to 4 4 quarter notes. Using the note value system, 1 1 whole note is equivalent to 2 2 half notes, 1 1 half note is equivalent to 2 2 quarter notes, 1 1 quarter note is equivalent to 2 2 eighth notes, and 1 1 eighth note is equivalent to 2 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 1 quarter note, 2 2 sixteenth notes, 1 1 eighth note, and 1 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?


The answer is 5272.

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.

4 solutions

Zico Quintina
Jul 14, 2018

Under the given conditions, rhythms can be represented as ordered strings of 1 16 \frac{1}{16} 's, 1 8 \frac{1}{8} 's, 1 4 \frac{1}{4} 's, 1 2 \frac{1}{2} 's and 1 1 's with a sum of 1 1 . The rhythm given in the question would be represented by the string ( 1 4 , 1 16 , 1 16 , 1 8 , 1 2 ) \left(\frac{1}{4}, \frac{1}{16}, \frac{1}{16}, \frac{1}{8}, \frac{1}{2}\right) which has a sum of 1 1 .

To simplify the calculations, we note that this is the equivalent of ordered strings of 1 1 's, 2 2 's, 4 4 's, 8 8 's and 16 16 '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 ) (4, 1, 1, 2, 8) which has a sum of 16 16 .

Two methods came to mind to find the number of such representations, both of which unfortunately required some "grunt" work.

filler filler {\color{#FFFFFF} \text{filler}} \\ {\color{#FFFFFF} \text{filler}}

METHOD 1:

We can use the powers of the polynomial x 16 + x 8 + x 4 + x 2 + x x^{16} + 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 16 x^{16} in ( x 16 + x 8 + x 4 + x 2 + x ) 7 (x^{16} + 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 1 to 16 16 , 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 ( 16 ) (16) and one string with two terms ( 8 , 8 ) (8, 8) ; similarly, there is only one string with sixteen terms, consisting of sixteen 1 1 's, and fifteen strings with fifteen terms, namely all the permutations of one 2 2 and fourteen 1 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 16 x^{16} in ( x 16 + x 8 + x 4 + x 2 + x ) 7 (x^{16} + x^8 + x^4 + x^2 + x)^7 . We can factor out an x 7 x^7 from the polynomial, so effectively we are looking for the coefficient of x 9 x^{9} in ( x 15 + x 7 + x 3 + x + 1 ) 7 (x^{15} + x^7 + x^3 + x + 1)^7 . We then note that the x 15 x^{15} cannot contribute to this coefficient, so we only need to look at ( x 7 + x 3 + x + 1 ) 7 (x^7 + x^3 + x + 1)^7 .

The general term of this polynomial will have form

( 5 α 1 , α 2 , α 3 , α 4 ) ( x 7 ) α 1 ( x 3 ) α 2 ( x ) α 3 ( 1 ) α 4 \dbinom{5}{\alpha_1, \alpha_2, \alpha_3, \alpha_4} \left( x^7 \right)^{\alpha_1} \left( x^3 \right)^{\alpha_2} (x)^{\alpha_3} (1)^{\alpha_4}

We know that α 1 + α 2 + α 3 + α 4 = 7 \alpha_1 + \alpha_2 + \alpha_3 + \alpha_4 = 7 ; to find the coefficient of x 9 x^{9} , we also need 7 α 1 + 3 α 2 + α 3 = 9 7 \alpha_1 + 3 \alpha_2 + \alpha_3 = 9 .

We can re-write the second condition as α 3 = 9 7 α 1 3 α 2 \alpha_3 = 9 - 7 \alpha_1 - 3 \alpha_2 ; using this, we re-write the first condition as α 4 = 6 α 1 + 2 α 2 2 \alpha_4 = 6 \alpha_1 + 2 \alpha_2 - 2 .

This means we have restrictions 7 α 1 + 3 α 2 9 7 \alpha_1 + 3 \alpha_2 \le 9 and 6 α 1 + 2 α 2 2 6 \alpha_1 + 2 \alpha_2 \ge 2 .

Applying those restrictions to the conditions, we find that the four possible sets of values for ( α 1 , α 2 , α 3 , α 4 ) (\alpha_1, \alpha_2, \alpha_3, \alpha_4) are ( 0 , 1 , 6 , 0 ) ; ( 0 , 2 , 3 , 2 ) ; ( 0 , 3 , 0 , 4 ) ; (0, 1, 6, 0); (0, 2, 3, 2); (0, 3, 0, 4); and ( 1 , 0 , 2 , 4 ) (1, 0, 2, 4) .

Then the coefficient of x 9 x^{9} in ( x 7 + x 3 + x + 1 ) 7 (x^7 + x^3 + x + 1)^7 is

( 7 0 , 1 , 6 , 0 ) + ( 7 0 , 2 , 3 , 2 ) + ( 7 0 , 3 , 0 , 4 ) + ( 7 1 , 0 , 2 , 4 ) = 7 + 210 + 35 + 105 = 357 \dbinom{7}{0, 1, 6, 0} + \dbinom{7}{0, 2, 3, 2} + \dbinom{7}{0, 3, 0, 4} + \dbinom{7}{1, 0, 2, 4} = 7 + 210 + 35 + 105 = 357

and so there are 357 357 strings of length 7 7 .

Repeating this process for all other possible lengths yields the following table, where n n is the length of a string, and s n s_n the number of strings of length n n :

n s n 1 1 2 1 3 3 4 13 5 75 6 165 7 357 8 645 9 927 10 1095 11 957 12 627 13 299 14 91 15 15 16 1 \begin{array}{|c|c|} \hline \ n \ & s_n \\ \hline 1 & 1 \\ 2 & 1 \\ 3 & 3 \\ 4 & 13 \\ 5 & 75 \\ 6 & 165 \\ 7 & 357 \\ 8 & 645 \\ 9 & 927 \\ 10 & 1095 \\ 11 & 957 \\ 12 & 627 \\ 13 & 299 \\ 14 & 91 \\ 15 & 15 \\ 16 & 1 \\ \hline \end{array}

Adding these up gives a total of 5272 \boxed{5272} rhythms.

filler filler {\color{#FFFFFF} \text{filler}} \\ {\color{#FFFFFF} \text{filler}}

METHOD 2:

Rather than focusing specifically on strings with a sum of 16 16 , we consider strings with a sum of k k for any k N k \in \mathbb{N} , and look for a recursive formula for t k t_k , the number of strings with sum k k .

To simplify the reasoning, we first consider 9 k 15 9 \le k \le 15 . To make a string with sum k k , we could take a string with sum k 1 k - 1 and append a 1 1 ; or we could take a string with sum k 2 k - 2 and append a 2 2 ; or we could take a string with sum k 4 k - 4 and append a 4 4 ; or we could take a string with sum k 8 k - 8 and append an 8 8 . This then leads to the recursion t k = t k 1 + t k 2 + t k 4 + t k 8 t_k = t_{k-1}+ t_{k-2}+ t_{k-4}+ t_{k-8} . We can extend this to lower values of k k by using the convention t i = 0 t_i = 0 whenever i 0 i \le 0 . However , we have to be a little more careful when k k is a power of 2 2 .

Consider strings with a sum of 8 8 . We can make such strings by taking strings of length 7 7 and appending a 1 1 , or taking strings of length 6 6 and appending a 2 2 , or taking strings of length 4 4 and appending a 4 4 ; but we can also form one more string by using a single 8 8 . Thus whenever k k is a power of 2 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 t_k = t_{k-1}+ t_{k-2}+ t_{k-4}+ t_{k-8} + 1 .

The first few values of t k t_k are easily found: t 1 = 1 t_1 = 1 ( the only possible string is ( 1 ) (1) ); t 2 = 2 t_2 = 2 ( the strings are ( 2 ) (2) or ( 1 , 1 ) (1, 1) ); and t 3 = 3 t_3 = 3 (the strings are ( 2 , 1 ) , ( 1 , 2 ) (2, 1), (1, 2) and ( 1 , 1 , 1 ) (1, 1, 1) ). After that we apply the recursive formula, being careful to add the extra 1 1 whenever k k is a power of 2. This yields the following table:

k t k 1 1 2 2 3 3 4 6 5 10 6 18 7 31 8 56 9 98 10 174 11 306 12 542 13 956 14 1690 15 2983 16 5272 \begin{array}{|c|c|} \hline \ k \ & t_k \\ \hline 1 & 1 \\ 2 & 2 \\ 3 & 3 \\ 4 & 6 \\ 5 & 10 \\ 6 & 18 \\ 7 & 31 \\ 8 & 56 \\ 9 & 98 \\ 10 & 174 \\ 11 & 306 \\ 12 & 542 \\ 13 & 956 \\ 14 & 1690 \\ 15 & 2983 \\ 16 & 5272 \\ \hline \end{array}

and again we find that there are a total of 5272 \boxed{5272} rhythms.

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.)

David Vreken - 2 years, 11 months ago

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.

zico quintina - 2 years, 11 months ago

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 16 x^{16} is in the expansion of 1 1 ( x + x 2 + x 4 + x 8 + x 16 ) \frac{1}{1-(x+x^2+x^4+x^8+x^{16})} (I try to avoid the slog)

Brian Moehring - 2 years, 10 months ago

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.)

Calvin Lin Staff - 2 years, 10 months ago

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:

  • Count the number of ways to have a 1 a_1 whole, a 2 a_2 half, a 3 a_3 quarter, a 4 a_4 eighth, and a 5 a_5 sixteenth notes in a measure of arbitrary length. This is the multinomial coefficient ( a 1 + a 2 + a 3 + a 4 + a 5 a 1 , a 2 , a 3 , a 4 , a 5 ) \binom{a_1+a_2+a_3+a_4+a_5}{a_1,a_2,a_3,a_4,a_5} .
  • Using the multinomial theorem and geometric series, we can therefore recognize the corresponding generating function as 1 1 ( z 1 + z 2 + z 3 + z 4 + z 5 ) = n = 0 ( z 1 + z 2 + z 3 + z 4 + z 5 ) n \displaystyle \frac{1}{1-(z_1+z_2+z_3+z_4+z_5)} = \sum_{n=0}^\infty (z_1+z_2+z_3+z_4+z_5)^n so that the coefficient of z 1 a 1 z 2 a 2 z 3 a 3 z 4 a 4 z 5 a 5 z_1^{a_1}z_2^{a_2}z_3^{a_3}z_4^{a_4}z_5^{a_5} is ( a 1 + a 2 + a 3 + a 4 + a 5 a 1 , a 2 , a 3 , a 4 , a 5 ) \binom{a_1+a_2+a_3+a_4+a_5}{a_1,a_2,a_3,a_4,a_5} .
  • Now we assign deg ( z k ) = 2 5 k \deg(z_k) = 2^{5-k} to make the degrees equal the equivalent number of sixteenth notes. Therefore, if we sum the coefficients corresponding to the terms with degree 16 16 , we will have the number of ways to make a measure of length equivalent to 16 16 sixteenth notes.

In order to sum all the terms of degree 16 16 , it's simply easier to replace the multiple variables given with powers of a single variable x x to which we assign degree 1 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.

Brian Moehring - 2 years, 10 months ago

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 n approved notes (order matters) to create one bar is the coefficient of x 16 x^{16} in ( x 1 + x 2 + x 4 + x 8 + x 16 ) n ( x^1 + x^2 + x^4 + x^8 + x^ {16} ) ^ n .
Hence, the number of ways to use any number of approved notes (order matters) to create one bar is the coefficient of x 16 x^{16} in n = 0 ( x 1 + x 2 + x 4 + x 8 + x 16 ) n = 1 1 ( x 1 + x 2 + x 4 + x 8 + x 16 ) . \sum_{n=0}^{\infty} ( x^1 + x^2 + x^4 + x^8 + x^ {16} ) ^ n = \frac{ 1} { 1 - ( x^1 + x^2 + x^4 + x^8 + x^ {16} ) } .

Calvin Lin Staff - 2 years, 10 months ago

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.

Peter Macgregor - 2 years, 10 months ago

Log in to reply

Very nice way of counting the distinct rythms using wolfram alpha.

Vinod Kumar - 2 years, 10 months ago

FYI Per Arjen's solution, in your method 2, what you want is to set t 0 = 1 t_0 = 1 and t i = 0 t_i = 0 for i < 0 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).

Calvin Lin Staff - 2 years, 10 months ago

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?

Aleix Ferrer - 2 years, 10 months ago

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.

Calvin Lin Staff - 2 years, 10 months ago

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.

Aleix Ferrer - 2 years, 10 months ago

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

  1. w-1, (1),

  2. hh-2, (1),

  3. hqq-3, (3!/2!=3),

  4. hqee-4, (4!/2!=12),

  5. hqsse-5, (5!/2!=60),

  6. hqssss-6, (6!/4!=30),

  7. heeee-5, (5!/4!=5),

  8. heeess-6, (6!/3!2!=60),

  9. heessss-7, (7!/4!2!=105),

  10. hessssss-8, (8!/6!=56),

  11. hssssssss-9, (9!/8!=9),

  12. qqqq-4, (1),

  13. qqqee-5, (5!/3!2!=10),

  14. qqeeee-6, (6!/4!2!=15),

  15. qeeeeee-7, (7!/6!=7),

  16. qqqess-6, (6!/3!2!=60),

  17. qqqssss-7, (7!/4!3!=35),

  18. qqeeess-7, (7!/3!2!2!=210),

  19. qqeessss-8, (8!/4!2!2!=420),

  20. qqessssss-9, (9!/6!2!=252),

  21. qqssssssss-10, (10!/8!2!=45),

  22. qeeeeess-8, (8!/5!2!=168),

  23. qeeeessss-9, (9!/4!4!=630),

  24. qeeessssss-10, (10!/6!3!=840),

  25. qeessssssss-11, (11!/8!2!=495),

  26. qessssssssss,12, (12!/10!=132),

  27. qssssssssssss-13, (13!/12!=13),

  28. eeeeeeee-8, (1),

  29. eeeeeeess-9, (9!/7!2!=36),

  30. eeeeeessss-10, (10!/6!4!=210),

  31. eeeeessssss-11, (11!/6!5!=462),

  32. eeeessssssss-12, (12!/8!4!=495),

  33. eeessssssssss-13, (13!/10!3!=286),

  34. eessssssssssss-14, (14!/12!2!=91),

  35. essssssssssssss-15, (15!/14!=15),

  36. 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,

  2. 1,

  3. 3,

  4. 13,

  5. 75,

  6. 165,

  7. 357,

  8. 645,

  9. 927,

  10. 1095,

  11. 957,

  12. 627,

  13. 299,

  14. 91,

  15. 15,

  16. 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,

  1. Rythm with (whole note) : 1,

  2. Number of distinct rythms with one or more (half note): 341,

  3. Number of distinct rythms with at least one quarter note (no half note): 3333,

  4. Number of distinct rythms with at least one 1/8 note ( no quarter note and no half note): 1596,

  5. Purely 1/16 note rythm:1

Vinod Kumar - 2 years, 10 months ago
Arjen Vreugdenhil
Jul 22, 2018

Let R R_\ell be the number of patterns with a total length of \ell sixteenths notes. Each such pattern starts with a note of length a a sixteenths, followed by a pattern of length a \ell-a , where a = 1 , 2 , 4 , 8 , 16 a = 1,2,4,8,16 ; thus we have the recursion R = R 16 + R 8 + R 4 + R 2 + R 1 . R_\ell = R_{\ell-16} + R_{\ell-8} + R_{\ell-4} + R_{\ell-2} + R_{\ell-1}. We set R 0 = 1 R_0 = 1 (there is one trivial valid pattern of zero length), and R = 0 R_\ell = 0 for negative values of \ell .

Once we implement this sequence, the answer to the problem is simply R 16 R_{16} .


Dynamic programming implementation

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include<stdio.h>

#define length 16
int values[] = { 1,2,4,8,16,0 };

int rhythms[length+1];

int main() {
    rhythms[0] = 1;

    for (int L = 1; L <= length; L++) {
        rhythms[L] = 0;
        for (int i = 0; values[i] != 0; i++) if (L - values[i] >= 0)
            rhythms[L] += rhythms[L - values[i]];

        printf("Length %2d/16 notes: %10d rhythms.\n", L, rhythms[L]);
    }
}

Output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Length  1/16 notes:          1 rhythms.
Length  2/16 notes:          2 rhythms.
Length  3/16 notes:          3 rhythms.
Length  4/16 notes:          6 rhythms.
Length  5/16 notes:         10 rhythms.
Length  6/16 notes:         18 rhythms.
Length  7/16 notes:         31 rhythms.
Length  8/16 notes:         56 rhythms.
Length  9/16 notes:         98 rhythms.
Length 10/16 notes:        174 rhythms.
Length 11/16 notes:        306 rhythms.
Length 12/16 notes:        542 rhythms.
Length 13/16 notes:        956 rhythms.
Length 14/16 notes:       1690 rhythms.
Length 15/16 notes:       2983 rhythms.
Length 16/16 notes:       5272 rhythms.

Tom Verhoeff
Jul 23, 2018

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

WingYin Tang - 2 years, 10 months ago
Mark Hennings
Jul 23, 2018

Let P ( n ) P(n) be the number of rhythms occupying n n sixteenth notes, and let P ( k , n ) P(k,n) be the number of rhythms occupying n n sixteenth notes that use precisely k k notes. Then P ( k , n ) = a + b + c + d + e = k a + 2 b + 4 c + 8 d + 16 e = n k ! a ! b ! c ! d ! e ! P(k,n) \; = \; \sum_{{a+b+c+d+e=k} \atop {a + 2b + 4c + 8d + 16e = n}} \frac{k!}{a! b! c! d! e!} is the coefficient of x n x^n in ( x + x 2 + x 4 + x 8 + x 16 ) k (x + x^2 + x^4 + x^8 + x^{16})^k . Moreover P ( n ) = k 0 P ( k , n ) P(n) \; = \; \sum_{k \ge 0} P(k,n) is the coefficient of x n x^n in k 0 ( x + x 2 + x 4 + x 8 + x 16 ) k \sum_{k \ge 0}(x + x^2 + x^4 + x^8 + x^{16})^k . Thus we have the generating function n 0 P ( n ) x n = 1 1 x x 2 x 4 x 8 x 16 \sum_{n \ge 0}P(n)x^n \; = \; \frac{1}{1 - x - x^2 - x^4 - x^8 - x^{16}} and hence P ( n ) = P ( n 1 ) + P ( n 2 ) + P ( n 4 ) + P ( n 8 ) + P ( n 16 ) P(n) \; = \; P(n-1) + P(n-2) + P(n-4) + P(n-8) + P(n-16) from which it is easy to calculate that P ( 16 ) = 5272 P(16) = \boxed{5272} .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...