从公式到像素From Formula to Pixel

一个 HTML 文件里的四个数值实验Four numerical experiments in one HTML file

Claude 2026 年 11 月 10 日10 November 2026

(b) 所指像素的那条光线The ray behind the selected pixel

碰撞参数Impact parameter
—
绕过的角度Angle swept
—
结局Fate
—

(c) 偏折角:式 (2) 与两个极限Deflection angle: Eq. (2) and its two limits

闭式closed form弱场weak field 强场近似strong-field limit所指光线selected ray

图 1 不自转的黑洞与它的吸积盘,由你的显卡此刻逐像素算出。(a) 每个像素沿式 (1) 反向追踪一条光线,直到它落入视界、撞上盘面或逃向星空;盘的颜色是温度为 的黑体的颜色, 见式 (4)。拖动画面可以绕着黑洞看;把光标停在任意像素上,(b) 画出那条光线在它自己的轨道平面里怎么走(实心圆是视界 ,虚线圆是光子球 ,粗灰线是盘面),(c) 标出它的碰撞参数。Figure 1 A non-rotating black hole and its accretion disk, computed pixel by pixel on your graphics card as you read. (a) Each pixel traces one ray backwards along Eq. (1) until it falls through the horizon, hits the disk, or escapes to the sky; the disk has the colour of a black body at temperature , with given by Eq. (4). Drag the image to orbit the hole. Rest the pointer on any pixel and (b) shows how that ray moves in its own orbital plane (solid disc: the horizon ; dashed circle: the photon sphere ; thick grey line: the disk), while (c) marks its impact parameter.

摘要 这是一篇可以运行的论文。文中的四幅图都不是图片,而是此刻正在你的浏览器里计算的程序:图 1 逐像素积分光子在黑洞附近的测地线;图 2 用外推法积分三体问题,并量出混沌的增长率;图 3 现场训练一个小神经网络,把高斯噪声“流”成你画的任意形状;图 4 把一段文字编成二维码,再从被涂坏的码里把它纠错读回来。四个实验守同一条规矩:从公式出发,一直写到像素为止,中间不调用任何库,文件也不发出任何网络请求。文末的表 1 是自检报告:页面打开时当场运行 24 项断言,每一项都拿正在运行的这份代码,去对照一个独立得到的结果。

关键词 零测地线;Bulirsch–Stoer 外推;流匹配;Reed–Solomon 码;可复现性

Abstract This is a paper that runs. Its four figures are programs executing in your browser right now: a per-pixel integration of null geodesics around a Schwarzschild black hole; an extrapolation integrator for the three-body problem that measures the growth rate of chaos; a small neural network trained on the spot to transport Gaussian noise onto any shape you draw; and a QR encoder whose Reed–Solomon decoder recovers the text from a symbol you have damaged. Everything from the governing equation down to the pixel is written here by hand, with no libraries and no network requests. Table 1 is a self-check: 24 assertions that run when the page opens, each comparing the running code against an independently obtained result.

Keywords null geodesics; Bulirsch–Stoer extrapolation; flow matching; Reed–Solomon codes; reproducibility

1光线在黑洞附近怎么走How light travels near a black hole

图 1 的每个像素都是一条光线。从相机出发、逆着光的传播方向追过去,它只有三种结局:落进视界,像素是黑的;撞上吸积盘,像素取盘在那一点的颜色;逃到无穷远,像素取那个方向的星空。全部物理都在“光线怎么弯”这一件事里。Every pixel of Figure 1 is a ray of light. Followed from the camera against its direction of travel, a ray can end in only three ways: it falls through the horizon and the pixel is black; it hits the accretion disk and the pixel takes the disk's colour at that point; or it escapes to infinity and the pixel shows the sky in that direction. All of the physics lies in one question: how does the ray bend?

对不带电、不自转的黑洞(史瓦西度规,取 ),光子的轨道落在一个过中心的平面内。用 作变量,轨道方程只有一行:For an uncharged, non-rotating black hole (the Schwarzschild metric, with ), a photon's orbit lies in a plane through the centre. In the variable the orbit equation takes one line:

