(consecutively concentric squares)
The bones 4(n-1) border numbers form 2(n-1) ± pairs. The + numbers are in the range:
((n-2)²+1)/2 to (n²-1)/2
The sum of each bones row, column, and main diagonal is 0.
Therefore, the border constraints are:
Note that the center 4x4 square is not a bordered square; its center 2x2 square is not magic.
The square is divided into the following regions:
Define rrel = |row - (n+1)/2|, crel = |column - (n+1)/2|.
Then, the basic formula used here to compute a cell number is 2x² + y + c,
where, for each region:
The algorithm is:
Summary:
region x y c sign -------- ----------- ----------- ------- ---------- NW rrel 0 0 + SE rrel 0 0 - NNW rrel crel-2rrel ½ -+ SSW rrel crel-2rrel ½ +- N-E rrel -rrel,2rrel ½,0 - S-E rrel -rrel,2rrel ½,0 + NNE rrel crel+rrel 0 +- SSE rrel crel+rrel 0 -+ NE rrel 0 1 + SW rrel 0 1 - ENE crel -rrel ½ (-+)(+-)-+ WNW crel -rrel ½ (+-)(-+)+- E-N crel crel ½ -+ W-N crel crel ½ +- E-S crel 2crel,-crel 0,½ (-)+ W-S crel 2crel,-crel 0,½ (+)- ESE crel rrel ½ (-)-+ WSW crel rrel ½ (+)+-
Is the algorithm correct for all even order, (> 4), squares?
It is sufficient to check the border, since the test applies recursively to the nested squares down to order 6.
Let B be the bones, m = (n+1)/2, and X = 2(1-m)² = 2(n-m)².
For row 1: rrel = m-1, crel = m-1, .. ,½,½, .. ,n-m.
NW: B(1,1) = X NNW: B(1,m-1½) = X + 1½ - 2(m-1) + ½ = X - 2m + 4 NNW: B(1,m-½) = -(X + ½ - 2(m-1) + ½) = -X + 2m - 3 N-E: B(1,m+½) = -(X -(m-1) + ½) = -X + m - 1½ NNE: B(1,m+1½) = -(X + 1½ + (m-1)) = -X - m - ½ NE: B(1,n) = X + 1 The sum of these 6 is 0. The remaining NNW numbers are ±(X + (crel - 2rrel) + ½). NNW: B(1,2) = X + (m-2) - 2(m-1) + ½ = X - m + ½ NNW: B(1,3) = -(X + (m-3) - 2(m-1) + ½) = -X + m + ½ … The sum of each of these (n-6)/4 pairs is 1. The remaining NNE numbers are ±(X + (crel + rrel)). … NNE: B(1,n-2) = X + (n-2-m) + (m-1) X + n - 3 NNE: B(1,n-1) = -(X + (n-1-m) + (m-1)) = -X - n + 2 The sum of each of these (n-6)/4 pairs is -1.
Row 1 total is 0 + (n-6)/4 - (n-6)/4 = 0.
Rows 2 to n-1 have ± the same numbers at each end.
Row n total is 0, (it contains ± the same numbers as row 1).
For column 1: rrel = m-1, .. ,½,½, .. ,n-m, crel = m-1.
NW: B(1,1) = X WNW: B(m-1½,1) = -(X - 1½ + ½) = -X + 1 W-N: B(m-½,1) = X + (m-1) + ½ = X + m - ½ W-S: B(m+½,1) = -(X + 2(m-1)) = -X -2m + 2 WSW: B(m+1½,1) = X + 1½ + ½ = X + 2 SW: B(n,1) = -(X + 1) = -X - 1 The sum of these 6 is -(n - 6)/2. The remaining WNW numbers are ±(X - rrel + ½) WNW: B(2,1) = -(X - (m-2) + ½) = -X + m - 2½ WNW: B(3,1) = X - (m-3) + ½ = X - m + 3½ … The sum of each of these (n-6)/4 pairs is 1. The remaining WSW numbers are ±(X + rrel + ½) … WSW: B(n-2,1) = -(X + (n-2-m) + ½) = -X - n + m + 1½ WSW: B(n-1,1) = X + (n-1-m) + ½ = X + n - m - ½ The sum of each of these (n-6)/4 pairs is 1.
Column 1 total is -(n-6)/2 + (n-6)/4 + (n-6)/4 = 0.
Columns 2 to n-1 have ± the same numbers at each end.
Column n total is 0, (it contains ± the same numbers as column 1).
For row 1: rrel = m-1, crel = m-1, .. ,½,½, .. ,n-m.
NW: B(1,1) = X NNW: B(1,m-½) = -(X + ½ - 2(m-1) + ½) = -X + 2m - 3 N-E: B(1,m+½) = -(X + 2(m-1)) = -X - 2m + 2 NE: B(1,n) = X + 1 The sum of these 4 is 0. The remaining NNW numbers are ±X + (crel - 2rrel) + ½ NNW: B(1,2) = -(X + (m-2) - 2(m-1) + ½) = -X + m - ½ NNW: B(1,3) = X + (m-3) - 2(m-1) + ½ = X - m - ½ … The sum of each of these (n-4)/4 pairs is -1. The remaining NNE numbers are ±(X + (crel + rrel)). … NNE: B(1,n-2) = -(X + (n-2-m) + (m-1)) = -X - n + 3 NNE: B(1,n-1) = X + (n-1-m) + (m-1) = X + n - 2) The sum of each of these (n-4)/4 pairs is 1.
Row 1 total is 0 - (n-4)/4 + (n-4)/4 = 0.
Rows 2 to n-1 have ± the same numbers at each end.
Row n total is 0, (it contains ± the same numbers as row 1).
For column 1: rrel = m-1, .. ,½,½, .. ,n-m, crel = m-1.
NW: B(1,1) = X These 2, if n > 8. WNW: B(m-4½,1) = X - 4½ + ½ = X - 4 WNW: B(m-3½,1) = X - 3½ + ½ = X - 3 WNW: B(m-2½,1) = -(X - 2½ + ½) = -X + 2 WNW: B(m-1½,1) = -(X - 1½ + ½) = -X + 1 W-N: B(m-½,1) = -(X + (m-1) + ½) = -X - m + ½ If n = 8: W-S: B(m+½,1) = X - (m-1) + ½ = X - m + 1½ If n > 8: W-S: B(m+½,1) = -(X - (m-1) + ½) = -X + m - 1½ WSW: B(m+1½,1) = X + 1½ + ½ = X + 2 WSW: B(m+2½,1) = X + 2½ + ½ = X + 3 These 2, if n > 8. WSW: B(m+3½,1) = -(X + 3½ + ½) = -X - 4 WSW: B(m+4½,1) = X + 4½ + ½ = X + 5 SW: B(n,1) = -(X + 1) = -X - 1 The sum of these 8 or 12 is 0. For n > 12, the remaining numbers are: The remaining WNW numbers are ±(X - rrel + ½). WNW: B(2,1) = X - (m-2) + ½ = X - m + 2½ WNW: B(3,1) = -(X - (m-3) + ½) = -X + m - 3½ … The sum of each of these (n-12)/4 pairs is -1. The remaining WSW numbers are ±(X + rrel + ½). … WSW: B(n-2,1) = -(X + (n-2-m) + ½) = -X - n + m + 1½ WSW: B(n-1,1) X + (n-1-m) + ½ = X + n - m - ½ The sum of each of these (n-12)/4 pairs is 1.
Column 1 total is 0 - (n-12)/4 + (n-12)/4 = 0.
Columns 2 to n-1 have ± the same numbers at each end.
Column n total is 0, (it contains ± the same numbers as column 1).
Are the border numbers correct, that is, in the right range with no duplicates?
There are 4(n-1) border numbers or 2(n-1) ±pairs.
There is 1 pair in each of the main diagonals.
The remaining 2(n-1) - 2 pairs are in the (NNW,SSW), (NNE,SSE), (WNW,ENE),
and (WSW,ESE) sectors.
The placing of the 2(n-1) positive numbers is:
----- (n-2)/2 numbers alternating SSW,NNW SSW: B(n,m-½) = X + ½ - 2(n-m) + ½ = X - n + 2 NNW: B(1,m-1½) = X + 1½ - 2(m-1) + ½ = X - n + 3 … SSW: B(n,3) = X + (m-3) - 2(n-m) + ½ = X - (n+2)/2 NNW: B(1,2) = X + (m-2) - 2(m-1) + ½ = X - n/2 S-E: B(n,m+½) = X - (n-m) + ½ = X - (n-2)/2 ----- (n-4)/2 numbers alternating ENE, WNW ENE: B(2,n) = X - (m-2) + ½ = X - (n-4)/2 WNW: B(3,1) = X - (m-3) + ½ = X - (n-6)/2 … WNW: B(m-2½,1) = X - 2½ + ½ = X - 2 ENE: B(m-1½,n) = X - 1½ + ½ = X - 1 NW: B(1,1) = X NE: B(1,n) = X + 1 ----- (n-4)/2 numbers alternating WSW, ESE WSW: B(m+1½,1) = X + 1½ + ½ = X + 2 ESE: B(m+2½,n) = X + 2½ + ½ = X + 3 … ESE: B(n-2,n) = X + (n-2-m) + ½ = X + (n-4)/2 WSW: B(n-1,1) = X + (n-1-m) + ½ = X + (n-2)/2 W-N: B(m-½,1) = X + (m-1) + ½ = X + n/2 ----- (n-4)/2 numbers alternating SSE, NNE SSE: B(n,m+1½) = X + (n-m) + 1½ = X + (n+2)/2 NNE: B(1,m+2½) = X + (m-1) + 2½ = X + (n+4)/2 … NNE: B(1,n-2) = X + (m-1) + (n-2-m) = X + n - 3 SSE: B(n,n-1) = X + (n-m) + (n-1-m) = X + n - 2 E-S: B(m+½,n) = X + 2(n-m) = X + n - 1
----- (n-2)/2 numbers alternating SSW,NNW SSW: B(n,m-½) = X + ½ - 2(n-m) + ½ = X - n + 2 NNW: B(1,m-1½) = X + 1½ - 2(m-1) + ½ = X - n + 3 … NNW: B(1,3) = X + (m-3) - 2(m-1) + ½ = X - (n+2)/2 SSW: B(n,2) = X + (m-2) - 2(n-m) + ½ = X - n/2 If n = 8: W-S: B(m+½,1) = X - (m-1) + ½ = X - 3 If n > 8: E-S: B(m+½,n) = X - (n-m) + ½ = X - (n-2)/2 If n > 8: ----- (n-12)/2 + 1 numbers alternating WNW, ENE WNW: B(2,1) = X - (m-2) + ½ = X - (n-4)/2 ENE: B(3,n) = X - (m-3) + ½ = X - (n-6)/2 … WNW: B(m-4½,1) = X - 4½ + ½ = X - 4 If n > 8: WNW: B(m-3½,1) = X - 3½ + ½ = X - 3 ENE: B(m-2½,n) = X - 2½ + ½ = X - 2 ENE: B(m-1½,n) = X - 1½ + ½ = X - 1 NW: B(1,1) = X NE: B(1,n) = X + 1 WSW: B(m+1½,1) = X + 1½ + ½ = X + 2 ----- (n-6)/2 numbers alternating WSW, ESE WSW: B(m+2½,1) = X + 2½ + ½ = X + 3 ESE: B(m+3½,n) = X + 3½ + ½ = X + 4 … WSW: B(n-1,1) = X + (n-1-m) + ½ = X + (n-2)/2 E-N: B(m-½,n) = X + (n-m) + ½ = X + n/2 ----- (n-4)/2 numbers alternating SSE, NNE SSE: B(n,m+1½) = X + 1½ + (n-m) = X + (n+2)/2 NNE: B(1,m+2½) = X + 2½ + (m-1) = X + (n+4)/2 … SSE: B(n,n-2) = X + (n-2-m) + (n-m) = X + n - 3 NNE: B(1,n-1) = X + (n-1-m) + (m-1) = X + n - 2 S-E: B(n,m+½) = X + 2(n-m) = X + n - 1
The next smaller even order square is order k = n - 2.
Its biggest border number is 2(1-(k+1)/2)² + k - 1 = X - n + 1.
The smallest border number of the order n is X - n + 2.
That is, the smallest border number of the order n is 1 greater
than the biggest border number of the order n-2.