Some Theory concerning 5 x 5 magic squares

Consider a 5 x 5 magic square
 c01 c02 c03 c04 c05 c06 c07 c08 c09 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25

with 1 ≤ c01,c02,...,c24,c25 ≤ 25, all entries different, and equal row-, column- and diagonal sums (=65).

If all entries c01,c02,...,c24,c25 are replaced by 26-c01,26-c02,...,26-c24,26-c25 then the square remains magic.

Observation 1

(i) For any choice of 5 different numbers c01,c02,c03,c04,c05 from {1,2,...,25} with sum 65 there exists at least one 5x5 Magic Square with this first row.
(ii)For any choice of 5 different numbers c01,c07,c13,c19,c25 from {1,2,...,25} with sum 65 there exists at least one 5x5 Magic Square with this diagonal.

This can be verified with a computer experiment, e.g. with the downloadable program "mag5x.exe".

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

c05 = 65-c01-c02-c03-c04,
c10 = 65-c06-c07-c08-c09,
c15 = 65-c11-c12-c13-c14,
c17 = 2c01+c02+c03+c04+c06-c09+c11-c13+c16-65,
c18 = 325-4c01-2c02-2c03-2c04-2c06-2c07-c08-2c11-c12-c13-c14-2c16-2c19,
c20 = 2c01+c02+c03+c04+c06+2c07+c08+c09+c11+c12+2c13+c14+c19-195,
c21 = 65-c01-c06-c11-c16,
c22 = 130-2c01-2c02-c03-c04-c06-c07+c09-c11-c12+c13-c16,
c23 = 4c01+2c02+c03+2c04+2c06+2c07+2c11+c12+c14+2c16+2c19-260,
c24 = 65-c04-c09-c14-c19, and
c25 = 65-c01-c07-c13-c19.

This results from solving the 12 linear equations rowsum=65, columnsum=65, diagonalsum=65 and expressing the 14-dimensional general solution with variables c01,c02,c03,c04,c06,c07,c08,c09,c11,c12,c13,c14,c16 and c19.

Remark 1   Every linear equation valid for the entries c01,c02,...,c24,c25 of all 5x5-magic squares, including the equations of Theorem 1, can be obtained with the "calculator" below (requires JavaScript):
 c01 c02 c03 c04 c05 c06 c07 c08 c09 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25
result:
Examples:
1) To get the first equation c01+c02+c03+c04+c05 = 65, simply press the "+"-button of row 1.
2) The equation 4c01+2c02+2c03+2c04+2c06+2c07+c08+2c11+c12+c13+c14+2c16+c18+2c19 = 325, f.i., can be obtained in the following way: three times "+" in row 1, two times "+" in rows 2, 3, and 4, one time "+" in row 5 and diagonal c01...c25, one "-" for columns 2, 3, 4 and diagonal c05...c21, finally two times "-" in column 5.
3) Another equation (*) 2c01+c02+c06+2c07-c14-c15-c18-c20-c23-c24 = 0, is shown by: "+" for diagonal c01...c25, column 1 and column 2, "-" for rows 3, 4 and 5.

Theorem 2   55 ≤ 3(c01 + c07) + 2(c02 + c06) ≤ 205.
This estimation is best possible, as shown by the square
 1 2 22 25 15 9 10 16 11 19 17 23 13 5 7 24 12 6 20 3 14 18 8 4 21

Proof  Equation (*) from example 3) gives c14+c15+c18+c20+c23+c24 = 2c01+c02+c06+2c07, therefore
55 = 1+2+3+...+10 ≤ c01+c02+c06+c07+c14+c15+c18+c20+c23+c24 = 3(c01+c07)+2(c02+c06). The upper bound is obtained, when every entry c is replaced by 26-c.

Corollary 1   20 ≤ c01+c02+c06+c07 ≤ 84.

This follows from Theorem 2, since 58 ≤ 55 + c02+c06 ≤ 3(c01+c02+c06+c07). Then 60 ≤ 3(c01+c02+c06+c07), too. The square given in Theorem 3 shows, that the bounds 20 and 84 cannot be enlarged resp. reduced.

