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.
1 | 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |
31 | 32 | 33 | 34 | 35 | 36 |
As always, Shen starts with a square in natural order and then reverses individual rows and columns according to the regular patterns.
1 | 2 | 3 | 4 | 5 | 6 | l |
12 | 11 | 10 | 9 | 8 | 7 | r |
18 | 17 | 16 | 15 | 14 | 13 | r |
19 | 20 | 21 | 22 | 23 | 24 | l |
30 | 29 | 28 | 27 | 26 | 25 | r |
31 | 32 | 33 | 34 | 35 | 36 | l |
b | t | b | t | t | b |
31 | 2 | 33 | 4 | 5 | 36 | l |
30 | 11 | 28 | 9 | 8 | 25 | r |
19 | 17 | 21 | 15 | 14 | 24 | r |
18 | 20 | 16 | 22 | 23 | 13 | l |
12 | 29 | 10 | 27 | 26 | 7 | r |
1 | 32 | 3 | 34 | 35 | 6 | l |
b | t | b | t | t | b |
This means that all column and row sums with the exception of 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.
31 | 2 | 33 | 4 | 5 | 36 |
30 | 11 | 28 | 9 | 8 | 25 |
18 | 17 | 16 | 22 | 14 | 24 |
19 | 20 | 21 | 15 | 23 | 13 |
12 | 29 | 10 | 27 | 26 | 7 |
1 | 32 | 3 | 34 | 35 | 6 |
31 | 2 | 33 | 4 | 5 | 36 |
30 | 11 | 28 | 9 | 8 | 25 |
18 | 16 | 17 | 22 | 14 | 24 |
19 | 21 | 20 | 15 | 23 | 13 |
12 | 29 | 10 | 27 | 26 | 7 |
1 | 32 | 3 | 34 | 35 | 6 |
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.
36 | 2 | 33 | 4 | 5 | 31 |
25 | 11 | 28 | 9 | 8 | 30 |
18 | 16 | 17 | 22 | 14 | 24 |
19 | 21 | 20 | 15 | 23 | 13 |
12 | 29 | 10 | 27 | 26 | 7 |
1 | 32 | 3 | 34 | 35 | 6 |
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 of all, in a square ofwith a natural order of the numbers, a few rows and columns are reversed according to the selected patterns as usual.
10 | 9 | 98 | 97 | 6 | 95 | 94 | 93 | 2 | 1 | r |
11 | 12 | 83 | 84 | 15 | 86 | 87 | 88 | 19 | 20 | l |
30 | 29 | 78 | 77 | 26 | 75 | 74 | 73 | 22 | 21 | r |
31 | 32 | 63 | 64 | 35 | 66 | 67 | 68 | 39 | 40 | l |
41 | 42 | 58 | 57 | 45 | 55 | 54 | 53 | 49 | 50 | l |
60 | 59 | 43 | 44 | 56 | 46 | 47 | 48 | 52 | 51 | r |
61 | 62 | 33 | 34 | 65 | 36 | 37 | 38 | 69 | 70 | l |
80 | 79 | 28 | 27 | 76 | 25 | 24 | 23 | 72 | 71 | r |
81 | 82 | 13 | 14 | 85 | 16 | 17 | 18 | 89 | 90 | l |
100 | 99 | 8 | 7 | 96 | 5 | 4 | 3 | 92 | 91 | r |
t | t | b | b | t | b | b | b | t | t |
This square is almost semimagic, 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 on the edge 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
10 | 9 | 98 | 97 | 6 | 95 | 94 | 93 | 2 | 1 |
11 | 12 | 83 | 84 | 15 | 86 | 87 | 88 | 19 | 20 |
30 | 29 | 78 | 77 | 26 | 75 | 74 | 73 | 22 | 21 |
31 | 32 | 63 | 64 | 35 | 66 | 67 | 68 | 39 | 40 |
41 | 42 | 58 | 57 | 45 | 54 | 55 | 53 | 49 | 51 |
60 | 59 | 43 | 44 | 56 | 47 | 46 | 48 | 52 | 50 |
61 | 62 | 33 | 34 | 65 | 36 | 37 | 38 | 69 | 70 |
80 | 79 | 28 | 27 | 76 | 25 | 24 | 23 | 72 | 71 |
81 | 82 | 13 | 14 | 85 | 16 | 17 | 18 | 89 | 90 |
100 | 99 | 8 | 7 | 96 | 5 | 4 | 3 | 92 | 91 |
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.