What Is a Magic Square?
A magic square is a grid of numbers in which every row, every column, and both diagonals add up to the same total. The 3×3 version — using each number from 1 to 9 exactly once — has essentially only one solution. Rotate it, mirror it, and you always get the same underlying pattern. That unique pattern is the Luoshu (洛书), and it is the skeleton of every Qimen Dunjia chart ever cast.
This is not decoration. The magic-square property means the grid is perfectly balanced in every direction — no row is heavier than another, no corner outweighs its opposite. For a system designed to model how forces distribute themselves across space and time, that balance is the whole point.
The Luoshu Legend — A Turtle from the River Luo
Chinese tradition says the pattern was discovered by Yu the Great (大禹), the legendary tamer of floods, around 2000 BCE. While working on the River Luo, a divine turtle emerged from the water with a pattern of dots on its shell: one dot near the tail, nine near the head, three on the left flank, seven on the right — the full magic square, written in nature.
Whatever you make of the turtle, the mathematics is real and old. The Luoshu is one of the earliest recorded magic squares anywhere in the world, and it became a foundational diagram of Chinese cosmology — feeding into the I Ching, feng shui, traditional medicine, and, most systematically of all, Qimen Dunjia.
"Carry the nine, tread the one;
three on the left, seven on the right."
Why Fifteen? The Number Hidden in the Calendar
Fifteen is not an arbitrary total. The ancient Chinese solar calendar divides the year into 24 solar terms (节气), and each solar term lasts almost exactly 15 days. The number that balances every line of the grid is the same number that paces the seasons — which is exactly the kind of correspondence Qimen is built on: the structure of space mirroring the structure of time.
Notice also that every opposite pair sums to 10 through the center: 1–9, 2–8, 3–7, 4–6. The center, 5, is the pivot of the whole system — which is why Palace 5 in a Qimen chart is the "commander's seat" and never receives a door of its own.
From Luoshu to the Nine Palaces
Qimen Dunjia takes the Luoshu and loads it with meaning. Each of the nine numbers becomes a palace (宫), and each palace inherits a compass direction, an I Ching trigram, one of the five elements, and a seasonal character. Palace 1 sits in the north and carries Water; Palace 9 sits in the south and carries Fire; the diagonal corners hold Earth, Metal and Wood between them.
When you cast a chart, the Eight Doors, Nine Stars, and Eight Deities are distributed across this fixed grid. The grid never changes — what changes is which symbols land in which palace at a given hour. If the palaces are the chessboard, the doors and stars are the pieces. (For what each individual term means, see the Glossary — this article is about the "why" of the board itself.)
The Luoshu's balance is what makes chart comparison meaningful. Because every direction of the grid carries equal weight, a symbol's position — north or southwest, corner or edge — adds information without bias. A lopsided grid would tilt every reading.
How the Magic Square Drives Chart Rotation
Here is where the square stops being history and starts being machinery. When a Qimen chart is cast, symbols "fly" through the palaces following the Luoshu number order — a fixed path from 1 to 9 that zig-zags across the grid. Practitioners call this 飞宫, "flying the palaces."
Because the path is fixed and the totals are balanced, the rotation is fully deterministic: given a date, time and location, there is exactly one correct chart. That determinism is what allows QimenIT to compute your chart astronomically instead of by hand — same ancient path, same ancient square, calculated to the second.
Want to see the Luoshu in motion? Cast a chart for this very hour and watch where the nine stars have flown — no account required.