Theorem 3    218 ≤ 3(c01+c07+c13) + 2(c02+c03+c05+c08+c11+c12) ≤ 328.

Proof   Define
n:= c01+c02+c03+c06+c07+c08+c11+c12+c13,
s:= c04+c05+c09+c10+c14+c15,
f:= c19+c20+c24+c25.
 n s f

 22 6 3 18 16 4 14 11 15 21 5 8 12 23 17 25 13 19 7 1 9 24 20 2 10

One has n + s = 195 and f + s = 130, hence n = 65 + f ≥ 85 (see Corollary 1).
Now   n + c01+c07+c13 = 65 + c01+c07+c13 + f = 65 +c01+c07+c13+c19+c25+c20+c24 = 130 +c20+c24 ≥ 133.
Together with n ≥ 85 one now has 2n + c01+c07+c13 ≥ 133 + 85 = 218. The square above shows that the bound 218 ist best possible.

Theorem 4  For the "corner sum" the inequality 26 ≤ c01+c05+c21+c25 ≤ 78 holds.

Proof   From Theorem 1 (using the calculator of Remark 1) we get: 65 + c08+c12+c14+c18 = 2(c01+c05+c21+c25) + c13,
hence 65 + 10 ≤ 2(c01+c05+c21+c25) + 25, and 50 ≤ 2(c01+c05+c21+c25). Equality is impossible,
since {c08, c12,c14,c18} = {1,2,3,4} would imply 26 = 5+6+7+8 ≤ c01+c05+c21+c25.

Corollary 2  "X"-sum and "x"-sum: 52 ≤ c01+c05+2c13+c21+c25 ≤ 104.

 5 9 20 25 6 13 15 2 11 24 21 1 23 3 17 19 18 4 14 10 7 22 16 12 8
This follows, because exchange of proper rows and colums turns the "X"-sum c01+c05+2c13+c21+c25 into an "x"-sum c06+c08+2c13+c16+c18 and because "x"-sum + "corner sum" = 130. The example with "corner sum" 5+6+7+8 and "x"-sum 15+11+2·23+18+14 tells, that the bounds 26,78 in Theorem 4 and 52,104 in Corollary 2 cannot be improved.

Theorem 5    Let V5:= c01+c05+c07+c09+c13, and Σ(k) resp. σ(k) be the greatest resp. lowest sum of k numbers from 1 to 25, not occuring as summands in V5, then

(i)    σ(10) ≤ V5+65 ≤ Σ(10)
(ii)   28 ≤ V5 ≤ 102, -37 ≤ c01+c07-c05-c09 ≤ 37
(iii)  66 ≤ 2V5+c13 ≤ 220
(iv)   130-Σ(4) ≤ V5+c13 ≤ 130-σ(4); especially 36 ≤ V5+c13 ≤ 120
(v)    195-Σ(12) ≤ 2c01+2c07-c05-c09+c13 ≤ 195-σ(12)
(vi)   41 ≤ V5+c01+c05+c13 ≤ 167 and 41 ≤ V5+c07+c09+c13 ≤ 167

Proof    The calculator of Remark 1 shows (+ for both diagonals and - for the lower 3 rows): V5 + 65 is the sum of 10 numbers not belonging to V5; this proves (i).
Moreover from 2V5 + Sum of 10 other entries = 260 (+ for both diagonals and + for the upper 2 rows) it follows 260 - Σ(10) ≤ 2V5 ≤ 260 - σ(10); hence 55 ≤ 2V5 ≤ 205 this proves the first part of (ii), the second part results, if the first part is applicated to V5' = c01+c05+c13+c17+c21, with c17+c21 = 65-c05-c09-c13.
Next, from 2V5 + c13 + Sum of 14 other entries = 325 (+ for both diagonals and + for the upper 3 rows) it follows 325 - Σ(14) ≤ 2V5 + c13 ≤ 325 - σ(14), proving (iii).
The inequality (iv) follows from V5 + c13 = 130 - (c17 + c19 + c21 + c25). For (v), again use the calculator of Remark 1 (+ for the diagonal c01 - c25 and for the 3 left columns then - for the other diagonal). Inequality (vi) follows from V5+c01+c05+c13 + Sum of 7 unused entries = 195 (+ for both diagonals and for the first resp. second row).

