 |
Ask A Scientist
Mathematics Archive
|
 |
Magic square algorithm
Author: ankur srivastava
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?
Response #: 1 of 1
Author: tee
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
shown below.
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
NEWTON is an electronic community for Science, Math, and Computer Science K-12 Educators.
Argonne National Laboratory, Division of Educational Programs, Harold Myron, Ph.D., Division Director.