(1)

左边等于零时它描述极坐标里的一条直线,右边的 是广义相对论的全部修正。这一项在 时可以忽略,在 处恰好能让光子绕着黑洞转圈,那里叫光子球。一条光线的命运由它的碰撞参数 决定: 小于临界值 的被俘获,略大于 的先绕黑洞若干圈再离开。能离开的光线,总偏折角有闭式[1]:With the left-hand side set to zero it describes a straight line in polar coordinates; the term on the right is the whole of the general-relativistic correction. It is negligible for , and at it is exactly strong enough to hold a photon on a circle, the photon sphere. The fate of a ray is fixed by its impact parameter : rays with below the critical value are captured, and rays slightly above it wind around the hole several times before leaving. For a ray that leaves, the total deflection has a closed form[1]:

(2)

其中 是近心点半径,由 给出, 与 是第一类完全、不完全椭圆积分。图 1(c) 画的就是这条曲线: 很大时它回到爱因斯坦的 , 时按 发散[2]。where is the radius of closest approach, given by , and and are the complete and incomplete elliptic integrals of the first kind. Figure 1(c) plots this curve: for large it reduces to Einstein's , and as it diverges like [2].

着色器并不直接用式 (2),因为它事先不知道光线半路会不会撞上盘,只能一步一步走。式 (1) 等价于平直空间里一个质点在有心力 作用下的轨迹, 沿途守恒。于是在三维里用蛙跳法推进位置和速度即可,每走一步顺便检查有没有穿过盘面、有没有掉进 。The shader does not use Eq. (2) directly: it cannot know in advance whether a ray will hit the disk on the way, so it has to march step by step. Eq. (1) is equivalent to the trajectory of a particle in flat space under the central force , with conserved along the path. Position and velocity are therefore advanced in three dimensions with a leapfrog scheme, and each step also checks whether the ray has crossed the disk plane or fallen inside .

代码 1 逐像素追踪的主循环(页面正在运行的源码,JavaScript 版;着色器里是逐行对应的 GLSL)Listing 1 The main loop of the per-pixel tracer (the source this page is running, with its comments translated; this is the JavaScript version, and the shader contains the same lines in GLSL)

有两处细节决定画面对不对。其一,相机是静止在 处的观察者,它眼里的角度和坐标系里的角度不是一回事:把视线方向换到坐标系时,径向分量要乘上 。漏掉这个因子, 处的阴影会被画大 2.6%;加上它,阴影的角半径就应该满足 。表 1 里有一项专门用二分法从渲染器中量出这个角来核对。Two details decide whether the picture is right. First, the camera is an observer at rest at , and the angles it sees are not coordinate angles: when a viewing direction is converted to the coordinate frame, its radial component must be multiplied by . Leave this factor out and the shadow at is drawn 2.6% too large; with it, the angular radius of the shadow should satisfy . One row of Table 1 measures this angle from the renderer by bisection and compares.

其二是颜色。盘取 Page 与 Thorne 的相对论薄盘模型[3],单位面积的辐射流量是The second detail is colour. The disk follows the relativistic thin-disk model of Page and Thorne[3], whose radiated flux per unit area is

(3)

它在最内稳定圆轨道 处降为零,在 处最大,有效温度 。盘上的气体以角速度 绕转,观察者收到的光子频率是发射时的 倍:It falls to zero at the innermost stable circular orbit and peaks near ; the effective temperature goes as . Gas in the disk orbits with angular velocity , and a photon reaches the observer with times the frequency it was emitted at:

(4)

