What does Dyadic Coupling and Grid Games conclude, in numbers, about “The Luoshu, the Eight Doors and Permutation Groups”?

Answer: Chapter 5 proves that the magic square of order three is unique up to symmetry, and that the flying and turning motions generate all 362,880 arrangements, of which only 8 stay magic.

Scope of the numbers: All data are synthetic, generated by its programs, and wherever physics or game theory is applied to people it is marked as an analogy. Chapter 7 reads the Tuan commentary on Xian and Heng, the Rhapsody of the Old Fisherman and Yang Hui's magic squares; that Xian upside down is Heng is read, as marked interpretation, as a transposed matrix.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 362880

   magic squares among 362,880 arrangements: 8
   centre value in every one: [5]
   all 8 are D4 images of one square: True
   semi-magic (rows and columns only): 72
   Yang Hui's rule gives  4 9 2 / 3 5 7 / 8 1 6   magic: True
   (nine on top, one below, three left, seven right)
Reading: up to the eight symmetries of the square there is
exactly one 3 x 3 magic square, and its centre is forced to be 5
(the four lines through the centre use every number once plus the
centre three more times: 4 x 15 = 45 + 3c). Yang Hui's four moves
produce it directly.
Show the full program
# Chapter 5. The Luoshu square: enumeration and Yang Hui's rule.
# A 3 x 3 normal magic square holds 1..9 with every row, column and both
# diagonals summing to 15. The program (1) checks all 9! = 362,880
# arrangements, (2) shows that the solutions are the 8 images of one square
# under the symmetries of the square (4 rotations, 4 reflections: the
# dihedral group D4), (3) counts the "semi-magic" arrangements (rows and
# columns only), and (4) carries out Yang Hui's rule of 1275 on a diamond:
# "nine numbers in slanting rows; exchange top and bottom; exchange left and
# right; the four corners step out".
from itertools import permutations

LINES = [(0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7), (2, 5, 8),
         (0, 4, 8), (2, 4, 6)]

def magic(sq, lines=LINES):
    return all(sq[a] + sq[b] + sq[c] == 15 for a, b, c in lines)

def rot(sq):
    return tuple(sq[i] for i in (6, 3, 0, 7, 4, 1, 8, 5, 2))

def flip(sq):
    return tuple(sq[i] for i in (2, 1, 0, 5, 4, 3, 8, 7, 6))

def d4(sq):
    out, s = set(), sq
    for _ in range(4):
        out.add(s)
        out.add(flip(s))
        s = rot(s)
    return out

def show(sq):
    return " / ".join(" ".join(str(v) for v in sq[r * 3:r * 3 + 3])
                      for r in range(3))

if __name__ == "__main__":
    sols = [p for p in permutations(range(1, 10)) if magic(p)]
    semi = sum(magic(p, LINES[:6]) for p in permutations(range(1, 10)))
    print("   magic squares among 362,880 arrangements: {}".format(len(sols)))
    print("   centre value in every one: {}".format(
        sorted({s[4] for s in sols})))
    print("   all 8 are D4 images of one square: {}".format(
        set(sols) == d4(sols[0])))
    print("   semi-magic (rows and columns only): {}".format(semi))
    # Yang Hui on a 5 x 5 board, (row, col) -> number
    board = {(0, 2): 1, (1, 1): 4, (1, 3): 2, (2, 0): 7, (2, 2): 5,
             (2, 4): 3, (3, 1): 8, (3, 3): 6, (4, 2): 9}
    board[(0, 2)], board[(4, 2)] = board[(4, 2)], board[(0, 2)]
    board[(2, 0)], board[(2, 4)] = board[(2, 4)], board[(2, 0)]
    moved = {(1, 2): board.pop((0, 2)), (3, 2): board.pop((4, 2)),
             (2, 1): board.pop((2, 0)), (2, 3): board.pop((2, 4))}
    board.update(moved)
    yang = tuple(board[(r, c)] for r in (1, 2, 3) for c in (1, 2, 3))
    print("   Yang Hui's rule gives  {}   magic: {}".format(
        show(yang), magic(yang)))
    print("   (nine on top, one below, three left, seven right)")
    print("\nReading: up to the eight symmetries of the square there is")
    print("exactly one 3 x 3 magic square, and its centre is forced to be 5")
    print("(the four lines through the centre use every number once plus the")
    print("centre three more times: 4 x 15 = 45 + 3c). Yang Hui's four moves")
    print("produce it directly.")

Single source and citation

Fan, Y. (2026). Dyadic Phase Coupling, Bilinear Compatibility Tensors and Spatiotemporal Grid Games (Version 1.0.0), Chapter 5: The Luoshu, the Eight Doors and Permutation Groups. 5D Library. https://doi.org/10.5281/zenodo.24090172

DOI: 10.5281/zenodo.24090172 · Read the monograph · 5DL-B-062 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026062,
  author    = {Fan, Yafu},
  title     = {Dyadic Phase Coupling, Bilinear Compatibility Tensors and Spatiotemporal Grid Games},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  doi       = {10.5281/zenodo.24090172},
  url       = {https://doi.org/10.5281/zenodo.24090172}
}

Other chapter answers in this book