[Math] Magic square of a given date

magic square

How to create a magic square if we know a date. Eg-22-04-2014
The first column should have 22 2nd-04 3rd-20 and 4th -14. I believe ramanujan created the same thing for his birthday but I don't know the method he used. Please help.
Is there any method to do it?
I tried doing it using the fact that the row diagonal 2*2 square sum should all be equal to the total sum of the first row in this case 22+4+20+14=60

Best Answer

Let the magic square be $\begin{bmatrix}a & b & c & d \\ x_1 & x_2 & x_3 & x_4 \\ x_5 & x_6 & x_7 & x_8 \\ x_9 & x_{10} & x_{11} & x_{12}\end{bmatrix}$ where $a,b,c,d$ represents the date.

The conditions that the rows, columns, and diagonals sum to $a+b+c+d$ gives us $9$ linear equations for $12$ variables. The resulting system has rank $8$.

Therefore, any solution can be obtained by taking a particular solution and adding a linear combination of $12-8 = 4$ "basis vectors" for the nullspace of the system.

The matrix $\begin{bmatrix}a & b & c & d \\ c & d & a & b \\ d & c & b & a \\ b & a & d & c\end{bmatrix}$ is a magic square with the correct top row.

The following $4$ matrices form a basis of the nullspace of the system (all rows, cols, diags sum to $0$):

$\begin{bmatrix}0 & 0 & 0 & 0\\ 2 & -1 & -1 & 0 \\ -2 & 1 & 1 & 0 \\ 0 & 0 & 0 & 0\end{bmatrix}$, $\begin{bmatrix}0 & 0 & 0 & 0\\ 1 & 0 & 0 & -1 \\ -1 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0\end{bmatrix}$, $\begin{bmatrix}0 & 0 & 0 & 0\\ 1 & 0 & -1 & 0 \\ -1 & 1 & 0 & 0 \\ 0 & -1 & 1 & 0\end{bmatrix}$, $\begin{bmatrix}0 & 0 & 0 & 0\\ 2 & -1 & 0 & -1 \\ -1 & 1 & 0 & 0 \\ -1 & 0 & 0 & 1\end{bmatrix}$.

Take the first matrix and add any linear combination of the above four matrices to get a solution.