Theorems on Classical 4x4 Magic Squares

© H.B. Meyer     for general 4x4 magic squares see here     zur Seite in deutscher Sprache     magic squares and cubes

Summary:   Observations on classical magic squares of order 4 are made, which lead to a necessary and sufficient condition for any quadruple (q|r|s|t) of natural numbers to appear as row or column of a proper 4x4 magic square. Additional relations between entries of 4x4 magic squares are studied. A classification of 4x4 magic squares with 15 types is presented.

Consider a 4x4 magic square
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p

with 0 < a,b,...,o,p < 17, all entries different, and equal row-, column- and diagonal sums (=34).

Observation 0    The following 31 squares are also 4x4 magic squares:
  02
d
h
l
p
c
g
k
o
b
f
j
n
a
e
i
m
03
p
o
n
m
l
k
j
i
h
g
f
e
d
c
b
a
04
m
i
e
a
n
j
f
b
o
k
g
c
p
l
h
d
05
m
n
o
p
i
j
k
l
e
f
g
h
a
b
c
d
06
d
c
b
a
h
g
f
e
l
k
j
i
p
o
n
m
07
a
e
i
m
b
f
j
n
c
g
k
o
d
h
l
p
08
p
l
h
d
o
k
g
c
n
j
f
b
m
i
e
a
09
a
c
b
d
i
k
j
l
e
g
f
h
m
o
n
p
10
d
l
h
p
b
j
f
n
c
k
g
o
a
i
e
m
11
p
n
o
m
h
f
g
e
l
j
k
i
d
b
c
a
12
m
e
i
a
o
g
k
c
n
f
j
b
p
h
l
d
13
m
o
n
p
e
g
f
h
i
k
j
l
a
c
b
d
14
d
b
c
a
l
j
k
i
h
f
g
e
p
n
o
m
15
a
i
e
m
c
k
g
o
b
j
f
n
d
l
h
p
16
p
h
l
d
n
f
j
b
o
g
k
c
m
e
i
a
17
k
i
l
j
c
a
d
b
o
m
p
n
g
e
h
f
18
j
b
n
f
l
d
p
h
i
a
m
e
k
c
o
g
19
f
h
e
g
n
p
m
o
b
d
a
c
j
l
i
k
20
g
o
c
k
e
m
a
i
h
p
d
l
f
n
b
j
21
g
e
h
f
o
m
p
n
c
a
d
b
k
i
l
j
22
j
l
i
k
b
d
a
c
n
p
m
o
f
h
e
g
23
k
c
o
g
i
a
m
e
l
d
p
h
j
b
n
f
24
f
n
b
j
h
p
d
l
e
m
a
i
g
o
c
k
25
f
e
h
g
b
a
d
c
n
m
p
o
j
i
l
k
26
g
c
o
k
h
d
p
l
e
a
m
i
f
b
n
j
27
k
l
i
j
o
p
m
n
c
d
a
b
g
h
e
f
28
j
n
b
f
i
m
a
e
l
p
d
h
k
o
c
g
29
j
i
l
k
n
m
p
o
b
a
d
c
f
e
h
g
30
g
h
e
f
c
d
a
b
o
p
m
n
k
l
i
j
31
f
b
n
j
e
a
m
i
h
d
p
l
g
c
o
k
32
k
o
c
g
l
p
d
h
i
m
a
e
j
n
b
f

If all entries a,b,c,...,o,p are replaced by 17-a,17-b,17-c,...,17-o,17-p then the squares remain magic.

Observation 1   None of the following 16 pairs of entries has a difference of 8 or -8:

(a|d), (b|c), (e|h), (f|g), (i|l), (j|k), (m|p), (n|o), (a|m), (e|i), (b|n), (f|j), (c|o), (g|k), (d|p), (h|l).

Observation 2   If any of the 16 pairs in Observation 1 has a difference of 4 or -4, then the greater entry x of this pair satifies the inequality 7 < x < 13.