是光子绕盘轴的角动量与能量之比。黑体辐射经过多普勒频移和引力红移之后仍是黑体,只是温度变成 。所以每个像素的颜色,就是温度为 的黑体的颜色:把普朗克谱乘上 CIE 1931 配色函数[4]积分,再转到 sRGB。朝我们转过来的一侧 ,又蓝又亮;转离的一侧又红又暗。关掉图 1 下面的“多普勒与红移”,盘立刻左右对称,这一项有多大一目了然。Here is the ratio of the photon's angular momentum about the disk axis to its energy. Black-body radiation that has been Doppler-shifted and gravitationally redshifted is still black-body radiation, only at temperature . The colour of each pixel is therefore the colour of a black body at : the Planck spectrum integrated against the CIE 1931 colour-matching functions[4] and converted to sRGB. The side rotating towards us has and is bluer and brighter; the receding side is redder and dimmer. Untick Doppler and redshift under Figure 1 and the disk becomes left–right symmetric at once, which shows how large this effect is.

至于画面的形状:盘在黑洞背后的那一半并没有被挡住。从它上表面出发的光被弯过黑洞上方,成了罩在阴影顶上的那道拱;从它下表面出发的光绕过下方,成了阴影底下那道细弧;紧贴阴影边缘还有一圈极细的亮环,是绕了黑洞半圈以上才出来的光。Luminet 在 1979 年第一次算出这幅图[5],再用墨水一点一点画在纸上;这里交给显卡实时重算。As for the shape of the image: the half of the disk behind the hole is not hidden. Light leaving its upper surface is bent over the top of the hole and becomes the arch above the shadow; light from its lower surface passes underneath and becomes the thin arc below; and hugging the edge of the shadow is a very thin bright ring, made of light that went more than half-way around the hole before escaping. Luminet first computed this picture in 1979[5] and then drew it on paper dot by dot in ink; here the graphics card recomputes it in real time.

背景的星空是程序生成的,但对待它的方式并不随便。恒星是点光源,被引力透镜放大以后仍然是一个点,只是更亮;如果把星空当成一张贴图去采样,黑洞周围的星星就会被拉成一段段弧线。着色器因此用屏幕空间的导数,把每颗星在天球上的偏移换算回屏幕上的像素,再画一个大小不变的圆点,亮度按放大率调整。The background sky is procedural, but it is not treated carelessly. A star is a point source, and after magnification by the gravitational lens it is still a point, only brighter; sampling the sky as if it were a texture would stretch the stars near the hole into arcs. The shader therefore uses screen-space derivatives to convert each star's offset on the celestial sphere back into pixels on the screen, and draws a dot of constant size whose brightness is scaled by the magnification.

2三体:同一组方程,两种性格Three bodies: one set of equations, two temperaments

三个质点两两以平方反比的引力相吸(取 )。直接积分三个位置矢量有一个隐患:两个天体贴得很近时,它们的间距是两个大数之差,有效数字丢得很快。这里改用三条边 、、 作状态量,运动方程仍然封闭(下标对 3 取模):Three point masses attract one another in pairs with inverse-square gravity (). Integrating the three position vectors directly has a weakness: when two bodies come very close, their separation is the difference of two large numbers and significant digits are lost quickly. The state used here is instead the three edges , , , for which the equations of motion still close (indices modulo 3):

(5)

时间推进用 Gragg–Bulirsch–Stoer 外推法[6]。同一个大步 ,用修正中点法分别走 个子步,得到一列越来越准的结果 ;把它们看作 的函数,逐列外推到零:Time is advanced with Gragg–Bulirsch–Stoer extrapolation[6]. One large step is taken with the modified midpoint method using substeps, giving a sequence of increasingly accurate results ; regarded as functions of , they are extrapolated to zero column by column:

(6)

相邻两列之差小于容差(这里取相对 )就接受这一步。整个积分器里没有一个需要查表的系数,循环里只用到加减乘除和开方,所以同一组初值在任何浏览器里都算出逐位相同的轨道。The step is accepted once two neighbouring columns differ by less than the tolerance (a relative here). The integrator contains no tabulated coefficients, and its loop uses only the four arithmetic operations and square roots, so the same initial conditions give a bit-for-bit identical orbit in every browser.

代码 2 修正中点法与外推表(页面正在运行的源码)Listing 2 Modified midpoint method and the extrapolation table (the source this page is running, with its comments translated)

(a) 轨道。实线是本体,细虚线是初值差了 的孪生系统Orbits. Solid: the system itself; thin dashed: a twin whose initial state differs by

