5D Library › 五节点循环网络动力学、黄经历表与多尺度振子扰动 · English
第六章 平气与定气、不等间距插值与历法常数的漂移
从数学模型回到历表
前四章的环是抽象的。本章回到第一章的太阳,看中国历法史上三个具体的数值问题:二十四节气是把一年平分(平气),还是按太阳的真实黄经划分(定气)?在节气之间推算太阳位置时,等间距插值与不等间距插值有何不同?历法常数写成分数后,误差如何随世纪累积?这三个问题都可以用本书的程序直接回答。
平气与定气
推导
两种划分。 定气:太阳视黄经达到 的时刻。平气:冬至时刻加 乘以回归年的二十四分之一。两者之差来自太阳运动的不均匀,即第一章的开普勒方程。
推导
# Chapter 6. p12: Mean solar terms (pingqi) against true solar terms (dingqi).
# True terms: the Sun's apparent longitude reaches 270 + 15k deg (the low-
# precision solar theory of p03). Mean terms: the winter-solstice instant
# plus k times (tropical year / 24), the tropical year 365.2422 days.
# Winter solstice of 2026 to that of 2027. Reported: the gap between the
# two dates of each term, and the length of each true-term interval.
import math
NAMES = ("Winter solstice", "Minor cold", "Major cold", "Spring begins",
"Rain water", "Insects waken", "Spring equinox", "Pure brightness",
"Grain rain", "Summer begins", "Grain buds", "Grain in ear",
"Summer solstice", "Minor heat", "Major heat", "Autumn begins",
"End of heat", "White dew", "Autumn equinox", "Cold dew",
"Frost descends", "Winter begins", "Minor snow", "Major snow")
def sun_lon(jd):
t = (jd - 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 when(target, jd0):
lo, hi = jd0, jd0 + 40
while (sun_lon(hi) - target) % 360 > 180:
hi += 5
for _ in range(60):
mid = (lo + hi) / 2
if (sun_lon(mid) - target) % 360 < 180:
hi = mid
else:
lo = mid
return (lo + hi) / 2
if __name__ == "__main__":
ws = when(270.0, 2461380.5) # around 2026 Dec 22
true, j = [ws], ws
for k in range(1, 25):
j = when((270 + 15 * k) % 360, j + 10)
true.append(j)
year = 365.2422
print("winter solstice 2026 at JD {:.4f}; next at JD {:.4f}".format(
true[0], true[24]))
print("\n term true - mean (days) interval (days)")
worst = 0.0
for k in range(24):
gap = true[k] - (ws + k * year / 24)
worst = max(worst, abs(gap))
print(" {:<18} {:+6.3f} {:6.3f}".format(
NAMES[k], gap, true[k + 1] - true[k]))
iv = [b - a for a, b in zip(true, true[1:])]
print("\nlargest gap {:.3f} days".format(worst))
print("intervals: shortest {:.3f}, longest {:.3f}, mean {:.4f}".format(
min(iv), max(iv), sum(iv) / 24))
print("\nReading: equal division of the year misplaces the true terms")
print("by up to 2.4 days, because the Sun moves fastest near")
print("perihelion in early January: true terms near the winter")
print("solstice are under fifteen days apart, those near the summer")
print("solstice nearly fifteen and three-quarters.")
# winter solstice 2026 at JD 2461396.3675; next at JD 2461761.6092
#
# term true - mean (days) interval (days)
# Winter solstice +0.000 14.720
# Minor cold -0.498 14.724
# Major cold -0.993 14.760
# Spring begins -1.451 14.826
# Rain water -1.843 14.919
# Insects waken -2.142 15.033
# Spring equinox -2.328 15.160
# Pure brightness -2.386 15.292
# Grain rain -2.312 15.421
# Summer begins -2.109 15.537
# Grain buds -1.791 15.631
# Grain in ear -1.379 15.696
# Summer solstice -0.901 15.729
# Minor heat -0.390 15.725
# Major heat +0.116 15.685
# Autumn begins +0.583 15.613
# End of heat +0.977 15.514
# White dew +1.272 15.394
# Autumn equinox +1.448 15.264
# Cold dew +1.494 15.132
# Frost descends +1.408 15.007
# Winter begins +1.197 14.898
# Minor snow +0.877 14.810
# Major snow +0.468 14.750
#
# largest gap 2.386 days
# intervals: shortest 14.720, longest 15.729, mean 15.2184
#
# Reading: equal division of the year misplaces the true terms
# by up to 2.4 days, because the Sun moves fastest near
# perihelion in early January: true terms near the winter
# solstice are under fifteen days apart, those near the summer
# solstice nearly fifteen and three-quarters.2026 年冬至到 2027 年冬至,平气与定气之差最大 2.386 天,出现在清明前后:平分一年得到的清明比真实的清明晚 2.386 天。秋分前后则相反,平气早 1.448 到 1.494 天。定气的间隔并不相等:冬至后的第一个间隔最短,14.720 天;夏至前后最长,15.729 天;平均 15.2184 天,即回归年的二十四分之一。短的间隔在冬季、长的在夏季,因为地球在一月初过近日点,那时太阳视运动最快。
等间距与不等间距插值
历法要在节气之间推算任意时刻的太阳位置。最简单的做法是假定太阳在每一段里匀速运动;更好的做法是用三个节点作二次插值。隋代刘焯的《皇极历》引入了等间距的二次插值;唐代一行的《大衍历》以定气为节点,节点在时间上不等距,因而需要不等间距的二次插值 (Needham and Wang 1959; 陈美东 2003)。
推导
牛顿差商。 对时间上不等距的三个节点 , 其中一阶差商 ,二阶差商 。节点等距时,它退化为等间距的二次插值公式。
推导
# Chapter 6. p13: Interpolating the Sun between tabulated nodes.
# Task: the Sun's longitude at any moment of the year, from a table.
# L linear between true-term nodes (the Sun moves evenly within each
# 15-degree step)
# E equal-interval quadratic: nodes at the mean terms (equal times,
# the true longitude tabulated there), three nodes at a time - the
# kind of second-difference scheme Liu Zhuo's Huangji calendar (600)
# introduced
# U unequal-interval quadratic: nodes at the true terms (equal steps
# in longitude, unequal in time), Newton divided differences on
# three nodes - the case Yixing's Dayan calendar (727) had to solve
# Truth: the low-precision theory of p03/p12. Error is sampled every
# 0.05 day through the year from the 2026 winter solstice.
import math
def sun_lon(jd):
t = (jd - 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 when(target, jd0):
lo, hi = jd0, jd0 + 40
for _ in range(60):
mid = (lo + hi) / 2
if (sun_lon(mid) - target) % 360 < 180:
hi = mid
else:
lo = mid
return (lo + hi) / 2
def unwrap(vals):
out = [vals[0]]
for v in vals[1:]:
while v < out[-1] - 180:
v += 360
out.append(v)
return out
def quad(xs, ys, x):
d1 = (ys[1] - ys[0]) / (xs[1] - xs[0])
d2 = (ys[2] - ys[1]) / (xs[2] - xs[1])
dd = (d2 - d1) / (xs[2] - xs[0])
return ys[0] + d1 * (x - xs[0]) + dd * (x - xs[0]) * (x - xs[1])
def pick(nodes, x):
i = max(k for k in range(len(nodes) - 1) if nodes[k] <= x)
i = min(max(i, 1), len(nodes) - 2)
return i - 1
if __name__ == "__main__":
ws = when(270.0, 2461380.5)
true_t = [ws]
for k in range(1, 27):
true_t.append(when((270 + 15 * k) % 360, true_t[-1] + 10))
true_l = [270.0 + 15 * k for k in range(27)]
step = 365.2422 / 24
mean_t = [ws + k * step for k in range(27)]
mean_l = unwrap([sun_lon(t) for t in mean_t])
err = {"L": 0.0, "E": 0.0, "U": 0.0}
rms = {"L": 0.0, "E": 0.0, "U": 0.0}
n, t = 0, ws + 0.05
while t < ws + 365.0:
truth = unwrap([270.0, sun_lon(t)])[1]
while truth < 270.0:
truth += 360
i = max(k for k in range(26) if true_t[k] <= t)
lin = true_l[i] + 15 * (t - true_t[i]) / (true_t[i + 1] - true_t[i])
j = pick(mean_t, t)
e = quad(mean_t[j:j + 3], mean_l[j:j + 3], t)
j = pick(true_t, t)
u = quad(true_t[j:j + 3], true_l[j:j + 3], t)
for key, val in (("L", lin), ("E", e), ("U", u)):
d = (val - truth) * 60 # arcminutes
err[key] = max(err[key], abs(d))
rms[key] += d * d
n += 1
t += 0.05
print(" scheme max error rms error")
for key, name in (("L", "L linear on true terms"),
("E", "E equal-interval quadratic"),
("U", "U unequal-interval quadratic")):
print(" {:<34} {:7.3f}' {:7.3f}'".format(
name, err[key], math.sqrt(rms[key] / n)))
print(" (arcminutes; the Sun moves about 59' a day)")
print("\nReading: treating the Sun as moving evenly inside each step")
print("costs up to about one arcminute - some 24 minutes of solar")
print("motion. Either quadratic scheme cuts the error about sevenfold;")
print("but on the true-term table, whose nodes are unequally spaced in")
print("time, only the unequal-interval formula applies.")
# scheme max error rms error
# L linear on true terms 0.978' 0.507'
# E equal-interval quadratic 0.143' 0.067'
# U unequal-interval quadratic 0.134' 0.067'
# (arcminutes; the Sun moves about 59' a day)
#
# Reading: treating the Sun as moving evenly inside each step
# costs up to about one arcminute - some 24 minutes of solar
# motion. Either quadratic scheme cuts the error about sevenfold;
# but on the true-term table, whose nodes are unequally spaced in
# time, only the unequal-interval formula applies.把太阳在每个节气段里当作匀速运动,最大误差 0.978 角分,均方根 0.507 角分;太阳每天约走 59 角分,所以这相当于约 24 分钟的太阳运动。等间距二次插值把最大误差降到 0.143 角分,不等间距二次插值降到 0.134 角分,两者都把误差缩小约七倍,均方根同为 0.067 角分。
两种二次插值的精度相当,区别在于适用的表:以平气为节点的表,节点等距,可以用等间距公式;以定气为节点的表,节点在时间上不等距,只能用不等间距公式。一行采用定气为节点,因而需要不等间距的方法——这是数学形式跟着历表结构走的例子。
历法常数:分数与漂移
推导
# Chapter 6. p14: Calendar constants as rational numbers, and their drift.
# Each calendar fixed a year and a month as fractions of a day:
# Santong (Liu Xin, Han) year 365 + 385/1539, month 29 + 43/81
# Sifen (85 CE) year 365 + 1/4, month 29 + 499/940
# Dayan (Yixing, 727) year 1110343/3040, month 89773/3040
# Shoushi (1281) year 365.2425, month 29.530593
# Modern mean values (near 2000): tropical year 365.24219 days, synodic
# month 29.530589 days (they change slowly; this is a first-order
# comparison). Drift = error x elapsed years (or months), in days per
# century. The 19-year, 235-month cycle (zhang) error is also shown.
from fractions import Fraction as F
YEAR, MONTH = 365.24219, 29.530589
CAL = (("Santong", F(365) + F(385, 1539), F(29) + F(43, 81)),
("Sifen", F(365) + F(1, 4), F(29) + F(499, 940)),
("Dayan", F(1110343, 3040), F(89773, 3040)),
("Shoushi", F(3652425, 10000), F(29530593, 1000000)))
if __name__ == "__main__":
print(" calendar year (days) month (days) year drift month"
" drift")
print(" " + " " * 41 + "(d/century) (d/century)")
for name, y, m in CAL:
dy = (float(y) - YEAR) * 100
dm = (float(m) - MONTH) * 100 * 12.368
print(" {:<9} {:11.6f} {:11.7f} {:+7.3f} {:+7.3f}"
.format(name, float(y), float(m), dy, dm))
print("\n 19 years versus 235 months, modern values: {:+.4f} days"
.format(235 * MONTH - 19 * YEAR))
s_y, s_m = CAL[0][1], CAL[0][2]
print(" Santong: 235 months - 19 years = {} days exactly".format(
235 * s_m - 19 * s_y))
print(" Santong drift from 104 BCE to 85 CE (188 years): {:+.2f}"
" days".format((float(s_y) - YEAR) * 188))
print("\nReading: the Han Santong year is long by about 0.8 days a")
print("century, so its solstices fell visibly late within two")
print("centuries; the Dayan constants are good to about a fifth of a")
print("day a century, and the Shoushi year to a thirtieth. Built into")
print("Santong's fractions, 235 months equal 19 years exactly - the")
print("cycle is a definition there, not an approximation.")
# calendar year (days) month (days) year drift month drift
# (d/century) (d/century)
# Santong 365.250162 29.5308642 +0.797 +0.340
# Sifen 365.250000 29.5308511 +0.781 +0.324
# Dayan 365.244408 29.5305921 +0.222 +0.004
# Shoushi 365.242500 29.5305930 +0.031 +0.005
#
# 19 years versus 235 months, modern values: +0.0868 days
# Santong: 235 months - 19 years = 0 days exactly
# Santong drift from 104 BCE to 85 CE (188 years): +1.50 days
#
# Reading: the Han Santong year is long by about 0.8 days a
# century, so its solstices fell visibly late within two
# centuries; the Dayan constants are good to about a fifth of a
# day a century, and the Shoushi year to a thirtieth. Built into
# Santong's fractions, 235 months equal 19 years exactly - the
# cycle is a definition there, not an approximation.历法把回归年与朔望月写成分数。汉代的三统历取年长 日、月长 日,年长比现代平均值每世纪多 0.797 日;从太初改历(公元前 104 年)到四分历(公元 85 年)的 188 年里,冬至会推迟约 1.50 日。唐代大衍历的年长 365.244408 日,每世纪只多 0.222 日,月长几乎精确(每世纪 0.004 日)。元代授时历的年长 365.2425 日,每世纪只多 0.031 日。
三统历的分数还有一个结构上的特点:用它的年长与月长计算,235 个月恰好等于 19 年,差为 0。用现代数值算,两者相差 0.0868 日。也就是说,十九年七闰的章法在三统历里是一个定义,而不是一个近似;它的近似误差被转嫁到年长与月长本身。
注
数字的出处与核对。 三统历、四分历、大衍历、授时历的常数据科学史文献中的通行数值 (Cullen 2017; 陈美东 2003; Sivin 2009),现代平均回归年与朔望月取公元 2000 年前后的值;两者都随时间缓慢变化,本章的漂移只是一阶比较。大衍历的年长与月长以通法 3040 为分母,分子(策实 1110343、揲法 89773)与《新唐书·历志》所载一致。
假说 · 尚未验证
作者的假说(尚未验证): 历代历法常数的改进,主要来自更长的观测基线,而不是更精细的分数:把各家年长误差对其所依据的观测年代跨度作图,误差大致与跨度成反比。什么结果会证明它错:误差与观测跨度无关,或主要由分母大小决定。
小结
平分一年的平气与按真实黄经划分的定气最多相差 2.386 天,定气间隔从 14.720 天到 15.729 天不等。在节气之间推算太阳位置,两种二次插值都比匀速假定精确约七倍;以定气为节点时节点不等距,必须用一行式的不等间距公式。三统历的年长每世纪多 0.797 日,大衍历 0.222 日,授时历 0.031 日;三统历的分数使 235 个月恰等于 19 年。
参考文献
Fan, Y. (2026). Five-Node Cyclic Network Dynamics, Solar-Longitude Ephemeris and Multi-Scale Oscillator Perturbations: Rock-Paper-Scissors-Lizard-Spock Lotka-Volterra Graphs, Equation-of-Time Keplerian Mechanics and Jacobian Sensitivity Bounds [五节点循环网络动力学、黄经历表与多尺度振子扰动] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090168 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).