Observation 3   Let (x|y) be any of the 16 pairs of Observation 1.
If x = 4z+1, then y cannot be x+1 or x+2. If x = 4z, then y cannot be x-1 or x-2; if y = 4z+1, then x cannot be y+1 or y+2. If y = 4z, then x cannot be y-1 or y-2 (z denotes an integer).

Remark 1   Observations 1 - 3 say, that the 16 positions mentioned in Observation 1 cannot be filled with value-pairs marked red in Fig. 1. Conversely, for any of the 16 positions and any chosen value-pair, marked green in Fig. 1, there exists a magic square, with these chosen values at the chosen positions.

 12345678910 111213141516
1                 
2                 
3                 
4                 
5                 
6                 
7                 
8                 
9                 
10                 
11                 
12                 
13                 
14                 
15                 
16                 
  Fig. 1:
  allowed pairs (green)
  in Observations 1 - 3.

  The red marked
  forbidden pairs (x|y)
  are those where x-1
  and y-1 correspond in
  3 digits, written as
  4-digit binaries:
  0000,0001,...,1111.

Observation 4  Consider the following 32 pairs of entry-positions ("position set II")

(b|g), (c|f), (i|f), (e|j), (l|g), (h|k), (o|j), (n|k), (e|d), (o|d), (h|a), (n|a), (b|m), (l|m), (i|p), (c|p), (i|d), (n|d), (o|a), (l|a), (c|m), (h|m), (b|p), (e|p), (b|k), (c|j), (h|j), (l|f), (o|f), (n|g), (e|k), (i|g).
Any position-pair of set II can be filled with values (u|v) if and only if (u|v) is marked green in Fig. 2

v
u 
 12345678910 111213141516
1                 
2                 
3                 
4                 
5                 
6                 
7                 
8                 
9                 
10                 
11                 
12                 
13                 
14                 
15                 
16                 
  Fig. 2:
  allowed (green)
  values (u|v)
  for position set II
  of Observation 4

Observation 5   Let (q|r) be any pair of entries of the magic suare, where q belongs to a diagonal and r does not, and q and r are situated in a common row or a common column.
Then the possible values for (q|r), are all pairs (a|b), 0 < a,b < 17 (a different from b), with the 6 exceptions (6|5), (7|8), (8|7), (9|10), (10|9) and (11|12).

Observation 6   Let (q|r|s|t) be any row or column of the magic square.
Then the square sum q2 + r2 + s2 + t2 is one of the 30 numbers:
302, 306, 310, 314, 318, 326, 330, 334, 342, 350, 354, 358, 362, 366, 370, 374, 378, 382, 386, 390, 398, 402, 406, 414, 426, 434, 438, 442, 462, or 486.

Remark 2  None of the 30 numbers is a multiple of 4, therefore p,q,r,s cannot be even all together, neither all of them can be odd. Two entries are even and the other two are odd.

Observation 7   Let (q|r|s|t) be any row or column of the magic square.
a) The expression 1/24[(q-8.5)3 + (r-8.5)3 + (s-8.5)3 + (t-8.5)3] evaluates to one of the 21 numbers:
-12, -10, -9, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 10 or 12.
b) The expression 1/24[(q'-3.5)3 + (r'-3.5)3 + (s'-3.5)3 + (t'-3.5)3] has the value -1, 0 or 1.
Here x' denotes (x-1) mod 8, and mod 8 means the residue of division by 8.
c) (q"-1.5)3 + (r"-1.5)3 + (s"-1.5)3 + (t"-1.5)3 = 0.
Here x" denotes (x-1) mod 4, and mod 4 means the residue of division by 4.
d) Assume q-1, r-1, s-1, and t-1 written as 4-bit binary numbers taken from {0000,0001,...,1110,1111}.
Then in every bit-position the digits 0 and 1 occur exactly 2 times.

