Back to the multiplication-algebra series

Matrix multiplication algebra · 6.1

Magic, charming, and semimagic squares

A product of two magic 3×3 squares need not be magic, but it always preserves equality of all row and column sums. This observation leads naturally to semimagic and charming squares, their multiplication laws, and the complete five-dimensional algebra.

1. From magic squares to semimagic matrices

We use the previously proved general form of a magic square:

M(E,x,y)=(E+xEx+yEyExyEE+x+yE+yE+xyEx).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}.

Set s₀=M(1,0,0), s₁=M(0,1,0), and s₂=M(0,0,1). Then M(E,x,y)=Es₀+xs₁+ys₂. Direct multiplication of these three basis matrices shows that a product of two magic squares generally loses the diagonal conditions while retaining equal row and column sums.

s1s_1(110101011)\begin{pmatrix} 1&-1&0\\-1&0&1\\0&1&-1 \end{pmatrix}
s2s_2(011101110)\begin{pmatrix} 0&1&-1\\-1&0&1\\1&-1&0 \end{pmatrix}
s12s_1^2(211121112)\begin{pmatrix} 2&-1&-1\\-1&2&-1\\-1&-1&2 \end{pmatrix}

The last matrix has zero row and column sums, but its main diagonal sums to 6. Hence the space of magic squares is not closed under matrix multiplication. The property that survives defines a larger class: a matrix is semimagic when all of its row sums and column sums agree.

2. Central reversal and two components

For a semimagic 3×3 matrix, write the common row and column sum as 3E. Central reversal separates these matrices into two natural classes. Let P denote the reversal matrix and 𝟙 the all-ones matrix:

P=(001010100),1=(111111111).P= \begin{pmatrix}0&0&1\\0&1&0\\1&0&0\end{pmatrix}, \qquad \mathbf 1= \begin{pmatrix}1&1&1\\1&1&1\\1&1&1\end{pmatrix}.

In standard terminology, a semimagic matrix A of weight E is associated when A+PAP=2E𝟙, and balanced, or centrosymmetric, when PAP=A.

Correspondence theorem

Over a field of characteristic other than 2 or 3, the associated semimagic 3×3 matrices are exactly the magic squares M(E,x,y). The balanced semimagic 3×3 matrices are exactly the matrices C(E,z,w), called charming squares in this project.

Proof for the associated component

In M(E,x,y), every centrally opposite pair sums to 2E, so M+PMP=2E𝟙. Conversely, the associated condition gives central entry E and sum 2E for every opposite pair. Both principal diagonals therefore sum to 3E; together with the semimagic conditions, the matrix is magic.

Proof for the balanced component

A centrosymmetric matrix with equal row and column sums first has the form on the left. Comparing its first row with its first column forces d=b, and equality of sums gives e=a+c−b:

(abcdedcba)=(abcba+cbbcba). \begin{pmatrix}a&b&c\\d&e&d\\c&b&a\end{pmatrix} = \begin{pmatrix}a&b&c\\b&a+c-b&b\\c&b&a\end{pmatrix}.

Setting E=(a+b+c)/3, z=(a−b)/3, and w=(c−b)/3 gives the unique form

C(E,z,w)=(E+2zwEzwEz+2wEzwE+2z+2wEzwEz+2wEzwE+2zw).C(E,z,w)= \begin{pmatrix} E+2z-w&E-z-w&E-z+2w\\ E-z-w&E+2z+2w&E-z-w\\ E-z+2w&E-z-w&E+2z-w \end{pmatrix}.

3. The four product laws

Expanding products in the basis gives four exact formulas. They are polynomial identities and require no division:

M(E1,x1,y1)M(E2,x2,y2)=C(3E1E2, x1x2y1y2, y1x2x1y2),M(E1,x1,y1)C(E2,x2,y2)=3M(E1E2, x1x2y1y2, y1x2x1y2),C(E1,x1,y1)M(E2,x2,y2)=3M(E1E2, x1x2+y1y2, y1x2+x1y2),C(E1,x1,y1)C(E2,x2,y2)=3C(E1E2, x1x2+y1y2, y1x2+x1y2).\begin{aligned} M(E_1,x_1,y_1)M(E_2,x_2,y_2) &=C(3E_1E_2,\ x_1x_2-y_1y_2,\ y_1x_2-x_1y_2),\\ M(E_1,x_1,y_1)C(E_2,x_2,y_2) &=3M(E_1E_2,\ x_1x_2-y_1y_2,\ y_1x_2-x_1y_2),\\ C(E_1,x_1,y_1)M(E_2,x_2,y_2) &=3M(E_1E_2,\ x_1x_2+y_1y_2,\ y_1x_2+x_1y_2),\\ C(E_1,x_1,y_1)C(E_2,x_2,y_2) &=3C(E_1E_2,\ x_1x_2+y_1y_2,\ y_1x_2+x_1y_2). \end{aligned}

