What does Hexagram and Star-Palace Mathematics conclude, in numbers, about “The Markov Chain of Changing Hexagrams and Its Spectral Gap”?
Answer: Chapter 3 writes the change from cast to changed hexagram as a product Markov chain on the cube: both methods have spectral gap 1/2 and forget their start within three steps, against 8 for a one-line walk; the yarrow chain is not symmetric, Qian changing into Kun 729 times as often as Kun into Qian.
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. standard-library Python onlyprinted values that match the answer: 729
yarrow: rows sum to 1: True; eigenfunctions verified: True
second eigenvalue 1/2 -> spectral gap 1/2; stationary yang share 1/4
P(Qian -> Kun) = 729/262144, P(Kun -> Qian) = 1/262144
matrix symmetric: False
coins: rows sum to 1: True; eigenfunctions verified: True
second eigenvalue 1/2 -> spectral gap 1/2; stationary yang share 1/2
P(Qian -> Kun) = 1/4096, P(Kun -> Qian) = 1/4096
matrix symmetric: True
Reading: both methods give a chain with the same spectral gap,
1/2: every pattern of lines loses half its weight per step. The
coin chain is symmetric and drifts to all 64 hexagrams equally.
The yarrow chain is not: Qian turns into Kun 729 times as often
as Kun turns into Qian, and the chain drifts to a yin-heavy
state in which a line is yang only a quarter of the time.Show the full program
# Chapter 3. From a hexagram to its changed hexagram: a Markov chain.
# Cast a hexagram and let its moving lines flip: given the cast's yin/yang
# pattern x, the changed hexagram y is random. Per line, a yang line
# flips with a = P(9) / P(yang) and a yin line with b = P(6) / P(yin):
# yarrow a = 3/8, b = 1/8 coins a = b = 1/4
# Lines flip independently, so P(x -> y) is a product of six 2 x 2 steps.
# Repeating "take the changed hexagram as the next cast pattern" defines a
# Markov chain on the 64 vertices of the cube. Its eigenfunctions are the
# products chi_S(x) = prod over i in S of (x_i - pi), pi = b / (a + b)
# the stationary share of yang, with eigenvalues (1 - a - b)^|S|. The
# program builds the 64 x 64 matrix exactly and checks all of this.
from fractions import Fraction as F
from itertools import combinations
def chain(a, b):
states = [tuple((n >> i) & 1 for i in range(6)) for n in range(64)]
def step(u, v):
if u == 1:
return a if v == 0 else 1 - a
return b if v == 1 else 1 - b
p = {}
for x in states:
for y in states:
pr = F(1)
for u, v in zip(x, y):
pr *= step(u, v)
p[x, y] = pr
return states, p
def check(a, b):
states, p = chain(a, b)
rows_ok = all(sum(p[x, y] for y in states) == 1 for x in states)
pi = b / (a + b)
lam = 1 - a - b
ok = True
for k in range(7):
for s in combinations(range(6), k):
def chi(x):
out = F(1)
for i in s:
out *= x[i] - pi
return out
for x in states:
lhs = sum(p[x, y] * chi(y) for y in states)
ok &= lhs == lam ** k * chi(x)
qian, kun = (1,) * 6, (0,) * 6
return rows_ok, ok, pi, lam, p[qian, kun], p[kun, qian], states, p
if __name__ == "__main__":
for label, a, b in (("yarrow", F(3, 8), F(1, 8)),
("coins", F(1, 4), F(1, 4))):
rows_ok, ok, pi, lam, qk, kq, states, p = check(a, b)
sym = all(p[x, y] == p[y, x] for x in states for y in states)
print(" {}: rows sum to 1: {}; eigenfunctions verified: {}"
.format(label, rows_ok, ok))
print(" second eigenvalue {} -> spectral gap {};"
" stationary yang share {}".format(lam, 1 - lam, pi))
print(" P(Qian -> Kun) = {}, P(Kun -> Qian) = {}".format(qk, kq))
print(" matrix symmetric: {}".format(sym))
print("\nReading: both methods give a chain with the same spectral gap,")
print("1/2: every pattern of lines loses half its weight per step. The")
print("coin chain is symmetric and drifts to all 64 hexagrams equally.")
print("The yarrow chain is not: Qian turns into Kun 729 times as often")
print("as Kun turns into Qian, and the chain drifts to a yin-heavy")
print("state in which a line is yang only a quarter of the time.")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 3: The Markov Chain of Changing Hexagrams and Its Spectral Gap. 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 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 7 · The Number of the Great Expansion, the Before-Heaven Diagrams and the Origins of the *Zi Wei Dou Shu*
- Chapter 8 · A Four-Step Check and a Pre-Registered Matching Test