Observation 8   Consider the following 20 vectors of natural numbers ("exceptional vectors"):
( 2| 6|11|15),( 2|11| 6|15),(15| 6|11| 2),(15|11| 6| 2),( 3| 6|11|14),( 3|11| 6|14),(14| 6|11| 3),(14|11| 6| 3),
( 5| 7|10|12),( 5|10| 7|12),(12| 7|10| 5),(12|10| 7| 5),( 7| 3|14|10),( 7|14| 3|10),(10| 3|14| 7),(10|14| 3| 7),
( 8| 4|13| 9),( 8|13| 4| 9),( 9| 4|13| 8),( 9|13| 4| 8).
None of these vectors appears as first row (last row, first or last column) of a magic square, but each of these 20 vectors fulfils every condition of Observations 1-3, Observation 5, Remark 2 and Observation 7b) and 7d), and therefore can not be excluded by these conditions.

Theorem 9   Let (q|r|s|t) be any vector of natural numbers.
Then there exists a 4x4 magic square with first row (last row, first column, last column) (q|r|s|t) if and only if the following conditions hold:
a) 0 < q,r,s,t < 17
b) q,r,s,t are pairwise different
c) q + r + s + t = 34
d) 1/24[(q'-3.5)3+(r'-3.5)3+(s'-3.5)3+(t'-3.5)3] has the value -1,0 or 1 (x' denotes the residue (x-1) mod 8)
e) None of the pairs (q|r), (q|s), (t|r) and (t|s) equals (6|5), (7|8), (8|7), (9|10), (10|9) or (11|12)
f) (q|r|s|t) is not one of the 20 exceptional vectors of Observation 8
g) the pairs (q|t) and (r|s) are allowed pairs in Observations 1-3 (see Fig. 1)

Remark 3   A vector (q|r|s|t) appears as second row (third row, second or third column) of a magic 4x4 square if and only if (r|q|t|s) appears as a first row.

Theorem 10   The entries of the magic square satisfy the following equations:

d = 34 - a - b - c,
h = 34 - e - f - g,
j = 2a + b + c + e - g + i - 34,
k = 68 - 2a - b - c - e - f - i,
l = f + g - i,
m = 34 - a - e - i,
n = 68 - 2a - 2b - c - e - f + g - i,
o = 2a + b + e + f - g + i - 34, and
p = a + b + c + e + i - 34.

This results from solving the 10 linear equations rowsum=34, columnsum=34, diagonalsum=34 and expressing the 7-dimensional general solution with variables a,b,c,e,f,g and i.

Remark 4   Theorem 10 shows that the entries in the green marked regions add up to 34:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p

Remark 5   Every linear equation valid for the entries a,b,c, ..., o,p of all 4x4-magic squares, including the equations of Theorem 10, can be obtained with the "calculator" below (requires JavaScript):
 
 
 
 
 
  
a
b
c
d
 
  
e
f
g
h
 
  
i
j
k
l
 
  
m
n
o
p
 
  
   
   
   
   
 
  
  

result: 
Examples: To get the first equation a+b+c+d=34, simply press the "+"-button of row 1. The equation 2a+b+c+e+f+i+k=68, f.i., is shown by: "+" for all rows, "-" for diagonal d-g-j-m, "+" for diagonal a-f-k-p, "-" for row 4 and column 4, "+" for row 1 and column 1, finally "divide".

Theorem 11  

D = 680a+544b+408c+408e+544f+136g-18ab-12ac-10ae-14af+4ag-12bc-6be
 -10bf+4bg-4ce-4cf-10ef-4eg-4fg -15a2-11b2-8c2-7e2-11f2-8g2-10880

is a square number. Moreover  
i = 1/4(136-5a-3b-2c-3e-f+2g + sqrt(D))  or   i = 1/4(136-5a-3b-2c-3e-f+2g - sqrt(D))  holds, where sqrt(D) denotes the square root of D.

This follows from the equation a2 + b2 + ... + o2 + p2 = 12 + 22 + ... + 152 + 162. Substitution for d,h,j,k,l,m,n,o, and p by their expressions given in Theorem 10 leads to a quadratic equation for i with the above solutions.