The left square below is an example for (i) with σ(10)= 5+6+...+14 = 95, V5 = 30; (i) shows, e.g., that 20 cannot be replaced by 19. The second square shows, that none of the bounds given in (ii) and (iii) can be improved.
(iii) tells e.g., that V5 = 28 is impossible with c13 < 10. [A computer calculation has shown: V5 = 28 is impossible, if the number 11 occurs in V5.]. The third square illustrates (iv), the fourth one shows (v), with 195-Σ(12) = 2c01+2c07-c05-c09+c13, and the right square illustrates (vi).
(1,8,10.7,2) is the only possibility for (c01,c07,c13,c09,c05) with c01 < c05,c07,c09, leading to equality with the leftt bound 41 in (vi).

 1 25 19 17 3 23 2 15 4 21 12 14 20 9 10 7 16 5 24 13 22 8 6 11 18
 1 22 21 18 3 19 5 15 9 17 16 14 10 12 13 6 20 8 24 7 23 4 11 2 25
 8 18 20 14 5 12 10 21 9 13 17 11 2 16 19 4 25 7 23 6 24 1 15 3 22
 5 22 12 1 25 18 7 13 24 3 21 17 10 11 6 19 4 14 20 8 2 15 16 9 23
 1 19 23 20 2 15 8 17 7 18 18 14 10 12 16 11 21 6 22 5 25 3 9 4 24
(i)
(ii), (iii)
(iv)
(v)
(vi)

Theorem 6    c19 = 1/12(1495-19c01-9c02-7c03-10c04-9c06-11c07-3c08-2c09-9c11-5c12-5c13-6c14-8c16 ± sqrt(D)),
sqrt denoting the square root. D is the square number:
 D = -215c012-111c022-71c032-68c042-87c062-71c072-39c082-68c092-87c112-47c122-95c132-36c142-80c162 +c01(-258c02-190c03-172c04-210c06-134c07-30c08+124c09-210c11-98c12+70c13-12c14-200c16) +c02(-138c03-132c04-126c06-90c07-18c08+84c09-126c11-78c12+66c13-12c14-120c16) +c03(-100c04-90c06-62c07-30c08+52c09-50c12+22c13-12c14-90c11-80c16) +c04(-84c06-44c07-12c08+40c09-84c11-44c12+52c13-24c14-80c16) +c06(-90c07-42c08+36c09-126c11-54c12+42c13-12c14-120c16) +c07(-54c08-4c09-66c11-58c12-34c13-12c14-40c16) +c08(-36c09-18c11-18c12-42c13-12c14) +c09(60c11+20c12-76c13-24c14+80c16) +c11(-78c12+18c13-36c14-120c16) +c12(-22c13-36c14-40c16) +c13(-36c14+80c16) +22750c01+15210c02+11830c03+10660c04+13650c06+10790c07 +5070c08-2860c09+13650c11+8450c12+650c13+3900c14+10400c16 -791375.

This follows from the equation c012 + c022 + ... + c242 + c252 = 12 + 22 + ... + 242 + 252. Substitution of c05,c10,c15,c17,c18,c20,c21,c23,c24, and c25 by their expressions given in Theorem 1 leads to a quadratic equation for c19 with the above solutions.

Remark 2  The next two squares show, that the entries c01,c02,c03,c04,c06,c07,c08,c09,c11,c12,c13,c14, and c16 do not completely determine the magic square, but by Theorem 6 there are at most 2 squares having these entries in common, because there are not more than 2 possible values for c19. These values may be determined with the following "calculator" (JavaScript required, "NaN" means: "not a number").
 20 1 13 23 8 4 21 14 2 24 6 22 12 16 9 10 18 15 5 17 25 3 11 19 7

 20 1 13 23 8 4 21 14 2 24 6 22 12 16 9 10 18 11 7 19 25 3 15 17 5

 c01 c02 c03 c04 c05 c06 c07 c08 c09 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25
