综合为何比分析更难:从微积分的局部与全局谈起
本文从微积分的一个经典观察出发——求导(局部操作)远比求积分(全局操作)容易——引申出软件工程中“分析”与“综合”的根本性差异。作者指出,求导只需知道函数在一点附近的行为,而求积分必须掌握整个区间上的信息,这恰如分析型问题(如拆解、封装、分离关注点)与综合型问题(如理解分布式系统中各组件的交互)之间的对立。对于SRE而言,事故响应往往要求综合能力——将分散的组件行为拼合成系统整体图景。但业界尚未将“综合能力建设”提升为一等公民的工作,因为它高度依赖于具体系统和组织细节。作者呼吁更多关注如何系统性地学习系统的运行细节。
Over the years, mathematicians, logicians and computer scientists have developed various calculi. If you have a background in computer science, you’ve likely heard of the lambda calculus, a model of computation that was developed by Alonzo Church. If databases are more your thing, then you’ve been exposed to the relational calculus without even knowing it, since SQL is based on the relational calculus. If you are into formal methods, then you’ve worked with the predicate calculus, better known as first-order logic. Finally, if you enjoy reading academic papers on programming languages, you’ve almost certainly run into the sequent calculus. However, when someone says “calculus” without modification (e.g., “I’m taking calculus next semester”), there’s no ambiguity about which calculus they are referring to: it’s always one particular calculus. Or, rather, two calculi that happen to be deeply related to each other: differential calculus and integral calculus.
多年来,数学家、逻辑学家和计算机科学家发展出多种演算。如果你有计算机科学背景,很可能听过 Alonzo Church 提出的 λ 演算;如果数据库是你的领域,那么你已在不自觉中接触过关系演算——因为 SQL 正是基于它;如果你研究形式化方法,则一定使用过谓词演算(即一阶逻辑);而如果你喜欢阅读编程语言的学术论文,则几乎肯定会碰到 sequent 演算。然而,当有人不加修饰词地说“calculus”(比如“下学期我要上微积分课”)时,所指的演算毫无歧义:永远是那一个特定的演算,更准确地说,是彼此深度关联的两个演算——微分学和积分学。
Visually, you can think of differential calculus as being about calculating the slope of a function at a given point. For example, consider this graph:
You might ask, “how quickly is this curve changing when x=6?” In other words, what is the slope of this function right in a neighborhood very close to x=6?
Differential calculus enables you to compute the slope of a function at a given point
直观来看,微分学是关于计算函数在给定点的斜率。例如,考虑下面这张图:

你可能会问:“当 x=6 时,这条曲线的变化率有多快?”也就是说,在 x=6 附近的一个微小邻域内,该函数的斜率是多少?

微分学让你能够计算函数在给定点的斜率。
Integral calculus, on the other hand, is about the area under the graph over a particular interval. For example, you might ask “what is the area under this curve between x=2 and x=7?
Integral calculus enables you to compute the area under a function over a given interval
而积分学关注的是函数图像在某个区间下方的面积。例如,你可能会问:“x=2 到 x=7 之间,这条曲线下的面积是多少?”