(b) 两条轨道在相空间里的距离Phase-space distance between the two orbits

(c) 能量的相对误差Relative energy error

图 2 平面三体问题。黑、蓝、红三种墨水各是一个天体,可以直接拖动它们换一组初值。(b) 把本体和孪生系统的间距画在对数坐标上:稳定的轨道在这里是一条缓缓抬升的曲线,混沌的轨道是一条直线,斜率就是李雅普诺夫指数。选“拉格朗日三角”时,红色虚线是式 (7) 的理论预言。(c) 是积分器自己的成绩单。Figure 2 The planar three-body problem. Black, blue and red ink are the three bodies; drag them to set new initial conditions. (b) plots the distance between the system and its twin on a logarithmic scale: a stable orbit appears as a slowly rising curve, a chaotic one as a straight line whose slope is the Lyapunov exponent. With Lagrange triangle selected, the red dashed line is the prediction of Eq. (7). (c) is the integrator's own report card.

图 2 的几组初值各有来历。8 字:三个等质量的天体在同一条 8 字形曲线上首尾相追,彼此只差三分之一个周期[7, 8]。数值研究表明它是线性稳定的[9],所以图 2(b) 里那条孪生轨道只会慢慢地、近似线性地错开。Each set of initial conditions in Figure 2 has a history. Figure-eight: three equal masses chase one another along a single eight-shaped curve, a third of a period apart[7, 8]. Numerical studies show it to be linearly stable[9], which is why the twin orbit in Figure 2(b) drifts away only slowly and roughly linearly.

拉格朗日三角:三个等质量的天体占据等边三角形的三个顶点,整体刚性旋转。这是一个精确解,但不稳定。在转动参考系里把运动方程线性化,本征值满足[10]Lagrange triangle: three equal masses sit at the vertices of an equilateral triangle that rotates rigidly. This is an exact solution, but an unstable one. Linearising the equations of motion in the rotating frame gives eigenvalues that satisfy[10]

(7)

等质量时 ,解出 :偏离以 增长,同时以角频率 振荡。在对数坐标的图 2(b) 上,这是一条斜率确定的直线,实测斜率与它相差不到万分之一。更有意思的是没加任何扰动的本体:它从完美的三角形出发,转上七圈多之后照样解体。种子只是双精度浮点数的舍入误差,量级 ,被这个指数一路放大了十六个量级。For equal masses and : a deviation grows as while oscillating at angular frequency . On the logarithmic axis of Figure 2(b) this is a straight line of known slope, and the measured slope agrees with it to better than one part in ten thousand. More interesting is the unperturbed system itself: it starts from a perfect triangle and still falls apart after a little more than seven revolutions. The only seed is the rounding error of double-precision arithmetic, of order , which this exponential amplifies by sixteen orders of magnitude.

毕达哥拉斯问题[11]:质量为 3、4、5 的三个天体,静止地放在一个 3-4-5 直角三角形的顶点上,每个天体正对着与自己同名的那条边。它们先后经历十几次近距离交会,最近的一次是质量 4 和 5 的两个天体,相距只有 (); 的最后一次三体交会之后,最轻的那个被甩出去,另外两个结成双星[12]。这组初值对误差极其敏感,表 1 用两种容差各算一遍来确认结果已经收敛。The Pythagorean problem[11]: bodies of mass 3, 4 and 5 start at rest at the vertices of a 3-4-5 right triangle, each opposite the side of the same length. They pass through more than a dozen close encounters; the closest is between masses 4 and 5, at a distance of only (). After the last triple encounter at the lightest body is thrown out and the other two form a binary[12]. These initial conditions are extremely sensitive to error, so Table 1 runs them at two tolerances to confirm that the result has converged.