Remark 6  The two squares on the right show, that the entries a,b,c,e,f, and g do not completely determine the magic square. By Theorem 11, however, there are at most 2 squares with these entries in common, because there are not more than 2 possible values for i. These values may be determined with the "calculator" below (JavaScript required, NaN means: "not a number").  
 1 31416
1513 4 2
10 611 7
 812 5 9
   
 1 31416
1513 4 2
12 8 9 5
 610 711

There are exactly eight pairs of magic squares with equal values for a,b,c,e,f but different entries for g, namely:
(a,b,c,e,f,g1/g2) = (5,14,3,10,7,2/16), (7,10,15,14,5,4/12), (7,12,5,2,15,4/14), (7,12,5,14,3,2/16), and the four pairs obtained by subtraction of every entry from 17.
The "calculator" on the right determines the value for g from those of a,b,c,e, and f (using, that D in Theorem 11 is a square number), if no input for g is made. If a,b,c,e,f,g belong to a magic square, the result for g will always be unique, except for the eight mentioned cases.
 
a b c d
e f g h
i j k l
m n o p


i =  

Remark 7  In the equations for j,k,...,o,p of Theorem 10 the entry i appears three times with sign "+" and four times with sign "-". As a consequence, the simplified sum of cubes a3 + b3 + ... + o3 + p3 cannot contain a term with i3. Therefore a proper linear combination of the equations

( I) a2 + b2 + ... + o2 + p2 = 12 + 22 + ... + 152 + 162
(II) a3 + b3 + ... + o3 + p3 = 13 + 23 + ... + 153 + 163

[namely 51(I) - 2(II)] contains i only with exponent 1 and gives another relation between i and the other 6 entries a,b,c,e,f,g. The result (compare [1], equation (2)) can be described as follows: define x':=2x-17 for x=a,b,c,e,f,g,i, further: α:=a'+f', β:=b'+c', γ:=b'+f', δ:=f'+g', T:=αβ+αδ+βγ+δa', finally U:=βγ+(β+δ)a', then:
(e'+i')(δe'+T)=(g'-a'-α-β)U.

Observation 12  

a) z=b+c+f+g is an even number with 17 < z < 51,
   and every such z occurs as sum b+c+f+g.

b) 21 < a+b+e+f < 47,
   and every number between 21 and 47 occurs as sum a+b+e+f.   
   The first assertion follows from
       21 < (1 + 2 + 3 + 4 + 34)/2 ≤ (b + e + l + o + a + f + k + p)/2 = a + b + e + f.   


9 1816
1572 10
612133
414115
5 215 12
411 613
167101
91438

Observation 13   There are 32 x 220 = 7040 magic 4x4 squares (see Observation 17).

Observation 14   Consider the squares
a'
b'
c'
d'
e'
f'
g'
h'
i'
j'
k'
l'
m'
n'
o'
p'

a) If x' = (x-1) mod 8 + 1, then: for all 7040 squares every row and every column sums up to 18. For 5696 of these squares the diagonals also have sum 18; these are exactly the squares which remain magic after the exchange of entries: 1<->8, 2<->7, 3<->6, 4<->5, 9<->16, 10<->15, 11<->14, and 12<->13. For 672 squares the main diagonal has sum 10, the other has sum 26, and for 672 squares the main diagonal sum is 26 and the other diagonal's sum is 10.

b) If x' = (x-1) mod 4 + 1, then: for all 7040 squares every row and every column sums up to 10. For 5248 of these squares the diagonals also have sum 10; these are exactly the squares which remain magic after the exchange of entries: 1<->4, 2<->3, 5<->8, 6<->7, 9<->12, 10<->11, 13<->16, and 14<->15. For 896 squares the main diagonal has sum 6, the other has sum 14, and for 896 squares the main diagonal sum is 14 and the other diagonal's sum is 6.

