5D Library › 黄历择吉布尔格、建除十二直同余与卢恩符文组合学 · English
第三章 联合周期:干支日、二十八宿与七曜
并行的几个周期
有三种日计数与太阳无关地贯穿通书:六十天的干支循环,二十八宿的值日循环,以及印有星期的通书里的七天一周。长度为 与 的两个周期,经过 天才一起回到原点,而 种组合中只有 种会出现。对干支日与二十八宿,。
推导
# 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 days从 2027 年 1 月 1 日(庚辰日、值鬼宿、星期五)起走 1,680 天,在 1,680 种可能的「干支-星宿」组合中只出现 420 种,第一个重复的组合出现在 420 天之后。因为 ,每个星宿总落在同一个星期几;角宿总在星期四,与传统上二十八宿配七曜的对应一致。相反,干支日与值神完全没有联合周期:值神依附于节气月,而节气月的长度不是整数天。
今年的吉日明年还吉吗
因为一个太阳年不是 60 天的整数倍,同一个日期的干支每年前移 5 或 6 位,值神也随之移动。所以附着在公历日期上的吉凶判定,不能从一年带到下一年。
推导
# 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: 0第一章的流派 A 判定 2027 年 0.258 的日子为吉,2028 年为 0.255。同一个日期在两年得到相同判定的比例是 0.685,而若两年的判定毫无关系,这个比例是 0.619;两年都是吉日的日期只有 36 个。略高于偶然的部分来自月份:同一日期每年都落在同一个节气月,月建因而固定,而日支在移动。2028 年没有任何节气落在离午夜 10 分钟之内,所以公式的低精度在这里不会移动任何重复日。
注
「吉日」不是日期。 某一年的嫁娶吉日表,对第二年同样的日期毫无意义。出售「今年吉日」的生意,出售的是一项每年都必须根据干支与节气重新计算的东西。
小结
六十干支与二十八宿有公因数 4,所以 1,680 种组合中只出现 420 种,每 420 天重复一次,每个星宿固定在一个星期几。一个日期在今年的判定与明年的判定一致的比例,只比偶然略高(0.685 对 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).