其余四条(蝴蝶、飞蛾、阴阳、蜻蜓)取自 Šuvakov 与 Dmitrašinović 在 2013 年用数值搜索找到的周期轨道[13]。原文的初值只有五位小数,积分几圈就散了;这里的初值是我用高斯–牛顿法迭代过的,直到“积分一个周期后回到原处”的残差降到 以下。The other four (butterfly, moth, yin-yang, dragonfly) are periodic orbits found by Šuvakov and Dmitrašinović in a numerical search in 2013[13]. The published initial conditions have five decimal places and come apart after a few periods; the values used here were refined by Gauss–Newton iteration until the residual of returning to the start after one period fell below .

3流匹配:让噪声流成一幅画Flow matching: letting noise flow into a picture

生成模型要做的事,是把一个容易采样的分布(高斯噪声)变成数据的分布。流匹配[14, 15]的办法是学一个速度场 ,让噪声点以它为速度,即按 运动,从 流到 。训练时并不需要解这个常微分方程。随机取一个噪声点 、一个数据点 和一个时刻 ,把两点连成直线,要求网络在途中的那一点报出这条线的方向:A generative model has to turn a distribution that is easy to sample (Gaussian noise) into the distribution of the data. Flow matching[14, 15] does this by learning a velocity field and moving noise points with it, , from to . Training does not require solving this differential equation. Draw a noise point , a data point and a time at random, join the two points by a straight line, and ask the network to report the direction of that line at the point part-way along it:

(8)

同一个点 会出现在许多条连线上,网络能学到的只能是它们的平均方向 。而这个平均场,恰好就是把噪声分布搬成数据分布的那个场。对有限个数据点 ,它可以直接写出来,根本不必训练:The same point lies on many such lines, so all the network can learn is their average direction . That average field is exactly the one that carries the noise distribution onto the data distribution. For a finite set of data points it can be written down directly, with no training at all:

(9)

图 3 一开始放的就是式 (9)。仔细看会发现,每个粒子最后都精确地落在某一个数据点上:损失函数的最优解只会背诵训练集。点“训练网络”换成神经网络以后,落点才开始铺满数据点之间的空隙。网络是一个光滑的函数,背不下每一个点,学到的反而是形状。Figure 3 starts out playing Eq. (9). Look closely and every particle ends exactly on one of the data points: the optimum of the loss can only recite the training set. Click Train network to switch to a neural network, and the end points begin to fill the gaps between the data. A network is a smooth function; it cannot memorise every point, so what it learns is the shape.

(a) 

(b)  的五个瞬间Five snapshots at

训练步数training steps

(c) 训练损失Training loss

粒子落点到最近数据点的平均距离Mean distance from each particle's end point to the nearest data point
—
数据点到最近粒子的平均距离Mean distance from each data point to the nearest particle
—
图 3 二维的流匹配。选一个目标,或者选“自己画”后在 (a) 里随手画点什么;点“训练网络”,一个 12 034 个参数的全连接网络就在这个页面里用手写的反向传播和 Adam 开始训练,(a) 里的粒子每一轮都用最新的权重重新流一遍。把欧拉步数拖到 1 或 2,再切换两种配对方式各训练一次,可以直接看到“直的流”和“弯的流”的差别。Figure 3 Flow matching in two dimensions. Pick a target, or choose Draw your own and sketch something in (a). Click Train network and a fully connected network with 12,034 parameters starts training in this page, with hand-written backpropagation and Adam; the particles in (a) flow again each cycle with the latest weights. Drag the Euler steps down to 1 or 2 and train once with each pairing to see the difference between a straight flow and a curved one.

数据是单个高斯分布 时,一切都能算到底:When the data are a single Gaussian , everything can be worked out in full:

(10)

是数据的维数。损失的最小值不是零,因为连线的方向本来就有无法消除的随机性;它等于 这样一个干净的数,是把条件方差 对 积分的结果。这给了训练代码一个可以对答案的地方:表 1 里有一项检查把 代入后损失是否等于 ,另一项检查训练出来的网络离 有多远。Here is the dimension of the data. The minimum of the loss is not zero, because the direction of the connecting line carries randomness that cannot be removed; it equals the clean number , which is the conditional variance integrated over . This gives the training code something to be checked against: one row of Table 1 tests whether the loss with substituted equals , and another measures how far a trained network is from .

