5D Library › Almanac Auspicious Boolean Lattices, Jianchu Twelve-Officer Congruences and Runic Combinatorics · 中文
Chapter 3. Joint Periods: Stem-Branch Days, the Twenty-Eight Lodges and the Week
Cycles that run side by side
Three day-counts run through an almanac without regard to the sun: the sexagenary stem-branch cycle of 60 days, the cycle of the 28 lodges (xiu), and, in almanacs that print it, the seven-day week. Two cycles of lengths and return together after days, and only of the combinations ever occur. For the stem-branch days and the lodges, .
Calculation
# Chapter 3. p05: The day cycles of the almanac and their joint period.
# Stem-branch days repeat every 60 days, the 28 lodges every 28 and the
# week every 7; since 28 = 4 x 7 each lodge always falls on the same
# weekday. gcd(60, 28) = 4, so a (stem-branch, lodge) pair repeats every
# lcm(60, 28) = 420 days and only 420 of the 60 x 28 = 1,680 pairs ever
# occur. Checked by walking 1,680 days from 2027-01-01 (geng-chen, lodge
# Gui, a Friday); also the 7 weekday-planets of the lodges.
import datetime
import math
if __name__ == "__main__":
d0 = datetime.date(2027, 1, 1)
pairs, weekday_of = set(), {}
first_repeat = None
for k in range(1680):
gz, lodge = (16 + k) % 60, (22 + k) % 28
wd = (d0 + datetime.timedelta(days=k)).weekday()
weekday_of.setdefault(lodge, set()).add(wd)
if (gz, lodge) in pairs and first_repeat is None:
first_repeat = k
pairs.add((gz, lodge))
print(" gcd(60, 28) = {}, lcm = {}".format(math.gcd(60, 28),
60 * 28 // math.gcd(60, 28)))
print(" distinct (stem-branch, lodge) pairs in 1,680 days: {} of {:,}"
.format(len(pairs), 60 * 28))
print(" first repeated pair after {} days".format(first_repeat))
print(" every lodge keeps one weekday: {}".format(
all(len(v) == 1 for v in weekday_of.values())))
print(" lodge 0 (Jiao) falls on weekday {} (0 = Monday)".format(
sorted(weekday_of[0])[0]))
print(" in 365 days: {} distinct pairs".format(
len({((16 + k) % 60, (22 + k) % 28) for k in range(365)})))
for n, m in ((60, 12), (60, 10), (60, 7), (12, 28)):
print(" cycles {:2d} and {:2d}: gcd {:2d}, joint period {:3d} days"
.format(n, m, math.gcd(n, m), n * m // math.gcd(n, m)))
# gcd(60, 28) = 4, lcm = 420
# distinct (stem-branch, lodge) pairs in 1,680 days: 420 of 1,680
# first repeated pair after 420 days
# every lodge keeps one weekday: True
# lodge 0 (Jiao) falls on weekday 3 (0 = Monday)
# in 365 days: 365 distinct pairs
# cycles 60 and 12: gcd 12, joint period 60 days
# cycles 60 and 10: gcd 10, joint period 60 days
# cycles 60 and 7: gcd 1, joint period 420 days
# cycles 12 and 28: gcd 4, joint period 84 daysWalking 1,680 days from 1 January 2027 (a geng-chen day in the lodge Gui, a Friday) produces only 420 of the 1,680 conceivable pairs of stem-branch and lodge, and the first pair to recur does so after 420 days. Because , every lodge always falls on the same weekday; the lodge Jiao always falls on a Thursday, matching the traditional pairing of the lodges with the seven luminaries. The stem-branch day and the officer, by contrast, have no joint period at all: the officer is tied to the solar months, whose lengths are not whole numbers of days.
Is a good date good again next year?
Because the solar year is not a multiple of 60 days, the stem-branch day of a date moves on by 5 or 6 places a year, and the officer moves with it. A judgement attached to a calendar date therefore does not carry from one year to the next.
Calculation
# Chapter 3. p06: Is the same date good again next year? School A of p02
# (good officer and a yellow-road god) is computed for every date of 2027
# and 2028, with the jie times from the solar formula of p04 (within 5
# minutes of NAOJ in 2027). The two years are compared date by date
# (29 February left out). If the verdicts were unrelated, agreement would
# be pA pB + (1 - pA)(1 - pB). Jie within 10 minutes of a midnight are
# reported, since only those could move a repeat day.
import datetime
import math
LON = (285, 315, 345, 15, 45, 75, 105, 135, 165, 195, 225, 255)
GOOD_OFFICER = {1, 4, 5, 7, 8, 10}
QINGLONG = {2: 0, 8: 0, 3: 2, 9: 2, 4: 4, 10: 4, 5: 6, 11: 6,
0: 8, 6: 8, 1: 10, 7: 10}
YELLOW = {0, 1, 4, 5, 7, 10}
EPOCH = datetime.datetime(2000, 1, 1, 12) # JD 2451545.0
def sun_lon(jde):
T = (jde - 2451545.0) / 36525
L0 = 280.46646 + 36000.76983 * T + 0.0003032 * T * T
M = math.radians(357.52911 + 35999.05029 * T - 0.0001537 * T * T)
C = ((1.914602 - 0.004817 * T - 0.000014 * T * T) * math.sin(M) +
(0.019993 - 0.000101 * T) * math.sin(2 * M) +
0.000289 * math.sin(3 * M))
om = math.radians(125.04 - 1934.136 * T)
return (L0 + C - 0.00569 - 0.00478 * math.sin(om)) % 360
def jie_times(year):
out = []
for k, lon in enumerate(LON):
t = datetime.datetime(year, k + 1, 6) - datetime.timedelta(hours=8)
jd = 2451545.0 + (t - EPOCH).total_seconds() / 86400
for _ in range(40):
jd += ((lon - sun_lon(jd + 69 / 86400) + 180) % 360 - 180) \
/ 0.9856
out.append(EPOCH + datetime.timedelta(days=jd - 2451545.0, hours=8))
return out
def verdicts(year):
jie = jie_times(year)
d0 = datetime.date(year, 1, 1)
gz0 = (d0.toordinal() + 1721425 + 49) % 60
out = {}
day = d0
while day.year == year:
n = sum(1 for j in jie if j.date() <= day)
b, M = (gz0 + (day - d0).days) % 12, n % 12
good = ((b - M) % 12 in GOOD_OFFICER and
(b - QINGLONG[M]) % 12 in YELLOW)
out[(day.month, day.day)] = good
day += datetime.timedelta(days=1)
near = [j for j in jie if min(j.hour * 60 + j.minute,
1440 - j.hour * 60 - j.minute) <= 10]
return out, near
if __name__ == "__main__":
a, na = verdicts(2027)
b, nb = verdicts(2028)
keys = [k for k in a if k in b]
agree = sum(1 for k in keys if a[k] == b[k]) / len(keys)
pa = sum(a[k] for k in keys) / len(keys)
pb = sum(b[k] for k in keys) / len(keys)
print(" good share 2027 {:.3f}, 2028 {:.3f}".format(pa, pb))
print(" same date, same verdict: {:.3f}; if unrelated {:.3f}".format(
agree, pa * pb + (1 - pa) * (1 - pb)))
both = sum(1 for k in keys if a[k] and b[k])
print(" dates good in both years: {} of {}".format(both, len(keys)))
print(" jie within 10 minutes of midnight: {}".format(len(na + nb)))
# good share 2027 0.258, 2028 0.255
# same date, same verdict: 0.685; if unrelated 0.619
# dates good in both years: 36 of 365
# jie within 10 minutes of midnight: 0School A of Chapter 1 calls 0.258 of the days of 2027 good and 0.255 of 2028. The same date receives the same verdict in both years 0.685 of the time, against 0.619 if the two years’ verdicts were unrelated; only 36 dates are good in both years. The slight excess over chance comes from the months: a date stays in the same solar month from year to year, which fixes the month branch, while the day branch moves. None of the 2028 solar terms falls within 10 minutes of midnight, so the low precision of the formula cannot move a repeat day here.
Note
“Lucky dates” are not dates. A list of good wedding dates for one year says nothing about the same dates the next year. A business that sells “this year’s lucky days” is selling a computation that has to be redone every year from the stem-branch and the solar terms.
Summary
The 60-day stem-branch cycle and the 28 lodges share a factor of 4, so only 420 of their 1,680 combinations occur, repeating every 420 days, and each lodge keeps one weekday. A date’s verdict in one year agrees with the next year’s verdict only a little more often than chance (0.685 against 0.619).
Fan, Y. (2026). Almanac Auspicious Boolean Lattices, Jianchu Twelve-Officer Congruences and Runic Combinatorics: Constraint Satisfaction Paradoxes, Solar-Term Phase Jumps and Elder Futhark Inversion Distributions [黄历择吉布尔格、建除十二直同余与卢恩符文组合学] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090239 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).