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.

4☴ 巽SE
9☲ 离S
2☷ 坤SW
3☳ 震E
5C
7☱ 兑W
8☶ 艮NE
1☵ 坎N
6☰ 乾NW
The Luoshu arrangement — the only way to place 1–9 so every line sums to 15.

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."

— Traditional Luoshu mnemonic (戴九履一,左三右七)

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.

Row4 + 9 + 2 = 15
Column4 + 3 + 8 = 15
Row3 + 5 + 7 = 15
Column9 + 5 + 1 = 15
Row8 + 1 + 6 = 15
Column2 + 7 + 6 = 15
Diagonal4 + 5 + 6 = 15
Diagonal2 + 5 + 8 = 15
All eight lines of the Luoshu sum to 15 — roughly the length of one solar term in days.

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.)

Key Insight

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."

Yang Dun 阳遁 — ascending
Used from Winter Solstice to Summer Solstice, when light is growing. Symbols fly forward through the numbers.
1 2 3 4 5 6 7 8 9
Yin Dun 阴遁 — descending
Used from Summer Solstice to Winter Solstice, when light is receding. The same path, walked in reverse.
9 8 7 6 5 4 3 2 1
The two halves of the year walk the same Luoshu path in opposite directions.

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.

Try It Now

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.