c) If x' = (x-1) mod 2 + 1, then: for all 7040 squares every row and every column sums up to 6. For 5696 of these squares the diagonals also have sum 6; these are exactly the squares which remain magic after the exchange of entries: 1<->2, 3<->4, ..., 13<->14, 15<->16. For 672 squares the main diagonal has sum 4, the other has sum 8, and for 672 squares the main diagonal sum is 8 and the other diagonal's sum is 4.
There are exactly the following 24 possibilities of parity distribution (
 
 = odd, 
 
 = even):

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

Observation 15  

a) Every 4x4 magic square satisfies at least one and at most three of the following five equations:
(1)
a+b+e+f=34
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
3456 squares
(2)
a+b+m+n=34
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
2464 squares
(3)
a+c+m+o=34
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
2464 squares
(4)
a+d+e+h=34
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
2464 squares
(5)
a+d+i+l=34
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
2464 squares
Moreover: equations (2) and (5) cannot be valid both, similarly (3) and (4) cannot be valid together. Therefore at most two of the equations (2),(3),(4) or (5) can hold. (2) and (4) together imply (1), as well as (3) and (5) together do.

b) According to Fig. 3 the set of all 4x4 magic squares can be divided into 15 Types:

typenumbereq.(1)eq.(2)eq.(3)eq.(4)eq.(5)also defined byspecial description
T01384yesnonononoa+p=17"centralsymmetric": rotation by 180o replaces every entry x by 17-x
T02384yesyesnoyesnoa+k=17"pandiagonal": every broken diagonal sums up to 34
T03384yesnoyesnoyesa+f=17exchange of rows 1<->4 and columns 1<->4 replaces every entry x by 17-x
T04384yesyesnononoa+b=17 and e+f=17 exchange of columns 1<->2 and columns 3<->4 replaces every entry x by 17-x
T05384yesnoyesnonoa+c=17 and i+k=17 exchange of columns 1<->3 and columns 2<->4 replaces every entry x by 17-x
T06384yesnonoyesnoa+e=17 and b+f=17exchange of rows 1<->2 and rows 3<->4 replaces every entry x by 17-x
T07384yesnonoyesnoa+i=17 and c+k=17exchange of rows 1<->3 and rows 2<->4 replaces every entry x by 17-x
T08384yesyesyesnonoa+m=17 and eq.(1) reflection (horizontal axis) replaces every entry x by 17-x and eq.(1) holds
T09384yesnonoyesyesa+d=17 and eq.(1) reflection (vertical axis) replaces every entry x by 17-x and eq.(1) holds
T10832noyesyesnonoa+m=17 and b+n=17 and not eq.(1) reflection (horizontal axis) replaces every entry x by 17-x and eq.(1) does not hold
T11832nononoyesyesa+d=17 and e+h=17 and not eq.(1)reflection (vertical axis) replaces every entry x by 17-x and eq.(1) does not hold
T12480noyesnononoa+k≠17 and b+n≠17 and
(a+b≠17 or e+f≠17) and eq.(2)
 
T13480nonoyesnonoa+f≠17 and b+n≠17 and
(a+c≠17 or i+k≠17) and eq.(3)
 
T14480nononoyesnoa+k≠17 and e+h≠17 and
(a+e≠17 or b+f≠17) and eq.(4)
 
T15480nonononoyesa+f≠17 and e+h≠17 and
(a+i≠17 or c+k≠17) and eq.(5)
 

c) The set of all 2432 "mirror-symmetric" (reflection replaces every entry x by 17-x) 4x4 magic squares is the union of T08, T10, T09, and T11.
Fig.3 has two symmetry axes: s1 from left down to right up and s2 from left up to right down. Reflection at s1 arises from 90o rotation of magic squares. Reflection at s2 arises from the exchange rows 1<->4 and columns 1<->4.

Observation 16

a) If four different letters w,x,y,z are chosen from a,b,c,...,o,p such that w+x+y+z=34 holds for more than 3456 of the 7040 magic 4x4 squares, then necessarily w,x,y,z form a row, a column, a diagonal, or {w,x,y,z} is one of the four green marked letter sets of Remark 4.

