Quick update on the last post. I have shown a graph for the length of rhythmic canons mod 2 with motive , and we have seen that the dependence of the length with is everything but simple, with particular cases when or . I wanted to check what happens for values of higher than 41, but it turns out that the computation of the length is now very slow. I managed to get the lengths for , and these are the red points in the updated graph below. I am waiting for other values of , but the computation for (haha…) took nearly two weeks, so this won’t be for tomorrow.

What are the green points by the way ? Well, I’m sure you have noticed that the previous code can easily be adapted to get rhythmic canons for any modulus, and not only 2. Here is an improved C program for calculating the length L (and entries) of a canon mod P with motive . Notice that you will get the version of the canon where entries may be repeated, and that you may “unravel the modulus” of any entry at position by considering another entry at position . The green points in the graph above are the length of the canons with motive modulus 3.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
int N,P;
int* U;
int i,mark=0,flag=0;
unsigned long long L,entry=0;
FILE* output_file=NULL;
if(argc<3) {
printf("Length of the motive is required !\n");
exit(1);
}
N = atoi(argv[1]);
P = atoi(argv[2]);
if(argc==4)
output_file=fopen(argv[4],"w");
if (output_file!=NULL)
fprintf(output_file,"Entries for canon with motive {0,1,%d}\n",N);
U = calloc(N+1,sizeof(int));
if (U==NULL) {
printf("Error during memory allocation...exiting now !\n");
exit(1);
}
L=N+1;
while(flag==0) {
L+=mark;
entry+=mark;
if (output_file!=NULL)
fprintf(output_file,"%llu\n",entry);
U[0]= (U[0]+1) % P;
U[1]= (U[1]+1) % P;
U[N]= (U[N]+1) % P;
flag=1;
for (mark=0; mark<N+1; mark++) {
if (U[mark]!=1) {
flag=0;
break;
}
}
for (i=mark; i<N+1; i++)
U[i-mark]=U[i];
for (i=(N+1-mark); i<N+1; i++)
U[i]=0;
}
printf("Final length of canon with motive {0,1,%d}: %llu \n",N,L);
if (output_file!=NULL)
fclose(output_file);
free(U);
}

Interestingly, it seems that any canon with motive has length , and any canon with motive has length . I am guessing that for any prime modulus, a similar relation exists…

### Like this:

Like Loading...

*Related*