c19 =

Relations for pattern sums    Consider the following sums of entries:

V=c01+c05
+c21+c25
v=c07+c09
+c17+c19
N=c01+c03+c05
+c11+c13+c15
+c21+c23+c25
n=c07+c08+c09
+c12+c13+c14
+c17+c18+c19
m=c13 K=c03+c11
+c15+c23
k=c08+c12
+c14+c18
O=c02+c04+c06
+c10+c16+c20
+c22+c24

Proper combinations of equations from Theorem 1 (with the help of the "equation-calculator" in Remark 1) lead to:

 (R01) 2V+m = k+65 (R02) 2v+m = K+65 (R03) V+65 = n (R04) v+65 = N (R05) 2v+3m+k = 195 (R06) 2V+3m+K = 195 (R07) 3V = v+2k (R08) 3v = V+2K (R09) k = v mod 3 (R10) K = V mod 3 (R11) O = 3m+65 (In1) 26≤V,v≤78 (In2) 52≤V+2m,v+2m≤104 (In3) 91≤N,n≤143 (In5) 39≤k+3m,K+3m≤143 (In6) 44≤V+m,v+m≤86 *)

*) Inequality (In6) was found by a computer calculation.

These Relations are useful for showing, that certain entries in magic squares are impossible:

Example 1    There is no 5x5 magic square with c01=1, c05=2, c21=4, and c25=24.
Proof    With (R01) the assumption leads to: m = k+65-2V = k + 3 ≥ 3+5+6+7 + 3 = 24. Because 24 is used: m=25. Further, by (R01) again: k=22 = 3+5+6+8. Now, c07+c19=15 leads to a contradiction, because there are not enough unused numbers left, that two of them could sum up to 15.

Reduced 5x5 Magic Squares   The two maps
 map1: exchange rows 1 and 2, exchange columns 1 and 2 exchange rows 4 and 5, exchange columns 4 and 5 map2: exchange rows 2 and 4, exchange columns 2 and 4

in combination with the 4 reflections and the 3 rotations of a 5x5 square generate a set of 32 transformations (including the identity), each of which maps every 5x5 magic square onto another one.
Every 5x5 magic square can be mapped by one of these 32 transformations onto a unique "reduced square" for which the following inequalities are valid:
c01<c05<c21, c01<c25, c01<c07, c01<c09, c01<c17, c01<c19, c02<c04.

The number of reduced 5x5 magic squares depending on the value of c01 is shown by the table below:

 c01 number of reduced squares 1 17736163 2 15437677 3 12581407 4 8803796 5 5927144 6 3786042 7 2286273 8 1332837 9 645631 10 217929 11 58598 12 12809 68826306

There exist 68820306 reduced 5x5 magic squares and 32x68826306 = 2202441792 magic squares of order 5.
(This number is well known since 1973, found by R. Schroeppel). There is a downloadable program "red5.exe" available, which produces all reduced 5x5 magic squares; moreover, the user may prescribe fixed entries.

The Delacorte-Number d of a 5x5-square (cij) is defined as
d = ½∑[gcd(cij,ckl)*((i-k)2+(j-l)2)|i,j,k,l=1,...,5].
This also may be written as d = ∑[φ(k)*Sk|k=1,...,12],
where φ denotes the Euler-function φ(k)=number of integers ≤k, coprime to k,
and Sk is the sum over all squares of distances of multiples of k occuring in (cij).
There are (except for reflections or rotations) unique 5x5-Magic Squares
with the lowest and highest possible Delacorte-Numbers d=3458 and d=5890, namely:
 1 5 15 25 19 23 20 6 9 7 13 10 18 3 21 17 8 24 12 4 11 22 2 16 14
d=3458
 8 10 14 9 24 22 13 25 1 4 5 19 7 23 11 18 21 3 17 6 12 2 16 15 20
d=5890

last update: 2016-March-29.