b) Since there are exactly 86 different equations w+x+y+z=34 with w<x<y<z and 0<w,x,y,z<17, for any given magic 4x4 square there are 72 different choices of entries w,x,y,z - in addition to the 14 choices of a) - such that w+x+y+z=34 holds.
But there are eight non-trivial patterns of choices of four entries, for which none of the 7040 magic 4x4 squares can have sum 34.[Trivial "≠34"-choices are those, where exactly 3 of the four entries are taken from one single of the 14 sets mentioned in a)]. Indeed:

(1) a+b+m+o≠34,   (2) a+b+n+o≠34,   (3) a+b+n+p≠34,   (4) a+d+f+j≠34,
(5) b+c+e+i≠34,   (6) b+c+e+l≠34,   (7) b+c+e+n≠34,   (8) b+c+e+o≠34 

holds for every 4x4 magic square, as well as any inequality, obtained from (1) until (8) by application of one of the 31 transformations of 4x4 magic squares, does.

  u  v
  pon m lkj i hgf e dcb a
a x   z  x wy  w xy zy y 
b  x z  x  yw w  yx yz  y
c  z x  wy  x xy  w y  zy
d z   x yw x  yx w   y yz
e  x wy x   z zy y   w xy
f x  yw  x z  yz  y w  yx
g wy  x  z x  y  zy xy  w
h yw x  z   x  y yz yx w 
i  w xy zy y  x   z  x wy
j w  yx yz  y  x z  x  yw
k xy  w y  zy  z x  wy  x
l yx w   y yz z   x yw x 
m zy y   w xy  x wy x   z
n yz  y w  yx x  yw  x z 
o y  zy xy  w wy  x  z x 
p  y yz yx w  yw x  z   x
   number of
magic squares
with

u + v = 17



 
w
x
y
z
    0 squares 
   32 squares 
  384 squares 
  624 squares 
 1664 squares 
Observation 17

Consider any pair (u|v) of positions of entries in a 4x4 magic square, u,v taken from {a,b,c,...,o,p}, u≠v.
There are exactly 5 possibilities for the number N of 4x4 magic squares satisfying u + v = 17:

N=0, N=32, N=384, N=624, or N=1664.

For each position pair (u|v) the corresponding number N of squares with u + v = 17 is shown in the right table.

(Note, that the red pattern is quite the same as in Fig. 1 of Remark 1 above.)







Observation 18 (reduction of squares)

A 4x4 magic square may be called "reduced" if and only if the following inequalities are satisfied:

      a ≤ 5
      a < d,f,g,j,k,m,p
      d < m
      b < c.

By means of a proper transformation chosen from the 31 transformations of Observation 0, any not already reduced 4x4 magic square can be mapped to a unique reduced square. There are exactly 220 reduced squares, namely:

    104 reduced squares with a = 1
     68 reduced squares with a = 2
     32 reduced squares with a = 3
     10 reduced squares with a = 4
      6 reduced squares with a = 5.


Observation 19 (16 queens problem)

Consider a 16x16 chessboard with 16 queens placed on the board. Place the first queen in row 1, column a, the second queen in row 2, column b, ..., the sixteenth queen in row 16 and column p. Then the magic square formed by a, b, c, ..., p "solves the 16 queens problem", if no queen on the board attacks any other one.
There are exactly 16 magic squares solving the 16 queens problem:

49 516
147112
156103
112813
4 9 156
147112
516103
112813
511 414
108151
16297
313612
79 216
144115
126133
115810
714 211
94165
121138
615310
714 121
94615
211138
165310
810 133
115126
115216
14479
IIIIII IVVVI VII

and II rotated 90o, 180o, 270o, further I, III, IV, V, VI, and VII rotated 180o.

Proofs   by computer, using e.g. magic squares of order 4 which produces all 7040 magic squares of order 4.





eXTReMe Tracker