Back to theory contents

Basic theory

3×3 magic squares over a general carrier

The magic constant, the complete form m(E,x,y), its uniqueness, and the exact distinctions between abelian groups, rings, fields, and the real, rational, and integer cases.

1. Carrier and definition

Let A be an abelian group written additively. A 3×3 magic square over A is an array whose three row sums, three column sums, and two main diagonal sums are equal to one element M∈A. An abelian group is the natural general setting: the proof needs addition, zero, and subtraction, but it needs no multiplication, order, or division.

Q=(ABCDEFGHJ),A+B+C==C+E+G=M.Q=\begin{pmatrix}A&B&C\\D&E&F\\G&H&J\end{pmatrix},\qquad A+B+C=\cdots=C+E+G=M.

If A is a module over a ring R, squares are added entrywise and every entry may be multiplied by one scalar. The classification below is compatible with this module structure.

2. The magic constant

Theorem

In every 3×3 magic square over an abelian group, the magic constant is three times the central entry:

M=3E.M=3E.

Proof

Let T be the sum of all nine entries. Adding the three rows gives T=3M. Now add the middle row, the middle column, and both diagonals. Every noncentral entry occurs once and the center occurs four times. Hence this sum is both 4M and T+3E:

T=3M,(D+E+F)+(B+E+H)+(A+E+J)+(C+E+G)=T+3E=4M.T=3M,\qquad (D+E+F)+(B+E+H)+(A+E+J)+(C+E+G)=T+3E=4M.

Substituting T=3M and cancelling 3M in the abelian group gives M=3E. No division by 3 was used. The four lines through the center immediately give the opposite-pair identities:

A+J=B+H=C+G=D+F=2E.A+J=B+H=C+G=D+F=2E.

3. The complete form m(E,x,y)

Classification theorem

For every abelian group A, each 3×3 magic square over A has a unique representation of the following form, with E,x,y∈A:

M(E,x,y)=(E+xEx+yEyExyEE+x+yE+yE+xyEx)\mathcal M(E,x,y)=\begin{pmatrix} E+x & E-x+y & E-y\\ E-x-y & E & E+x+y\\ E+y & E+x-y & E-x \end{pmatrix}

Surjectivity: every magic square has this form

Let Q be any magic square and set x=A−E and y=G−E. Then A=E+x and G=E+y. The opposite-pair identities give J=E−x and C=E−y. The bottom row and first column then give H=E+x−y and D=E−x−y, while their opposite entries are B=E−x+y and F=E+x+y. Thus all nine entries have the stated form.

x=AE,y=GE,A=E+x,G=E+y,J=2EA=Ex,C=2EG=Ey,H=3EGJ=E+xy,B=2EH=Ex+y,D=3EAG=Exy,F=2ED=E+x+y.\begin{aligned} x&=A-E,& y&=G-E,\\ A&=E+x,& G&=E+y,\\ J&=2E-A=E-x,& C&=2E-G=E-y,\\ H&=3E-G-J=E+x-y,& B&=2E-H=E-x+y,\\ D&=3E-A-G=E-x-y,& F&=2E-D=E+x+y. \end{aligned}

Consequently every Q∈𝓜₃(A) has a preimage (E,x,y), so the map Φₐ:A³→𝓜₃(A) is surjective.

Well-definedness: every coordinate triple gives a magic square

For arbitrary E,x,y, the eight required sums are computed directly. None of these identities uses division:

(E+x)+(Ex+y)+(Ey)=3E,(Exy)+E+(E+x+y)=3E,(E+y)+(E+xy)+(Ex)=3E,(E+x)+(Exy)+(E+y)=3E,(Ex+y)+E+(E+xy)=3E,(Ey)+(E+x+y)+(Ex)=3E,(E+x)+E+(Ex)=3E,(Ey)+E+(E+y)=3E.\begin{aligned} (E+x)+(E-x+y)+(E-y)&=3E,\\ (E-x-y)+E+(E+x+y)&=3E,\\ (E+y)+(E+x-y)+(E-x)&=3E,\\ (E+x)+(E-x-y)+(E+y)&=3E,\\ (E-x+y)+E+(E+x-y)&=3E,\\ (E-y)+(E+x+y)+(E-x)&=3E,\\ (E+x)+E+(E-x)&=3E,\\ (E-y)+E+(E+y)&=3E. \end{aligned}

Injectivity: the coordinates are unique

The coordinates are recovered without choices or denominators: E is the central entry, x=A−E, and y=G−E. Therefore two different coordinate triples cannot define the same square.

