5D Library › 黄历择吉布尔格、建除十二直同余与卢恩符文组合学 · English

第二章 建除十二直的分段同余与交节日的归属

一年跳拍十二次的同余式

建除十二神(建、除、满、平、定、执、破、危、成、收、开、闭)是一个简单的同余式。设 b(t)b(t) 为第 tt 天的地支(0 到 11),M(t)M(t) 为它所在节气月的月建,立春起为寅月,每交一个节加一。则值神为

o(t)≡b(t)−M(t)(mod⁡12).o(t) \equiv b(t) – M(t) \pmod{12}.

日支每天加一,月建每交一节加一;所以在交节那天两步相互抵消,值神重复前一天的。日本历法传统把这种重复称为「おどる」(跳),跳的值神就标出了交节之日 (国立天文台 2026)。因此一天的值神是 tt 的分段仿射函数,一年有十二个断点。

推导

# Chapter 2. p03: The twelve officers as a piecewise congruence.
# officer = (day branch - month branch) mod 12. The day branch advances
# by 1 every day; the month branch advances by 1 at each "jie", so on a
# jie day the officer repeats the previous day's. Listed: the 12 repeat
# days of 2027 (Beijing time), and how often each officer occurs.
import datetime

OFFICERS = ("jian chu man ping ding zhi po wei cheng shou kai bi").split()
# the 12 "jie" of 2027, Beijing time (UTC+8), from NAOJ's 2027 table
JIE = ((1, 5, 22, 10), (2, 4, 9, 46), (3, 6, 3, 40), (4, 5, 8, 17),
       (5, 6, 1, 25), (6, 6, 5, 26), (7, 7, 15, 37), (8, 8, 1, 27),
       (9, 8, 4, 28), (10, 8, 20, 17), (11, 7, 23, 39), (12, 7, 16, 38))
D0 = datetime.date(2027, 1, 1)          # geng-chen day, mansion Gui (22)

def days(offset_h=0):
    """One dict per day of 2027: stem, branch, month and year branch."""
    jie = [datetime.datetime(2027, m, d, h, mi) +
           datetime.timedelta(hours=offset_h) for m, d, h, mi in JIE]
    out = []
    for k in range(365):
        day = D0 + datetime.timedelta(days=k)
        n = sum(1 for j in jie if j.date() <= day)   # jie passed
        gz = (16 + k) % 60
        out.append({"date": day, "gz": gz, "s": gz % 10, "b": gz % 12,
                    "M": n % 12, "Y": 6 if n < 2 else 7,
                    "mansion": (22 + k) % 28})
    return out

BR = "zi chou yin mao chen si wu wei shen you xu hai".split()

if __name__ == "__main__":
    ds = days()
    off = [(d["b"] - d["M"]) % 12 for d in ds]
    print("   repeat days of 2027 (officer, day branch, month branch):")
    reps = [k for k in range(1, 365) if off[k] == off[k - 1]]
    for k in reps:
        d = ds[k]
        print("     {}  {:6s} {:5s} month {}".format(
            d["date"].isoformat(), OFFICERS[off[k]], BR[d["b"]],
            BR[d["M"]]))
    cnt = [off.count(i) for i in range(12)]
    print("   repeats: {}; days per officer:".format(len(reps)))
    for h in (0, 6):
        print("     {}".format(" ".join("{}={}".format(OFFICERS[i], cnt[i])
                                        for i in range(h, h + 6))))
    naive = [(d["b"] - ds[0]["b"] + off[0]) % 12 for d in ds]
    wrong = sum(1 for x, y in zip(naive, off) if x != y)
    print("   a plain 12-day cycle with no repeats is wrong on {} of 365"
          " days".format(wrong))
#    repeat days of 2027 (officer, day branch, month branch):
#      2027-01-05  wei    shen  month chou
#      2027-02-04  jian   yin   month yin
#      2027-03-06  zhi    shen  month mao
#      2027-04-05  kai    yin   month chen
#      2027-05-06  ding   you   month si
#      2027-06-06  kai    chen  month wu
#      2027-07-07  ding   hai   month wei
#      2027-08-08  bi     wei   month shen
#      2027-09-08  zhi    yin   month you
#      2027-10-08  kai    shen  month xu
#      2027-11-07  ping   yin   month hai
#      2027-12-07  cheng  shen  month zi
#    repeats: 12; days per officer:
#      jian=30 chu=29 man=29 ping=30 ding=32 zhi=32
#      po=30 wei=31 cheng=31 shou=29 kai=32 bi=30
#    a plain 12-day cycle with no repeats is wrong on 336 of 365 days

2027 年的十二次重复落在从 1 月 5 日到 12 月 7 日的各个交节日。重复的是哪个值神因年而异:2027 年立春(2 月 4 日)重复的是「建」,因为那天是寅月中的寅日,所以 2 月 3 日与 4 日都是建日。重复使十二神在一年里分布略不均匀:定、执、开各 32 天,除、满、收各 29 天。一个只是循环十二个名称、不做重复的黄历应用,每交一节就错开一位,一年 365 天里有 336 天是错的。

交节日是哪一天

重复落在节气的当地日期。时刻接近午夜的节气,在不同时区会落在不同的日期上,按一地计算的通书就与按另一地计算的不同。

推导

# Chapter 2. p04: Which day is the jie day? The repeat falls on the
# local date of the solar term, so an almanac computed for another time
# zone can differ. Counted: days of 2027 whose officer differs from the
# Beijing (UTC+8) almanac when computed for UTC+9, UTC+7, UTC-5 and
# UTC-8. Also: a low-precision solar formula (Meeus, about 0.01 degree)
# against NAOJ's published times, and jie that fall within an hour of
# midnight in Beijing.
import math
import datetime

