Tag Archives: diagonals

Making Math GIFs


Few months ago I wrote about the technologies we use today to share joy of mathematics. But, I overlooked one very important tool which we can use today: Graphics Interchange Format (GIF). For example, see this Tumblr blog: matan-matika.

Though I used this “technology” in one of my posts earlier this year, I didn’t know how to create my own animated GIF images.  So I started searching and stumbled on an HTML5 application by Pascal Bauermeister called MathVision . It is capable of generating mathematical art pictures using the contour plot technique. It uses simplified Java syntax and can be easily learnt by following this Instructable.

As an exercise in this Instructable, we are asked to make diagonal stripes, here is my attempt:

WIDTH = 350;
RATIO = 1;
X_MIN = 0; X_MAX = 10;
Y_MIN = 0; Y_MAX = 10;

color rgb(x, y) {
  int bu = y+x;
  int value = (int)bu % 2;
  int luma = value * 255;
  return color(luma);


Here is a “disturbing” animated spiral (note that it’s spinning in the direction opposite to the one given in instructable; just need to decrement time):

FRAMES = 10;
OUT_PAUSE = false;
WIDTH = 250;
RATIO = 1;
X_MIN = -1; X_MAX = 1;
Y_MIN = -1; Y_MAX = 1;

color rgb(x, y, t) {
float radius = dist(x, y, 0, 0);
float angle = -atan2(x, y);
angle = angle - t;

float value = angle*3 - (radius)*12;
float stripe = cos(value);

float luma = (stripe - 5) * 127;
return color(luma);


Today, 6-10-2016, is a Palindrome Day (if written in dd-mm-yyyy format)! So I end my post with this GIF I recorded using byzanz (on Ubuntu) and edited using ezgif.com:


Interesting Diagonal Discovery


Yesterday (while doodling in my Number Theory class) I was just playing with diagonals of polygons and something interesting appeared on my notebook. For the first time in my life I have discovered a theorem and its proof on my own (it’s original!). In this blog-post I will share it with you all!

Consider an n-sided polygon, and start drawing diagonals from each vertex one-by-one. While doing so count the number of new diagonals contributed by each vertex. Here is the “Experiment” done for n=4,5,6,7,8.

Number written near each vertex indicate the number of new diagonals contributed by that vertex (following anti-clockwise order and starting with the red one)

Number written near each vertex indicate the number of new diagonals contributed by that vertex (following anti-clockwise order and starting with the red one)

Based on above experiment, I observed:

The number of new diagonals contributed by each vertex of a n-sided polygon follows the sequence: (n-3),(n-3),(n-4),\ldots, 1,0,0

Now let’s try to  prove this observation:

Since we can’t draw diagonals to the adjacent vertices, each vertex will have (n-1)-2 = (n-3) diagonals.

Now, let’s count the new contribution of each vertex by considering restrictions on the maximum possible contribution (which is (n-3)).

For first vertex, we have no restriction, so it will contribute (n-3) diagonals.

Also, since second vertex in adjacent to first one and both can’t affect each-other’s contribution, it will also contribute (n-3) diagonals.

But, starting with third vertex we observe that first vertex has already taken one of the diagonals from its maximum contribution (second vertex can’t affect its contribution count since it’s adjacent vertex), thus it contributes (new) (n-3)-1 = (n-4) diagonals.

Continuing same way, for k^{th} vertex, consider the restriction to contribution caused by 1^{st} to (k-2)^{th} vertices. Thus for 1<k<n we get the number of new diagonals contributed by k^{th} vertex equal to (n-3)-(k-2) = (n-k-1).

Since new contribution can’t be negative and for (n-1)^{th} vertex we end up with zero (new) contribution, n^{th} vertex will also contribute zero diagonals.

Combining all of the above arguments I complete the proof of my observation and call it “New Diagonal Contribution Theorem” (NDCT).