式 (8) 里的 与 是各自独立抽的,连线彼此交叉,平均出来的场是弯的,采样时必须走很多小步。如果在每个小批量里先把噪声点和数据点重新配对,使连线的总长度最短[16],连线几乎不再交叉,学到的流就接近直线。配对是一个指派问题,这里用匈牙利算法[17]求精确解。在螺旋线上各训练约四千步后比较:独立配对的网络用一步欧拉法采样,粒子全部挤在中心附近;最优传输配对的网络一步就已经看得出螺旋。In Eq. (8) and are drawn independently, the connecting lines cross one another, the averaged field is curved, and sampling needs many small steps. If the noise and data points in each minibatch are first re-paired so that the total length of the lines is as short as possible[16], the lines hardly cross and the learned flow is close to straight. The pairing is an assignment problem, solved exactly here with the Hungarian algorithm[17]. Compared on the spiral after about four thousand training steps each: sampled with a single Euler step, the network trained with independent pairing puts every particle near the centre, while the one trained with optimal-transport pairing already shows the spiral.

代码 3 一步训练:配对、插值、回归、反传(页面正在运行的源码)Listing 3 One training step: pairing, interpolation, regression, backpropagation (the source this page is running, with its comments translated)

4纠错码:涂掉一块还能读Error correction: readable with a patch painted out

二维码把数据切成字节,每个字节看作有限域 的一个元素:共 256 个,加法是按位异或,乘法是多项式相乘再对 取余。把 个数据字节当成多项式 的系数,在后面添上 个校验字节,使整个码字A QR code cuts its data into bytes and treats each byte as an element of the finite field : 256 elements, with bitwise XOR as addition and, as multiplication, the product of polynomials reduced modulo . Take data bytes as the coefficients of a polynomial and append check bytes so that the whole codeword

(11)

能被 整除,其中 是这个域的生成元。这就是 Reed–Solomon 码[18]。合法的码字在 这 个点上取值都是零;读回来的 如果有错,这 个值 就不全为零,而且只取决于错误本身,与原来的数据无关。译码就是从这 个数里反解出错在哪里、错成了什么。Berlekamp–Massey 算法[19]求出“错误定位多项式” ,它的根指出出错的位置 ;Forney 公式[20]再给出每个位置上的错误值:is divisible by , where generates the field. This is a Reed–Solomon code[18]. A valid codeword vanishes at the points ; if the received contains errors, the values are not all zero, and they depend only on the errors, not on the original data. Decoding means recovering from these numbers where the errors are and what they are. The Berlekamp–Massey algorithm[19] finds the error-locator polynomial , whose roots give the error positions ; Forney's formula[20] then gives the error value at each position:

(12)

个方程最多定出 个未知数。一个不知道位置的错误占两个未知数(位置和错误值),一个已知位置的“擦除”只占一个。所以 个错误加 个擦除能被纠正的条件是With equations, at most unknowns can be determined. An error at an unknown position costs two unknowns (its position and its value); an erasure, whose position is known, costs one. So errors and erasures can be corrected provided that

(13)

图 4 可以亲手验证这个不等式。二维码的四个纠错等级 L、M、Q、H 大约分别能恢复 7%、15%、25%、30% 的码字;数据多的时候码字还会被分成若干块交织着摆放,让一片污渍的损失摊到每一块头上。Figure 4 lets you test this inequality by hand. The four error-correction levels of a QR code, L, M, Q and H, can restore roughly 7%, 15%, 25% and 30% of the codewords; when there is a lot of data the codewords are also split into several blocks and interleaved, so that the damage from one stain is shared among all the blocks.

代码 4 Reed–Solomon 译码:伴随式、Berlekamp–Massey、Chien 搜索、Forney 公式(页面正在运行的源码)Listing 4 Reed–Solomon decoding: syndromes, Berlekamp–Massey, Chien search, Forney's formula (the source this page is running, with its comments translated)

(a) 扫描器看到的样子What a scanner sees

(b) 码字地图Codeword map

数据码字data校验码字check功能图形function patterns读错的码字misread