积分学让你能够计算函数在给定区间下方与横轴围成的面积。
If you study calculus, you’ll first be taught differential calculus (sometimes referred to “Calculus 1” or “Cal 1”) and then you’ll be taught integral calculus (“Cal 2”). When you study differential calculus, you learn the rules for calculating the derivative (slope-at-a-point) of a function. And it turns out that it’s quite straightforward to calculate a derivative, no matter what type of function it is. It’s just an algorithm, which means you can easily program a computer to compute derivatives if you wanted to. (As an aside, automatically computing derivatives is a fundamental element in the process of training LLMs. If you’re curious, look up automatic differentiation). And then, you get to Cal 2, and you learn about how to compute an integral (area-under-a-curve). You will soon discover that, unlike in Cal 1, there is no algorithm for computing the integral of an arbitrary function. Instead, what you learn is a bag of tricks on how to compute integrals for different kinds of functions. You also learn that for some functions, there’s no closed-form solution at all for the integral!
在微积分的学习中,你首先接触的是微分学(有时称为“微积分 I”或“Cal 1”),然后才是积分学(“Cal 2”)。学习微分学时,你掌握了计算导数(某点斜率)的规则。事实证明,无论函数是什么类型,求导都非常直接——它只是一个算法而已,意味着你甚至可以轻松地编写程序让计算机自动求导(顺便一提,自动求导是训练大型语言模型的核心环节之一,感兴趣的话可以查阅“自动微分”)。
到了 Cal 2,你开始学习如何计算积分(曲线下的面积)。很快你就会发现,这与 Cal 1 截然不同:对任意函数,根本不存在通用的积分算法。你学到的只是一套针对不同类型函数的“锦囊妙计”。更棘手的是,有些函数的积分甚至根本没有闭式解!
As an example, consider the Gaussian function, which shows up in the normal distribution. With zero mean and unit variance, it looks like this: 12πe−x22\frac{1}{\sqrt{2\pi}} e^{-\frac{x^2}{2}}
The infamous bell curve Asking students to compute the derivative of this function would be a perfectly reasonable question on a Cal 1 final exam, the answer looks like this: −x2πe−x22-\frac{x}{\sqrt{2\pi}}e^{-\frac{x^2}{2}} But asking students to compute the integral of this function on a Cal 2 final exam would be unfair, because it’s not possible to do with the techniques they learned in class (at least, I didn’t learn the technique you’d need until Cal 3). Because the integral doesn’t have a closed-form solution, you need to express the solution as an infinite series, like: 12π∑n=0∞(−1)n2nn!(2n+1)x2n+1=12π(x−x36+x540−x7336+x93456−⋯)\frac{1}{\sqrt{2\pi}} \sum_{n=0}^{\infty} \frac{(-1)^n }{2^n n!(2n+1)}x^{2n+1} = \frac{1}{\sqrt{2\pi}} \left( x-\frac{x^3}{6}+\frac{x^5}{40}-\frac{x^7}{336}+\frac{x^9}{3456}-\cdots \right) (Note: I asked AI for the integral of the Gaussian, I hope it got it right!)
以正态分布中的高斯函数为例。当均值为零、方差为 1 时,它的表达式为:
$$\frac{1}{\sqrt{2\pi}} e^{-\frac{x^2}{2}}$$

