What does Hexagram and Star-Palace Mathematics conclude, in numbers, about “The Number of the Great Expansion, the Before-Heaven Diagrams and the Origins of the *Zi Wei Dou Shu*”?
Answer: Chapter 7 reads the number of the great expansion, Zhu Xi's divination procedure, Shao Yong's Before-Heaven diagrams and the textual history of the Zi Wei Dou Shu; the Before-Heaven diagrams are exactly binary counting, and the King Wen order has a rank correlation of −0.004 with binary value.
Scope of the numbers: Marked boxes separate published evidence, runnable Python calculations (16 programs), classical sources and the author's hypotheses.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it.
values along Shao Yong's sequence: [63, 62, 61, 60, 59, 58] ... [2, 1, 0] sequence is 63, 62, ..., 0: True trigram order values: [7, 6, 5, 4, 3, 2, 1, 0] 8 x 8 square, first row (upper Qian): [63, 55, 47, 39, 31, 23, 15, 7] rank correlation of King Wen order with binary value: -0.004 Reading: Shao Yong's sequence and square are exactly binary counting, read from the bottom line. The received King Wen order is a different principle altogether: pairs by reversal and complement (p01 of Chapter 1), with no trend in binary value.
Show the full program
# Chapter 7. Shao Yong's "Before Heaven" order is counting in binary.
# Shao Yong (1011-1077) arranged the 64 hexagrams in a sequence and in a
# square of 8 x 8, starting from Qian and ending with Kun. Read each
# hexagram as a six-digit binary number with yang = 1, yin = 0 and the
# BOTTOM line as the highest digit: the sequence is then 63, 62, ..., 0,
# and the trigram order Qian Dui Li Zhen Xun Kan Gen Kun is 7, 6, ..., 0.
# This is the observation Bouvet sent to Leibniz in 1701. The program
# checks it from the received sequence (listed by King Wen number) and the
# trigram table, and compares the King Wen order with the binary values.
TRI = {"qian": (1, 1, 1), "dui": (1, 1, 0), "li": (1, 0, 1),
"zhen": (1, 0, 0), "xun": (0, 1, 1), "kan": (0, 1, 0),
"gen": (0, 0, 1), "kun": (0, 0, 0)} # bottom line first
KING_WEN = [ # upper, lower for 1..64
"qian qian", "kun kun", "kan zhen", "gen kan",
"kan qian", "qian kan", "kun kan", "kan kun",
"xun qian", "qian dui", "kun qian", "qian kun",
"qian li", "li qian", "kun gen", "zhen kun",
"dui zhen", "gen xun", "kun dui", "xun kun",
"li zhen", "gen li", "gen kun", "kun zhen",
"qian zhen", "gen qian", "gen zhen", "dui xun",
"kan kan", "li li", "dui gen", "zhen xun",
"qian gen", "zhen qian", "li kun", "kun li",
"xun li", "li dui", "kan gen", "zhen kan",
"gen dui", "xun zhen", "dui qian", "qian xun",
"dui kun", "kun xun", "dui kan", "kan xun",
"dui li", "li xun", "zhen zhen", "gen gen",
"xun gen", "zhen dui", "zhen li", "li gen",
"xun xun", "dui dui", "xun kan", "kan dui",
"xun dui", "zhen gen", "kan li", "li kan",
]
XIANTIAN = [ # King Wen numbers in Shao Yong's order
1, 43, 14, 34, 9, 5, 26, 11, 10, 58, 38, 54, 61, 60, 41, 19,
13, 49, 30, 55, 37, 63, 22, 36, 25, 17, 21, 51, 42, 3, 27, 24,
44, 28, 50, 32, 57, 48, 18, 46, 6, 47, 64, 40, 59, 29, 4, 7,
33, 31, 56, 62, 53, 39, 52, 15, 12, 45, 35, 16, 20, 8, 23, 2,
]
def bits(n):
upper, lower = KING_WEN[n - 1].split()
return TRI[lower] + TRI[upper]
def value(h): # bottom line is the highest digit
return sum(b << (5 - i) for i, b in enumerate(h))
def spearman(x, y):
n = len(x)
rx = {v: i for i, v in enumerate(sorted(x))}
ry = {v: i for i, v in enumerate(sorted(y))}
d = sum((rx[a] - ry[b]) ** 2 for a, b in zip(x, y))
return 1 - 6 * d / (n * (n * n - 1))
if __name__ == "__main__":
vals = [value(bits(n)) for n in XIANTIAN]
print(" values along Shao Yong's sequence: {} ... {}".format(
vals[:6], vals[-3:]))
print(" sequence is 63, 62, ..., 0: {}".format(
vals == list(range(63, -1, -1))))
order = "qian dui li zhen xun kan gen kun".split()
print(" trigram order values: {}".format(
[sum(b << (2 - i) for i, b in enumerate(TRI[t])) for t in order]))
square = [[value(TRI[lo] + TRI[up]) for lo in order] for up in order]
print(" 8 x 8 square, first row (upper Qian): {}".format(square[0]))
kw_vals = [value(bits(n)) for n in range(1, 65)]
print(" rank correlation of King Wen order with binary value:"
" {:+.3f}".format(spearman(list(range(64)), kw_vals)))
print("\nReading: Shao Yong's sequence and square are exactly binary")
print("counting, read from the bottom line. The received King Wen order")
print("is a different principle altogether: pairs by reversal and")
print("complement (p01 of Chapter 1), with no trend in binary value.")Single source and citation
Fan, Y. (2026). Six-Dimensional Hypercube Walks, Hexagram Mutation Markov Chains and Modular Star-Palace Lattices (Version 1.0.0), Chapter 7: The Number of the Great Expansion, the Before-Heaven Diagrams and the Origins of the *Zi Wei Dou Shu*. 5D Library. https://doi.org/10.5281/zenodo.24090176
DOI: 10.5281/zenodo.24090176 · Read the monograph · 5DL-B-064 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026064,
author = {Fan, Yafu},
title = {Six-Dimensional Hypercube Walks, Hexagram Mutation Markov Chains and Modular Star-Palace Lattices},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
doi = {10.5281/zenodo.24090176},
url = {https://doi.org/10.5281/zenodo.24090176}
}Other chapter answers in this book
- Chapter 1 · The Sixty-Four Hexagrams Are a Six-Dimensional Cube
- Chapter 2 · Yarrow Stalks and Coins: the Exact Odds of the Two Methods
- Chapter 3 · The Markov Chain of Changing Hexagrams and Its Spectral Gap
- Chapter 4 · Which Text Is Read: the Rules for Moving Lines and a Good-or-Bad Function
- Chapter 5 · The Placement Rules of Zi Wei Dou Shu Are Maps Modulo 12
- Chapter 6 · "Three Sides and Four Squares" Is a Convolution on the Ring of Twelve Palaces
- Chapter 8 · A Four-Step Check and a Pre-Registered Matching Test