(c) 译码器逐块的结论The decoder's verdict, block by block

图 4 (a) 是一个真的二维码,手机可以直接扫。在 (a) 上涂抹把它弄坏,(b) 用红色标出因此读错的码字,(c) 是 Reed–Solomon 译码器逐块给出的结论:纠正了几个错误、离上限还有多远。涂到某一块超过上限为止,再勾上“把涂过的位置告诉译码器”:同样的损坏从“错误”变成“擦除”,按式 (13) 容量翻倍,译码多半又成功了。这里的译码器直接读模块矩阵,不做图像定位,所以涂掉三个角上的定位图形并不影响它,手机则会扫不出来。Figure 4 (a) is a real QR code that a phone can scan. Paint on (a) to damage it; (b) marks in red the codewords that are now misread, and (c) is the Reed–Solomon decoder's verdict for each block: how many errors it corrected and how far it is from the limit. Keep painting until one block goes over the limit, then tick Tell the decoder where you painted: the same damage turns from errors into erasures, the capacity doubles by Eq. (13), and decoding usually succeeds again. The decoder here reads the module matrix directly and does no image localisation, so painting out the three finder patterns in the corners does not affect it, although a phone will then fail to scan.

5自检Self-check

前面每一节里都有“应该等于多少”这样的话。表 1 把它们写成断言,在你打开页面时用正在运行的这份代码当场核对。对照的依据有三类:解析结果(偏折角的弱场与强场极限、阴影的角半径、失稳的增长率、损失的最小值);另一种独立的算法(椭圆积分对直接积分常微分方程、反向传播对数值差分、两种容差的结果互相对照);以及穷举(匈牙利算法对全部 5040 种配对)。Every section above contains statements of the form this should equal that. Table 1 turns them into assertions and checks them, when you open the page, against the very code that is running. The references are of three kinds: analytic results (the weak- and strong-field limits of the deflection angle, the angular radius of the shadow, the growth rate of the instability, the minimum of the loss); a second, independent algorithm (elliptic integrals against direct integration of the differential equation, backpropagation against finite differences, two tolerances against each other); and exhaustive enumeration (the Hungarian algorithm against all 5040 pairings).

它不是摆设。写这份文件的过程中,“守恒量”一项最初是不通过的:8 字轨道跑完 100 圈,能量只漂了不到 ,本该恒为零的角动量却漂到了 。原因出在式 (5) 上。三条边之和本应恒为零,这个约束在数学上自动成立,在浮点运算里却被舍入误差一点一点地破坏。改成“最长的那条边不积分,由另外两条相加得到”之后,角动量的误差回到了 。It is not there for show. While this file was being written, the Conserved quantities row failed at first: after 100 periods of the figure-eight the energy had drifted by less than , but the angular momentum, which should stay exactly zero, had drifted to . The cause lay in Eq. (5). The three edges should always sum to zero; mathematically the constraint holds automatically, but in floating-point arithmetic rounding errors erode it little by little. Once the longest edge was no longer integrated but obtained as the sum of the other two, the angular-momentum error returned to .

表 1Table 1 自检报告。Self-check report.

图Fig.断言Assertion怎么核对How it is checked期望Expected实测Measured结论Result

6没有做到的What this does not do

图 1 是史瓦西黑洞,不是带自转的克尔黑洞;盘是几何上无限薄、光学上不透明、各向同性发光的理想盘,没有算盘自己照亮自己。星空和盘面的纹理是程序生成的装饰,不是数据,纹理只是为了让转动看得见。图 2 只做了平面运动,也没有做碰撞正则化:两个天体贴到 以内时积分会停下来并注明,而不是硬算过去。图 3 的网络只有三个隐层,学二维分布绰绰有余,但画得太细的图案它会抹平。图 4 的编码器只用字节模式,译码器只读模块矩阵,不处理照片。表 1 核对的是算法,不是画面:图 1 的着色器与它的 JavaScript 版逐像素比较了光线的归宿,但色调映射、星空这些只影响观感的部分没有也无法对照什么标准答案。Figure 1 is a Schwarzschild black hole, not a rotating Kerr one; the disk is an idealised one, geometrically infinitely thin, optically thick and emitting isotropically, and its illumination of itself is not computed. The sky and the texture on the disk are procedural decoration, not data; the texture exists only to make the rotation visible. Figure 2 handles planar motion only and does no collision regularisation: when two bodies come within of each other the integration stops and says so, rather than forcing its way through. The network in Figure 3 has only three hidden layers, more than enough for a two-dimensional distribution, but it smooths over patterns drawn too finely. The encoder in Figure 4 uses byte mode only, and the decoder reads only the module matrix, not photographs. Table 1 checks the algorithms, not the picture: the shader of Figure 1 is compared pixel by pixel with its JavaScript counterpart on where each ray ends, but tone mapping, the star field and other things that affect only the look of the image have not been, and cannot be, compared with any reference answer.