Thus MM lands in C, MC and CM land in M, and CC lands in C. Factor order matters: the second coordinates in the MC and CM formulas differ. In particular, every product of an odd number of magic squares is magic, while every product of an even number is charming.

The last statement follows by induction on the number of factors using the four inclusions, rather than by checking individual products.

4. The complete semimagic form

To describe the full semimagic class, add a magic square of weight E to a zero-sum charming square. This gives the five-dimensional form:

S(E,x,y,z,w)=M(E,x,y)+C(0,z,w)=(E+x+2zwEx+yzwEyz+2wExyzwE+2z+2wE+x+yzwE+yz+2wE+xyzwEx+2zw).S(E,x,y,z,w)=M(E,x,y)+C(0,z,w) = \begin{pmatrix} E+x+2z-w&E-x+y-z-w&E-y-z+2w\\ E-x-y-z-w&E+2z+2w&E+x+y-z-w\\ E+y-z+2w&E+x-y-z-w&E-x+2z-w \end{pmatrix}.

Classification theorem

Over a field of characteristic other than 2 or 3, the map (E,x,y,z,w)↦S(E,x,y,z,w) is a bijection from K⁵ to the set of semimagic 3×3 matrices.

Forward direction

Every row and column of M(E,x,y) sums to 3E, while every row and column of C(0,z,w) sums to 0. Hence every row and column of S(E,x,y,z,w) sums to 3E.

Reverse direction and uniqueness

Let A be semimagic with common sum T. If its upper-left block is denoted by a,b,d,e, the equations for the first two rows and columns force every remaining entry in succession:

A=(abTabdeTdeTadTbea+b+d+eT).A= \begin{pmatrix} a&b&T-a-b\\ d&e&T-d-e\\ T-a-d&T-b-e&a+b+d+e-T \end{pmatrix}.

The last row and last column then automatically sum to T. Thus the five quantities T,a,b,d,e describe every semimagic matrix uniquely. When division by 2 and 3 is available, the same five degrees of freedom translate into our coordinates:

E=T3,x=a11a332,y=a31a132,u=a11+a332E,v=a13+a312E,z=2u+v3,w=u+2v3.\begin{gathered} E=\frac{T}{3},\qquad x=\frac{a_{11}-a_{33}}2,\qquad y=\frac{a_{31}-a_{13}}2,\\ u=\frac{a_{11}+a_{33}}2-E,\qquad v=\frac{a_{13}+a_{31}}2-E,\\ z=\frac{2u+v}{3},\qquad w=\frac{u+2v}{3}. \end{gathered}

Substituting the forced form of A into these expressions and then into S recovers all nine entries of A. The recovery formulas prove both existence and uniqueness of E,x,y,z,w.

5. Canonical decomposition and grading

The complete form already contains the canonical decomposition

S(E,x,y,z,w)=C(E,z,w)+M(0,x,y).S(E,x,y,z,w)=C(E,z,w)+M(0,x,y).

The charming part contains the common center and serves as the even component; the zero-center magic part serves as the odd component. Their intersection is zero: if C(E,z,w)=M(0,x,y), equality of common sums gives E=0, and uniqueness of the five coordinates gives x=y=z=w=0.

By the four product laws, the degree of a product of homogeneous components is the sum of their degrees modulo 2. Thus the five-dimensional semimagic algebra is ℤ/2ℤ-graded.

6. Generation by magic squares

The first product law shows that a product of two magic squares is charming. An exact converse holds for every zero-sum charming component: it can always be obtained from one fixed magic factor and one variable factor.

Exact formula

S(E,x,y,z,w)=M(E,x,y)+M(0,1,0)M(0,z,w).S(E,x,y,z,w) =M(E,x,y)+M(0,1,0)M(0,z,-w).

The first product law gives M(0,1,0)M(0,z,−w)=C(0,z,w), so the right-hand side is exactly the definition of S. Therefore every rational semimagic 3×3 square is a sum of a magic square and a product of two magic squares.

This does not claim that the three magic factors are unique. What is unique is the decomposition into the charming part C(E,z,w) and the zero-center magic part M(0,x,y).

7. Scope of the results

This page proves the classification and product laws over fields in which 2 and 3 are invertible, while the product identities themselves are integral polynomial identities. Over ℤ a full semimagic matrix may have common sum not divisible by 3, so the coordinates S(E,x,y,z,w) do not cover the entire integral lattice. That boundary requires a separate article.

The next article constructs the isomorphism with K⊕M₂(K), isolates the four-dimensional zero-sum ideal, and gives an explicit split-quaternion basis 1,i,j,k inside it.