Fun with Ramanujan’s Birthday Magic Square and Linear Algebra
One of the world’s most talented mathematicians, Srinivasa Aiyangar Ramanujan (1887–1920), was born on 22nd December 1887. Some of Ramanujan’s work on recreational mathematics and magic squares can be found in his early notebooks. A magic square is an NxN matrix in which every row, column, and diagonal sums up to the same number. The sum is called the magic constant or magic sum of the magic square. Ramanujan created the following birthday magic square from his date of birth (in DD MM YYYY format) where all four rows, four columns and two diagonals sum up to 139.
e.g. sum of all rows equals to 139.
22 + 12 + 18 + 87 = 139; 88 + 17+ 09 + 25 = 139; 10 + 24 + 89 + 16 = 139; 19 + 86 + 23 + 11 = 139
sum of all columns equals to 139
22 + 88 + 10 + 19 = 139; 12 + 17 + 24 + 86 = 139; 8 + 09 + 89 + 23 = 139; 87 + 25 + 16 + 11 = 139
sum of two diagonals equals to 139 as well
22 + 17 + 89 + 11 = 139; 19 + 24 + 09 + 87 = 139
In addition the 2x2 matrices in all four corners also sum up to 139
22 + 12 + 88 + 17 = 139; 18 + 87 + 09 + 25 =139;
10 + 24 + 19 + 86 = 139; 89 + 16 + 23+ 11=139;
sum of all the corner digits and central 2x2 matrix is also 139.
22 + 87 + 19 + 11 =139; 17 + 09 + 24 + 89 =139;
That seems like magic and hence the name — magic square. As depicted in the figure 1, there are different types of magic squares. Ramanujan’s birthday magic square is a complete magic square. Magic squares are not purely recreational, it has applications in Birkhoff — von Neumann decomposition, Quantum permutation matrices etc.
But how do we construct birthday magic square(s)? If we inspect the matrix closely we will notice there is a structure in it. If we denote: a = two digits date, b = two digits month, c = first two digits of year, d = last two digits of the year, in other words a=22, b=12, c=18, d=87.
the structure is …
So far so good, and given a birthday we can make any birthday magic squares with this method. But wait, what if somebody’s birthday is in January, February or March? Then the (b-3) or (b-2) or (b-1) term can become negative or zero. The (d-1) term can also become negative for some birth years (e.g. 2000) etc. Also duplicate numbers can get generated this way.
Question comes to mind — are there other ways of making birthday magic squares? If yes, how do we generate magic squares such that generated numbers are all greater than zero and are all unique numbers (when a, b, c, d are all unique numbers)?
So, I created another variation for generating magic squares,
This new method generates the following complete magic square from Ramanujan’s birthday:
Are there more ways of making magic squares? Well the new matrix can be accomplished by adding another matrix to the original magic square matrix or vice versa. e.g.
or, we can also write,
More generally,
Where x can be any positive or negative integer. We can also very easily write a program that will generate all possible magic squares from a birthday that has all positive numbers and/or all unique numbers in it.
A computer code generated the following magic squares from Ramanujan’s birthday where all numbers are unique and greater than zero. Here we started with the new method and generated all others including Ramanujan’s original one (*).
If we allow negative numbers in the matrix, there can be infinite number of complete magic squares possible once we write one. Which is obviously countable infinity. And if we relax the constraint and allow x as real number instead of integer we can generate uncountable infinite number of magic squares.
The new matrix is also a complete magic square with same magic constant, 139.
Have fun creating birthday magic squares or magic squares for any occasions …