Magic square algorithm
Name: ankur srivastava
Date: Around 1995
Suppose there is a matrix N x N. You have to put non-repetitive positive
integers in each square that is a matrix element. For example, rc (i,j)
where i = 1 to N, j = 1 to N, so that the sum of each row, column, and
diagonal is the same. Is there an algorithm to calculate a series of sums?
Is there an algorithm which can tell for a given sum whether a matrix can be
formed and what each element rc(i, j) would be and whether this can be
generalized for any matrix size N x N?
The type of matrix you are trying to construct is called a magic square.
Most libraries with a reasonable math collection should have something
available by searching under those key words. With luck you will find
Durer's "Melancholia" engraving of 1514 with spectacular analysis of its
substantial "magic" that goes way beyond the basic requirements. It is
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
Click here to return to the Mathematics Archives
Update: June 2012