OFFICERS = ("jian chu man ping ding zhi po wei cheng shou kai bi").split()
# the 12 "jie" of 2027, Beijing time (UTC+8), from NAOJ's 2027 table
JIE = ((1, 5, 22, 10), (2, 4, 9, 46), (3, 6, 3, 40), (4, 5, 8, 17),
       (5, 6, 1, 25), (6, 6, 5, 26), (7, 7, 15, 37), (8, 8, 1, 27),
       (9, 8, 4, 28), (10, 8, 20, 17), (11, 7, 23, 39), (12, 7, 16, 38))
D0 = datetime.date(2027, 1, 1)          # geng-chen day, mansion Gui (22)

def days(offset_h=0):
    """One dict per day of 2027: stem, branch, month and year branch."""
    jie = [datetime.datetime(2027, m, d, h, mi) +
           datetime.timedelta(hours=offset_h) for m, d, h, mi in JIE]
    out = []
    for k in range(365):
        day = D0 + datetime.timedelta(days=k)
        n = sum(1 for j in jie if j.date() <= day)   # jie passed
        gz = (16 + k) % 60
        out.append({"date": day, "gz": gz, "s": gz % 10, "b": gz % 12,
                    "M": n % 12, "Y": 6 if n < 2 else 7,
                    "mansion": (22 + k) % 28})
    return out

LON = (285, 315, 345, 15, 45, 75, 105, 135, 165, 195, 225, 255)

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_formula(k):
    """Beijing time of the k-th jie of 2027 by the formula (Delta T 69 s)."""
    t0 = datetime.datetime(2027, JIE[k][0], JIE[k][1], 12)
    jd = 2461406.5 + (t0 - datetime.datetime(2027, 1, 1)).total_seconds() \
        / 86400 - 8 / 24
    for _ in range(40):
        jd += ((LON[k] - sun_lon(jd + 69 / 86400) + 180) % 360 - 180) \
            / 0.9856
    return datetime.datetime(2027, 1, 1) + datetime.timedelta(
        days=jd - 2461406.5 + 8 / 24)

if __name__ == "__main__":
    base = [(d["b"] - d["M"]) % 12 for d in days()]
    for name, off in (("UTC+9", 1), ("UTC+7", -1), ("UTC-5", -13),
                      ("UTC-8", -16)):
        o = [(d["b"] - d["M"]) % 12 for d in days(off)]
        diff = [days()[k]["date"].isoformat() for k in range(365)
                if o[k] != base[k]]
        word = "day differs" if len(diff) == 1 else "days differ"
        shown = ", ".join(diff[:3]) + (" ..." if len(diff) > 3 else "")
        print("   {}: {} {}{}".format(
            name, len(diff), word, (": " + shown) if diff else ""))
    err = []
    for k, (m, d, h, mi) in enumerate(JIE):
        pub = datetime.datetime(2027, m, d, h, mi)
        err.append((jie_formula(k) - pub).total_seconds() / 60)
    print("   formula minus NAOJ: {:.1f} to {:.1f} minutes".format(
        min(err), max(err)))
    for m, d, h, mi in JIE:
        if h == 23 or h == 0:
            print("   within an hour of midnight: 2027-{:02d}-{:02d} "
                  "{:02d}:{:02d} Beijing".format(m, d, h, mi))
#    UTC+9: 1 day differs: 2027-11-07
#    UTC+7: 0 days differ
#    UTC-5: 7 days differ: 2027-02-03, 2027-03-05, 2027-04-04 ...
#    UTC-8: 8 days differ: 2027-02-03, 2027-03-05, 2027-04-04 ...
#    formula minus NAOJ: -4.5 to -0.8 minutes
#    within an hour of midnight: 2027-11-07 23:39 Beijing

2027 年立冬在北京时间 11 月 7 日 23:39,而在东京已是 11 月 8 日 00:39。所以按 UTC+9 计算的通书与北京版有 1 天不同;按 UTC+7 计算的没有不同。按纽约(UTC-5)计算的有 7 天不同,按洛杉矶(UTC-8)计算的有 8 天不同,因为在北京上午交节的节气,在那里落在前一天晚上。用来核对的低精度太阳公式 (Meeus 1998) 给出的 2027 年节气时刻,比公布值早 4.5 到 0.8 分钟,只有在节气离午夜仅几分钟时才有影响;2027 年最接近午夜的是立冬,相差 21 分钟。

2027 年前 60 天的值神序号,标出两次重复(交节日)(p03)。

注

注明地点。 通书的值神、月神与按月起算的神煞,都是针对某一地点与时区定义的。照搬北京日期却不说明的海外通书,与按手机本地时间计算却不说明的应用,可能都「没错」,却彼此不一致。

小结

值神是 b−M(mod⁡12)b – M \pmod{12},一个在十二个节各重复一次的同余式;2027 年立春重复的是建。不做重复的简单循环有 336 天出错。因为重复落在节气的当地日期,东京、纽约、洛杉矶的通书与北京版在 2027 年分别有 1、7、8 天不同。

参考文献

Meeus, Jean. 1998. Astronomical Algorithms. 2nd ed. Willmann-Bell.
国立天文台. 2026. 暦Wiki:十二直. National Astronomical Observatory of Japan. https://eco.mtk.nao.ac.jp/koyomi/wiki/BDBDC6F3C4BE.html.

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