这就是那条著名的钟形曲线。在 Cal 1 的期末考中,让学生求该函数的导数非常合理,答案如下:
$$-\frac{x}{\sqrt{2\pi}}e^{-\frac{x^2}{2}}$$
但在 Cal 2 的期末考中让学生计算该函数的积分则绝不合理,因为仅凭课堂上学过的技巧根本无法完成(至少我本人直到 Cal 3 才学到所需的方法)。由于该积分没有闭式解,必须用无穷级数来表示:
$$\frac{1}{\sqrt{2\pi}} \sum_{n=0}^{\infty} \frac{(-1)^n }{2^n n!(2n+1)}x^{2n+1} = \frac{1}{\sqrt{2\pi}} \left( x-\frac{x^3}{6}+\frac{x^5}{40}-\frac{x^7}{336}+\frac{x^9}{3456}-\cdots \right)$$
(注:我请 AI 提供了高斯函数的积分,但愿它没算错!)
It’s not obvious (at least, not to me) that differential calculus and integral calculus are related to each other. However, it turns out that these two calculi are opposite sides of the same coin, because integrals are anti-derivatives. That is, if f(x) is the derivative of F(x), then F(x) is the integral of f(x). This result is known as the Fundamental Theorem of Calculus.
微分学与积分学之间的关系并不显而易见(至少对我而言如此)。然而,事实是这两个分支是同一枚硬币的正反两面——因为积分就是反导数。也就是说,如果 f(x) 是 F(x) 的导数,那么 F(x) 就是 f(x) 的积分。这一结论被称为“微积分基本定理”。
This connection between differential and integral calculus raises an almost philosophical question: why is it so much easier to compute a derivative than it is to compute an integral? Back in 2011, somebody asked about this on the Mathematics Stack Exchange: Why is integration so much harder than differentiation? The top-voted answer was written by Qiaochu Yuan, and here’s the heart of it (emphasis mine): Differentiation is a “local” operation: to compute the derivative of a function at a point you only have to know how it behaves in a neighborhood of that point. But integration is a “global” operation: to compute the definite integral of a function in an interval you have to know how it behaves on the entire interval (and to compute the indefinite integral you have to know how it behaves on all intervals). That is a lot of information to summarize. Generally, local things are much easier than global things.
微分与积分之间的这种联系引出了一个近乎哲学的问题:为什么求导比积分容易这么多?早在 2011 年,就有人在 Mathematics Stack Exchange 上提出了这个问题:“为什么积分比微分难这么多?”得票最高的答案来自 Qiaochu Yuan,其核心如下(着重号为我所加):
微分是一种“局部”操作:要计算一个函数在某点的导数,只需知道该点邻域内的行为即可。而积分是一种“全局”操作:要计算一个函数在某个区间内的定积分,必须了解它在该整个区间上的行为(而计算不定积分则需知道它在所有区间上的行为)。这需要汇总大量信息。一般来说,局部事物比全局事物容易得多。
In one sense, local things are easier than global things is a banal statement. Everybody knows that, for example, local optimization is much easier than global optimization. But it’s also a very deep one. And it gets at the title of this post, which is synthesis is harder than analysis. I previously wrote about the difference between analysis and synthesis in the demon of the gaps. In analysis, we’re breaking a larger problem into smaller problems that separate out cleanly. These smaller problems are more localized, and hence easier to solve. This is why we advocate for principles like encapsulation and separation of concerns, to ensure our smaller problems are local. The work of synthesis involves integrating(!) multiple things together. This pushes in the other direction: we are creating a problem that is less local. And global things are much harder than local things. The challenge we face is that some kinds of problems are just inherently synthesis problems. As I wrote in that previous post, incident response is one area where we are frequently confronted with synthesis problems: we have to understand how the pieces normally fit together in order to make sense of what is currently going wrong.
从某种意义上说,“局部事物比全局事物容易”是一句平庸的话,谁都知道局部优化比全局优化容易得多。但它同时也非常深刻,并且直接指向了本文的标题:综合比分析更难。
我在之前的文章《the demon of the gaps》中曾讨论过分析与综合的区别。分析是将一个大问题拆解成多个可清晰分离的小问题,这些小问题更局部、因此更容易解决。这正是我们倡导诸如封装和关注点分离等原则的原因——它们确保小问题是局部的。
而综合则恰恰相反:它需要将多个要素整合在一起,这创造了一个不那么局部的问题。而全局问题比局部问题困难得多。我们面临的挑战在于,某些类型的问题本身就是综合问题。正如我在上一篇文章中所写,事故响应就是一个频繁面对综合问题的领域:我们必须理解各部分正常是如何组合的,才能搞清当前究竟出了什么问题。
That’s why I think that this sort of synthesis work is important for SREs. Now, because synthesis is harder than analysis, and because SREs don’t have super-human cognitive abilities, it means that there is a limit to how deeply they will be able to understand any given component in the system. But the more they understand how the different components interact, the better positioned they are for helping resolve the tougher incidents. Unfortunately, in our industry we haven’t recognized building up synthesis expertise as a first-class thing. That’s understandable because this work is very situated, it depends on the messy details of the particular system in the organization that an SRE works in. On the other hand, we can get better at learning how to learn about the operational details of a system. And that’s what I’d like to see more of.
正因如此,我认为这类综合工作对 SRE(站点可靠性工程师)至关重要。由于综合比分析更难,而 SRE 并没有超人的认知能力,这意味着他们对任何给定组件的理解深度是有限的。然而,他们对不同组件之间如何交互的理解越深,就越有能力帮助解决最棘手的事故。
遗憾的是,在我们的行业中,培养综合能力尚未被视为头等要务。这也可以理解,因为这项工作具有很强的场景依赖性——它取决于 SRE 所在组织的特定系统的繁杂细节。但另一方面,我们可以更好地学习“如何学习”一个系统的运维细节。而这正是我希望看到的更多进展。