(E,x,y)=(Q22, Q11Q22, Q31Q22).(E,x,y)=\bigl(Q_{22},\ Q_{11}-Q_{22},\ Q_{31}-Q_{22}\bigr).

4. Group, module, and vector space

Write 𝓜₃(A) for the set of 3×3 magic squares over A. The theorem gives an isomorphism of abelian groups A³≅𝓜₃(A). If A is an R-module, this isomorphism is R-linear:

ΦA:A3M3(A),(E,x,y)M(E,x,y),M(E1,x1,y1)+M(E2,x2,y2)=M(E1+E2,x1+x2,y1+y2),rM(E,x,y)=M(rE,rx,ry).\begin{aligned} \Phi_A:A^3&\longrightarrow\mathcal M_3(A),&(E,x,y)&\longmapsto\mathcal M(E,x,y),\\ \mathcal M(E_1,x_1,y_1)+\mathcal M(E_2,x_2,y_2) &=\mathcal M(E_1+E_2,x_1+x_2,y_1+y_2),\\ r\mathcal M(E,x,y)&=\mathcal M(rE,rx,ry). \end{aligned}

For a commutative ring R, this is a free R-module with the following three explicit basis matrices:

M(E,x,y)=ES0+xS1+yS2,\mathcal M(E,x,y)=E S_0+xS_1+yS_2,S0=(111111111),S1=(110101011),S2=(011101110).S_0=\begin{pmatrix}1&1&1\\1&1&1\\1&1&1\end{pmatrix},\quad S_1=\begin{pmatrix}1&-1&0\\-1&0&1\\0&1&-1\end{pmatrix},\quad S_2=\begin{pmatrix}0&1&-1\\-1&0&1\\1&-1&0\end{pmatrix}.

In particular, over every field K the space 𝓜₃(K) has dimension three. This statement concerns entrywise addition and scalar multiplication; ordinary matrix multiplication does not in general preserve magic squares.

5. Different scalar domains

CarrierStructureExact consequence
AAabelian groupM3(A)A3\mathcal M_3(A)\cong A^3
RRcommutative ringfree R-module of rank 3
KKfielddimKM3(K)=3\dim_K\mathcal M_3(K)=3
R\mathbb Rordered fieldfixed M gives the affine plane E=M/3
Q\mathbb Qrational fielda common denominator scales the square to an integral one
Z\mathbb Zfree abelian groupM3(Z)Z3\mathcal M_3(\mathbb Z)\cong\mathbb Z^3

Real numbers

Over ℝ one obtains a three-dimensional real vector space. For a fixed magic constant M, the coordinate E=M/3 is fixed while x and y are free, giving a two-dimensional affine plane. Positivity is expressed by nine linear inequalities, while pairwise distinctness removes a finite collection of lines from the (x,y)-plane.

Rational numbers

Rational entries are equivalent to rational coordinates E,x,y. Multiplying by a common denominator of the coordinates turns any rational magic square into an integral one. To preserve the stronger property that the entries are rational squares, take a common denominator of their square roots and multiply the whole square by the square of that denominator.

Integers

An integral magic square has integral E,x,y because these coordinates are integral differences of its entries; the converse is immediate from the formula. Its magic constant is necessarily divisible by 3. Primitivity is also read directly from the coordinates:

gcd{nine entries}=gcd(E,x,y).\gcd\{\text{nine entries}\}=\gcd(E,x,y).

Indeed, every entry is an integral linear combination of E,x,y, while E,x,y are themselves integral linear combinations of the entries. Hence the two gcds divide each other.

Fields of positive characteristic

The form m(E,x,y) and the three-dimensional classification remain valid in every characteristic, but the familiar geometry may degenerate. In characteristic 3 every magic square has M=3E=0, so M no longer determines the center. In characteristic 2 opposite entries coincide and the four side entries B,D,F,H share one value; the square cannot have nine pairwise distinct entries:

charK=2:A=J,C=G,B=D=F=H.\operatorname{char}K=2:\qquad A=J,\quad C=G,\quad B=D=F=H.

Over a ring in which 2 or 3 is not invertible, one should use the denominator-free form and recover E=Q₂₂, x=A−E, y=G−E. The formulas E=M/3, x=(A−J)/2, and y=(G−C)/2 are valid only when the corresponding elements are invertible.

6. Boundary of the linear theory

The theorem classifies all 3×3 magic squares, but by itself says nothing about positivity, distinctness, or square-valued entries. Positivity requires an order; being a square requires multiplication; requiring selected linear forms to be squares turns the linear problem into a Diophantine one. This is the point at which the k/9 problems, residue theory, norms, and elliptic surfaces begin.