Wednesday, August 12, 2015

Vizualizing some modulo-n series

The following is an algorithm able to calculate some generic modulo-n relationships in a very visual way:

a(n) = total number of vertices of a polygon (n-gon) that are a "final vertex" of aclass of curve defined at integer values which hops from one value to another (please see images below for reference), and is defined by the following algorithm:

(1) Define counter c=1.

(2) Start at any desired vertex and advance clockwise c vertices.

(3) Mark the current vertex as a "final vertex".

(4) c=c+1.

(5) Starting from the last final vertex, count clockwise up to c again, and mark that vertex as a "final vertex" as well.

(6) Repeat from (4).

It is cyclical: after some repetitions of steps (4)-(6), the cycle along the vertices is repeated and it is possible to count how many vertices of the n-gon contain a "final vertex" mark.

For instance these are some series that can be calculated by using the algorithm: 

1. When the n-gon is a triangle, it generates OEIS A117484 (Number of triangular numbers mod n) 

2. When the n-gon is a square, it generates OEIS A047452 (Numbers that are congruent to {1, 6} mod 8).

3. When the n-gon is a pentagon, it generates OEIS A047219 (Numbers that are congruent to {1, 3} mod 5).

4. When the n-gon is an hexagon, it generates the sequence of numbers that are congruent to {1,10} mod 12) (not registered at OEIS).

etc. (upper sequences are not registered at OEIS).

The main point is that the algorithm visualizes the bouncing patterns of the modulo-n series, this is how it looks like (this is the representation of the n-gons 3 to 14, 16, 17 and 27):


The more vertices are added, the easiest it is to visualize the bouncing patterns.

For instance, this is the basic one, the triangle (3-gon):


As it is very plane (3 vertices) it is not so easy to observe the bouncing, but in the case of the 27-gon the pattern is clear:


I think that the algorithm makes easier playing with the modulo-n properties, for instance somebody not familiar with modular arithmetic can initially play with these patterns and visualize the results, and then it can be explained in terms of modular arithmetic what is seen in the patterns.

No comments:

Post a Comment