Abstract
Placing $1$ to $n^2$ once each in an $n\times n$ grid so that every row, column and both diagonals have the same sum gives a magic square (the sum is $15$ for $3\times3$ and $34$ for $4\times4$). All are counted by computer, and which values each cell can hold is examined. No new theorem or law is claimed.
First, there is only one $3\times3$——checking all $362880$ arrangements of $1$ to $9$, there are $8$ magic squares, and $1$ once those differing by rotation and reflection are taken as the same. The centre is always $5$, the corners are limited to $2$, $4$, $6$, $8$ and the edge middles to $1$, $3$, $7$, $9$ (Section 2).
Second, and this is the core. In the $3\times3$, the four lines through the centre cover every cell, so the centre is fixed——the middle row, middle column and two diagonals sum to $4\times15=60$, which counts the centre $4$ times and the other eight cells once each. All cells sum to $45$, so the centre is $(60-45)/3=5$. In the $5\times5$, the four lines through the centre cover only $17$ of the $25$ cells, and this reasoning does not work (Sections 2 and 4).
Third, in the $4\times4$ no cell is fixed——a backtracking search choosing eight cells, with the other eight fixed by the sum $34$, found $7040$, or $880$ up to rotation and reflection (agreeing with the known value). Every cell can hold any of $1$ to $16$. What is fixed is the sum of the four corners and the sum of the central four cells, $34$ in all $7040$ (Section 3).
Fourth, order $6$, which has no orthogonal Latin squares, still has magic squares——the square made as $4A+B+1$ from two orthogonal Latin squares $A$, $B$ of order $4$ is magic and in the list of $7040$. Order $6$ has no orthogonal mates, so this construction cannot be used, but one $6\times6$ magic square with all row, column and diagonal sums $111$ was confirmed (Section 4).
Keywords: magic square, 3x3 magic square, 4x4 magic square, backtracking search, pandiagonal magic square.
Scope (what is not claimed)
No new theorem or law is claimed——that the $3\times3$ magic square is essentially unique, that the $4\times4$ number $880$ up to rotation and reflection (Frénicle, $1693$), and that magic squares can be made from orthogonal Latin squares (Euler) are known. Counts for $5\times5$ and beyond are not made——for $5\times5$, only that the lines through the centre do not cover the grid is looked at. Relation to earlier papers: Paper 604 showed that no Latin square of order $6$ has an orthogonal mate——Euler’s construction of magic squares from two orthogonal Latin squares was confirmed at order $4$ but cannot be used at order $6$. Even so, a $6\times6$ magic square exists by another arrangement. What is added is counting the $3\times3$ by all permutations and the $4\times4$ by backtracking, confirming closure under rotation and reflection, counting which values each cell can hold, and placing the separator on whether the lines through one cell cover the grid.
1. Notation and the Question
Setting: $1$ to $n^2$ are placed once each in an $n\times n$ grid so that every row, column and both diagonals sum to $n(n^2+1)/2$. This sum is $15$ for order $3$, $34$ for $4$, $65$ for $5$ and $111$ for $6$.
Question: how many magic squares are there, and which cells are fixed?
2. 3×3
Computation 2.1: all $362880$ arrangements of $1$ to $9$ were checked. There are $8$ magic squares, $1$ once those differing by rotation and reflection are taken as the same. The values each cell can hold are $5$ at the centre, $2$, $4$, $6$, $8$ at the corners and $1$, $3$, $7$, $9$ at the edge middles.
Observation 2.2 this is the core: in the $3\times3$, the four lines through the centre cover every cell. With centre $c$, the middle row, middle column and two diagonals sum to
$$4\times15=60=(1+2+\cdots+9)+3c=45+3c,$$so $c=5$. The four lines cover the centre $4$ times and the other eight cells once each, so their sum is written by the sum of all cells and the centre alone——and the $8$ with centre $5$ differ from one another only by rotation and reflection.
3. 4×4
Computation 3.1: choosing eight cells, three in the first row, two in the first column, two on the diagonal and one in the second row, fixes the other eight by the row, column and diagonal sums $34$. This backtracking search found $7040$ ($6.8$ seconds). Every one is truly magic, with no duplicates, and $880$ remain once rotation and reflection are taken as the same.
Computation 3.2: over the $7040$, counting the values each cell can hold gave $16$ for every one of the sixteen cells. The sum of the four corners and the sum of the central four cells were $34$ in all $7040$. Those with every broken diagonal also summing to $34$ (pandiagonal squares) number $384$ ($48$ up to rotation and reflection), and those where cells opposite through the centre always sum to $17$ (associative squares) also number $384$ ($48$).
Observation 3.3 in the $4\times4$, adding lines fixes no single cell; it fixes sums. Since every cell can hold $16$ values, no way of adding lines fixes a single cell as the centre of the $3\times3$ is fixed——the sums of the corners and of the central four are fixed, but what goes inside them stays free and spreads into $880$ arrangements.
4. Orders 5 and 6
Computation 4.1: in the $5\times5$, the four lines through the centre (middle row, middle column and two diagonals) cover $17$ of the $25$ cells. Their sum cannot be written by the sum of all cells and the centre alone.
Computation 4.2: the square made as $4A+B+1$ from two orthogonal Latin squares $A$, $B$ of order $4$ is the following; it is magic and is in the list of $7040$.
| $1$ | $6$ | $11$ | $16$ |
|---|---|---|---|
| $12$ | $15$ | $2$ | $5$ |
| $14$ | $9$ | $8$ | $3$ |
| $7$ | $4$ | $13$ | $10$ |
Computation 4.3: the following $6\times6$ uses $1$ to $36$ once each, and all its rows, columns and diagonals sum to $111$.
| $35$ | $1$ | $6$ | $26$ | $19$ | $24$ |
|---|---|---|---|---|---|
| $3$ | $32$ | $7$ | $21$ | $23$ | $25$ |
| $31$ | $9$ | $2$ | $22$ | $27$ | $20$ |
| $8$ | $28$ | $33$ | $17$ | $10$ | $15$ |
| $30$ | $5$ | $34$ | $12$ | $14$ | $16$ |
| $4$ | $36$ | $29$ | $13$ | $18$ | $11$ |
Observation 4.4 having no construction and having no object are different things. Order $6$ has no orthogonal Latin squares, and the construction overlaying them cannot be used. Even so, $6\times6$ magic squares exist by another arrangement——the limit of one construction is not the limit of what can be made.
5. The Separator
Observation 5.1 the separator is whether the lines through one cell cover the grid. In the $3\times3$ the four lines through the centre cover every cell, the centre is fixed at $5$, and the arrangements narrow to one. In the $4\times4$ no set of lines fixes a single cell, only sums are fixed, and there are $880$ arrangements. In the $5\times5$ the four lines through the centre cover only $17$ cells——under the same “make the sums equal”, how the lines overlap decides what is fixed.
Observation 5.2 beside Paper 604. Paper 604 showed that no Latin square of order $6$ has an orthogonal mate——here the construction of magic squares from two orthogonal Latin squares was confirmed at order $4$, and one example showed that at order $6$ magic squares exist even though that construction cannot be used.
Observation 5.3 what is not said. Counts of magic squares of order $5$ and beyond are not made, and the general construction of $6\times6$ squares is not entered——what is shown is the full counts for $3\times3$ and $4\times4$, the values each cell can hold, and the difference in how the lines cover the grid.
6. Roll Call and Closing
- $3\times3$: $8$, or $1$ up to symmetry (Computation 2.1): by all permutations.
- the centre is always $5$ (Computation 2.1): even corners, odd edges.
- four lines through the centre cover every cell (Observation 2.2): the core.
- $4\times4$: $7040$, or $880$ up to symmetry (Computation 3.1): by backtracking.
- $16$ values in every cell (Computation 3.2): none fixed.
- corners and central four sum to $34$ (Computation 3.2): sums are fixed.
- $384$ pandiagonal and $384$ associative (Computation 3.2): $48$ each up to symmetry.
- $17$ cells for the four lines of $5\times5$ (Computation 4.1): not covering.
- a $6\times6$ magic square exists (Computation 4.3): sums $111$.
- a construction’s limit is not the object’s (Observation 4.4): Paper 604.
Closing: The $3\times3$ magic square of $1$ to $9$ is $8$ among all $362880$ arrangements, only $1$ up to rotation and reflection, always with $5$ at the centre. The four lines through the centre cover every cell, so $4\times15=45+3c$ fixes the centre at $5$. The $4\times4$ has $7040$, or $880$ up to symmetry, and every cell can hold any of $1$ to $16$——what is fixed is not a cell but the sums of the corners and of the central four cells. The separator is whether the lines through one cell cover the grid. Placed among the earlier papers——even at order $6$, where Paper 604 found no orthogonal mate, a magic square exists by another arrangement. To be honest——neither counts for order $5$ and beyond nor the general construction of $6\times6$ squares is entered.
References
- Euler, L. (1782). Recherches sur une nouvelle espèce de quarrés magiques. Verhandelingen uitgegeven door het zeeuwsch Genootschap der Wetenschappen te Vlissingen.
- Yamagishi, Y. (2026). No Latin Square of Order Six Has an Orthogonal Mate [Paper 604]. Zenodo. 10.5281/zenodo.23014438
Reference
Yamagishi, Y. (2026). The 3×3 Magic Square Has Its Centre Fixed at 5 and Is Unique, While the 4×4 Fixes No Cell and Has 880 [Paper 638]. YOI: https://www.yamagishiyuuki.com/yoi/638
DOI: 10.5281/zenodo.23014602
ORCID: 0009-0006-8587-3450
PDF (English) · PDF (Japanese) · Date proof of the English PDF (OpenTimestamps .ots) · SHA256SUMS
The record page for this paper (in Japanese, with the PDFs in each language and the date proof): YOI 638. This paper is a preprint and has not been peer reviewed.