Shen:   regular and special patterns

Shen creates magic squares of single-even order using regular patterns presented in his method dor double-even squares. He uses patterns for squares of size n − 2, which he are followed by lr or rl for the middle two rows and tb or bt for the middle two columns. Due to the lack of symmetry, the magic property must now be created through additional exchanges, which can be achieved in a variety of ways.

The insertion of the additional patterns for the middle rows and columns reduces the swapping to a minimum, and at the same time offers the possibility to simplify the algorithm.

123456
789101112
131415161718
192021222324
252627282930
313233343536

As always, Shen starts with a square in natural order and then reverses individual rows and columns according to the regular patterns.

  • 123456l
    121110987r
    181716151413r
    192021222324l
    302928272625r
    313233343536l
    btbttb
  • 312334536l
    3011289825r
    191721151424r
    182016222313l
    12291027267r
    132334356l
    btbttb

This means that all column and row sums with except the two middle rows have the magic sum 111. These two rows have the totals 112 and 110 so that a balance can be achieved if you swap with 18 and 19 two adjacent numbers at the left column and also swap the middle block of four numbers vertically reversed as shown in the figure on the left.

  • 312334536
    3011289825
    181716221424
    192021152313
    12291027267
    132334356
  • 312334536
    3011289825
    181617221424
    192120152313
    12291027267
    132334356

Now all rows and columns have the magic sum 111 and only the two diagonals need to be adjusted. Their sums are 117 and 105, so 6 too large or too small. It is noticeable that the pairs of corners differ by 5 each. Now we are only looking for a neighboring pair of numbers that differ in value by 1 and whose smaller number can be brought to the main diagonal by swapping. So, the column sums do not change and another adjacent pair with the opposite difference is also exchanged as in the figure on the right.

Now the sum of the numbers on the main diagonal 116 and that of the secondary diagonal is 106, so that a simple exchange of the two upper corners compensates for these differences. However, to ensure that the associated column totals do not change, another pair of numbers must be exchanged for compensation. This creates the magic square of order n=6.

362334531
2511289830
181617221424
192120152313
12291027267
132334356

Example n=10

This algorithm will be shown again using an example of order n=10 to demonstrate, how a magic square can be constructed with a few interchanges. First, in a square of natural order, a few rows and columns are reversed according to the selected patterns as usual.

1099897695949321r
11128384158687881920l
30297877267574732221r
31326364356667683940l
41425857455554534950l
60594344564647485251r
61623334653637386970l
80792827762524237271r
81821314851617188990l
1009987965439291r
ttbbtbbbtt

This square is almost semi-magic, only the two middle rows with sums 506 and 504 each differ by 1 from the magic sum 505. This can be compensated for by swapping two numbers in the border without having to create an additional compensation this time.

Another exchange of pairs of numbers decreases or increases the sums on the two diagonals by 1, which currently differ by a value of 10 from the magic sum

1099897695949321
11128384158687881920
30297877267574732221
31326364356667683940
41425857455455534951
60594344564746485250
61623334653637386970
80792827762524237271
81821314851617188990
1009987965439291

Now the diagonals only deviate from the magic sum by a value of 9, so that a simple exchange of the two lower corners compensates these differences. However, to ensure that the associated column totals do not change, another pair of numbers must be exchanged for compensation. This creates the magic square of order n=10.