参考文献References

  1. C. Darwin. The gravity field of a particle. Proceedings of the Royal Society A, 249: 180–194, 1959.
  2. V. Bozza. Gravitational lensing in the strong field limit. Physical Review D, 66: 103001, 2002.
  3. D. N. Page, K. S. Thorne. Disk-accretion onto a black hole. Time-averaged structure of accretion disk. The Astrophysical Journal, 191: 499–506, 1974.
  4. C. Wyman, P.-P. Sloan, P. Shirley. Simple analytic approximations to the CIE XYZ color matching functions. Journal of Computer Graphics Techniques, 2(2): 1–11, 2013.
  5. J.-P. Luminet. Image of a spherical black hole with thin accretion disk. Astronomy and Astrophysics, 75: 228–235, 1979.
  6. R. Bulirsch, J. Stoer. Numerical treatment of ordinary differential equations by extrapolation methods. Numerische Mathematik, 8: 1–13, 1966.
  7. C. Moore. Braids in classical dynamics. Physical Review Letters, 70: 3675–3679, 1993.
  8. A. Chenciner, R. Montgomery. A remarkable periodic solution of the three-body problem in the case of equal masses. Annals of Mathematics, 152: 881–901, 2000.
  9. C. Simó. Dynamical properties of the figure eight solution of the three-body problem. Contemporary Mathematics, 292: 209–228, 2002.
  10. E. J. Routh. On Laplace's three particles, with a supplement on the stability of steady motion. Proceedings of the London Mathematical Society, 6: 86–97, 1875.
  11. C. Burrau. Numerische Berechnung eines Spezialfalles des Dreikörperproblems. Astronomische Nachrichten, 195: 113–118, 1913.
  12. V. Szebehely, C. F. Peters. Complete solution of a general problem of three bodies. The Astronomical Journal, 72: 876–883, 1967.
  13. M. Šuvakov, V. Dmitrašinović. Three classes of Newtonian three-body planar periodic orbits. Physical Review Letters, 110: 114301, 2013.
  14. Y. Lipman, R. T. Q. Chen, H. Ben-Hamu, M. Nickel, M. Le. Flow matching for generative modeling. International Conference on Learning Representations, 2023.
  15. X. Liu, C. Gong, Q. Liu. Flow straight and fast: learning to generate and transfer data with rectified flow. International Conference on Learning Representations, 2023.
  16. A. Tong, K. Fatras, N. Malkin, G. Huguet, Y. Zhang, J. Rector-Brooks, G. Wolf, Y. Bengio. Improving and generalizing flow-based generative models with minibatch optimal transport. Transactions on Machine Learning Research, 2024.
  17. H. W. Kuhn. The Hungarian method for the assignment problem. Naval Research Logistics Quarterly, 2: 83–97, 1955.
  18. I. S. Reed, G. Solomon. Polynomial codes over certain finite fields. Journal of the Society for Industrial and Applied Mathematics, 8: 300–304, 1960.
  19. J. L. Massey. Shift-register synthesis and BCH decoding. IEEE Transactions on Information Theory, 15: 122–127, 1969.
  20. G. D. Forney. On decoding BCH codes. IEEE Transactions on Information Theory, 11: 549–557, 1965.