3
$\begingroup$

A Magic Square of order n is an arrangement of $n^2$ numbers, usually distinct integers, in a square, such that the n numbers in all rows, all columns, and both diagonals sum to the same constant.

To construct Magic Squares of n-odd size, a method known as Siamese method is given on Wikipedia, the method is ::

starting from the central box of the first row with the number 1 (or
the first number of any arithmetic progression), the fundamental 
movement for filling the boxes is diagonally up and right (↗), one step
at a time. When a move would leave the square, it is wrapped around to 
the last row or first column, respectively.

If a filled box is encountered, one moves vertically down one box (↓)    
instead, then continuing as before.

enter image description here

How does this method work?

$\endgroup$
3
$\begingroup$

There is a detailed discussion of "the Siamese method," with proofs, at this website. There's also a proof here.

$\endgroup$
3
$\begingroup$

The basic idea is that you divide the numbers from $1$ to $n^2$ into blocks $(1,n), (n+1,2n), (2n+1,3n) \ldots (n^2-n+1,n^2)$ and think of them as $0+(1,n), n+(1,n), 2n+(1,n) \ldots n(n-1)+(1,n)$. Then you want each row to get each of $(1,n)$ and each column to get each of $(1,n)$. The various runs of $n$ numbers start one in each row and each column, so they each go one per row and column. Each multiple of $n$ also goes one per row and column. It is a Greco-Latin square, if you make the Greek letters correspond to $(1,n)$ and the Latin letters correspond to $(0,(n-1)n)$

$\endgroup$
  • $\begingroup$ It's not clear to me how this relates to the specific algorithm OP asks about. $\endgroup$ – Gerry Myerson Jul 27 '12 at 0:44
  • $\begingroup$ @GerryMyerson: I was hoping to explain that the diagonal movement distributes the numbers properly to ensure that each row and column get a number $1 \pmod n, 2 \pmod n 3 \pmod n \ldots 0 \pmod n$ and also a number in each bracket of $n$ numbers. Maybe it didn't come through. The site you cited looks very good. $\endgroup$ – Ross Millikan Jul 27 '12 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.