# 克莱姆法则

**克莱姆法则**是线性代数中的一个定理，它将方阵线性方程组解的每个分量表示为行列式之比：对于方程组 \( A\mathbf{x} = \mathbf{b} \)，其中 \( A \) 为 \( n \times n \) 非奇异矩阵，第 \( j \) 个未知量为

\[ x_j = \frac{\det(A_j)}{\det(A)}, \qquad j = 1, \ldots, n, \]

其中 \( A_j \) 是将 \( A \) 的第 \( j \) 列替换为 \( \mathbf{b} \) 后得到的矩阵<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup><sup> • </sup><sup>[2](https://mjo.osborne.economics.utoronto.ca/index.php/tutorial/index/1/eqs/t)</sup>。该法则由加布里埃尔·克莱姆（Gabriel Cramer，1704–1752）于1750年首次提出，每一门线性代数入门课程都会给出证明，但作为数值算法，它只适用于小型方程组，而且其浮点行为比人们熟悉的运算量异议所暗示的还要糟糕<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup><sup> • </sup><sup>[3](https://proofwiki.org/wiki/Cramer%27s_Rule/Historical_Note)</sup>。

| 关键事实 | 详情 |
|---|---|
| 陈述 | \( x_j = \det(A_j)/\det(A) \)，其中 \( A_j \) 与 \( A \) 相同，仅第 \( j \) 列被替换为 \( \mathbf{b} \)；要求 \( \det(A) \neq 0 \)<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup><sup> • </sup><sup>[2](https://mjo.osborne.economics.utoronto.ca/index.php/tutorial/index/1/eqs/t)</sup> |
| 首次发表 | 加布里埃尔·克莱姆，《代数曲线分析引论》（*Introduction à l'analyse des lignes courbes algébriques*）附录，日内瓦，1750年<sup>[3](https://proofwiki.org/wiki/Cramer%27s_Rule/Historical_Note)</sup><sup> • </sup><sup>[4](https://nonagon.org/ExLibris/gabriel-cramer-cramers-rule)</sup> |
| 余子式展开的运算量 | \( n+1 \) 个行列式，每个含 \( n! \) 项；当 \( n = 20 \) 时约为 \( 4.6 \times 10^{19} \) 次运算<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup> |
| 经LU分解的运算量 | \( n+1 \) 次分解对消元法的一次分解：当 \( n = 20 \) 时为112,000次对5,333次运算<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup> |
| 实测精度 | 在24位精度下对40,000个近乎平行的2×2方程组测试，克莱姆法则的最坏向后误差为458个舍入单位，而行交换消元法为1.3个<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup> |
| 零行列式 | 当 \( \det(A) = 0 \) 时法则无法应用，也无法区分无解方程组与无穷多解方程组；需要用到消元法<sup>[5](https://openstax.org/books/college-algebra-2e/pages/7-8-solving-systems-with-cramers-rule)</sup> |
| 实际适用范围 | 小型方程组（2×2、3×3）、精确或符号运算，以及经济学和线性代数中的推导<sup>[6](https://www.datacamp.com/tutorial/cramers-rule)</sup><sup> • </sup><sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup> |

## 陈述与适用范围

该法则适用于 \( n \) 个未知量、\( n \) 个线性方程且系数矩阵 \( A \) 非奇异的方程组，这等价于 \( \det(A) \neq 0 \)<sup>[7](https://archive.nptel.ac.in/content/storage2/courses/122104018/node30.html)</sup>。在这一唯一假设下，方程组有唯一解，法则分别给出每个分量<sup>[2](https://mjo.osborne.economics.utoronto.ca/index.php/tutorial/index/1/eqs/t)</sup>。对于3×3方程组，记 \( D \) 为系数矩阵的行列式，\( D_x, D_y, D_z \) 分别为将 \( x \)、\( y \)、\( z \) 列替换为常数列后形成的行列式，则解为 \( x = D_x/D \)，\( y = D_y/D \)，\( z = D_z/D \)<sup>[5](https://openstax.org/books/college-algebra-2e/pages/7-8-solving-systems-with-cramers-rule)</sup>。

当 \( \det(A) = 0 \) 时，法则对剩余两种情形中哪一种成立不作任何断言。行列式为零的方程组要么无解，要么有无穷多解，要区分二者需要对原方程组进行消元<sup>[5](https://openstax.org/books/college-algebra-2e/pages/7-8-solving-systems-with-cramers-rule)</sup><sup> • </sup><sup>[2](https://mjo.osborne.economics.utoronto.ca/index.php/tutorial/index/1/eqs/t)</sup>。

## 证明

标准证明通过逆矩阵进行。由于 \( A \) 非奇异，\( \mathbf{x} = A^{-1}\mathbf{b} \)，而 \( A^{-1} \) 的第 \( (i,j) \) 个元素为 \( (-1)^{i+j}|A_{ji}|/|A| \)，其中 \( A_{ji} \) 为删去第 \( j \) 行和第 \( i \) 列所得的余子式。将 \( \det(A_i) \) 沿其第 \( i \) 列（即 \( \mathbf{b} \)）展开，恰好得到和式 \( \sum_j (-1)^{i+j} b_j |A_{ji}| \)，因此 \( x_i = \det(A_i)/\det(A) \)<sup>[2](https://mjo.osborne.economics.utoronto.ca/index.php/tutorial/index/1/eqs/t)</sup>。一个等价的证明是将 \( A\mathbf{x} = \mathbf{b} \) 乘以伴随矩阵，并利用行列式对单列的线性性：\( \det(A \xleftarrow{k} \mathbf{b}) = x_k \det(A) \)，因为当 \( i = k \) 时将第 \( k \) 列替换为 \( \mathbf{a}_i \) 得到 \( \det(A) \)，否则得到0<sup>[8](https://courses.math.wichita.edu/math511/ch3/3/ApplicationsOfDeterminant.html)</sup>。

克莱姆本人陈述该法则时并未给出证明；证明是后来出现的<sup>[4](https://nonagon.org/ExLibris/gabriel-cramer-cramers-rule)</sup>。新的证明仍在不断涌现，包括2024年在arXiv上发表的一个组合证明<sup>[9](https://arxiv.org/abs/2408.10282)</sup>。

## 历史

加布里埃尔·克莱姆，日内瓦数学家，在一篇题为《未知量的消去》（*De l'évanouissement des inconnues*）的简短附录中提出了该法则，附录附于其《代数曲线分析引论》之后，该书于1750年由克莱姆兄弟出版社和克洛德·菲利贝尔（Cl. Philibert）在日内瓦出版<sup>[4](https://nonagon.org/ExLibris/gabriel-cramer-cramers-rule)</sup><sup> • </sup><sup>[10](https://www.e-rara.ch/zut/content/titleinfo/1233318)</sup>。该书正文680页，卷首部分11页，据MathWorld引用原书，该法则出现在第657–659页<sup>[10](https://www.e-rara.ch/zut/content/titleinfo/1233318)</sup><sup> • </sup><sup>[11](https://mathworld.wolfram.com/CramersRule.html)</sup>。通信记录显示克莱姆在此十年前就已开始撰写该论著，在1740年秋致让·雅拉贝尔（Jean Jallabert）的一封信中提到了“一篇关于曲线分析的小论文”（“petit traitté de l'Analyse des Courbes”）<sup>[12](https://smf.emath.fr/system/files/filepdf/RHM_25_2_Joffredo.pdf)</sup>。

## 计算成本

人们熟悉的异议是算术上的。一个 \( n \times n \) 方程组需要 \( n+1 \) 个行列式；用余子式展开计算，每个行列式有 \( n! \) 项，常被引用的说法是：用这种方法求解一个20×20方程组所需时间比宇宙年龄还长<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。这一异议并不完整，因为也没有人用余子式展开来计算行列式。若用LU分解计算每个行列式，克莱姆法则的代价是 \( n+1 \) 次分解，而消元法只需一次<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>：

| \( n \) | LU求解 | 经LU的克莱姆法则 | 经余子式的克莱姆法则 |
|---|---|---|---|
| 4 | 43 | 213 | 72 |
| 10 | 667 | 7,333 | \( 3.3 \times 10^{7} \) |
| 20 | 5,333 | 112,000 | \( 4.6 \times 10^{19} \) |

\( n+1 \) 的因子是一个糟糕的常数，但毕竟仍是常数，单凭这一点并不能在 \( n = 2 \) 时否定该法则——此时因子为3，整个计算只有六次运算<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。

## 数值稳定性

真正要紧的异议是稳定性。带行交换的高斯消元法是向后稳定的：计算解是邻近方程组 \( (A + \Delta A)\hat{\mathbf{x}} = \mathbf{b} + \Delta \mathbf{b} \) 的精确解，其中 \( \|\Delta A\| \) 是单位舍入误差乘以 \( \|A\| \) 的小倍数。克莱姆法则根本没有这种形式的界<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。

这一差距已被直接测量。在40,000个各行近乎平行的2×2方程组上，以24位二进制有效数字求值，最坏范数型向后误差 \( \eta(\hat{\mathbf{x}}) = \|\mathbf{b} - A\hat{\mathbf{x}}\| / (\|A\|\,\|\hat{\mathbf{x}}\| + \|\mathbf{b}\|) \) 对于行交换消元法为1.3个舍入单位，对于克莱姆法则为458个舍入单位。最坏情形的条件数为 \( 3.2 \times 10^{4} \)，是一个稍显棘手而非病态的矩阵，消元法将其解到1.3u<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。在双精度下，同样的比较显示克莱姆法则为391u，消元法为1.4u<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。

由于误差轴以格式自身的舍入为单位度量，这并非位数不够的问题。消元法在16、24、32、43和53位下都处于 \( u \) 的有界倍数，而克莱姆法则的尾部无论在何处测量都停留在数十到数百个 \( u \)；将尾数加倍，稳定方法多得八位正确数字，而不稳定方法多得的八位数字所对应的答案仍然不能求解任何邻近问题<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。其机制在于除以一个行列式，而该行列式的值来自大项之间的相消<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。2×2逆矩阵公式 \( A^{-1} = (1/\det A)\begin{bmatrix} a_{22} & -a_{12} \\ -a_{21} & a_{11} \end{bmatrix} \) 是同一算术的不同形式，继承了同样的缺陷，因为以此方式计算的 \( \mathbf{x} = A^{-1}\mathbf{b} \) 就是克莱姆法则<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。当 \( n = 3 \) 时，闭式解包含大约三倍之多的独立舍入，每个行列式有两次近似相等量之间的减法，所有实测指标都更差<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。

## 仍有应用之处

**小型与精确计算。** 该法则在几何内核中仍有生命力，用于线-线交点、重心坐标和三角形外心，这些都是2×2或3×3问题，其输入坐标往往是精确整数或定点数。即便输入精确，只要法则在有限精度算术中求值，稳定性论证就适用，因为除非精确进行，计算是不稳定的<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup><sup> • </sup><sup>[14](https://djvu.online/file/uGJmLc3c54Qe6)</sup>。在精确有理算术中，该法则完全没有误差，在区间算术中它产生一个包围区间；就成本而言它是糟糕的选择，就正确性而言它是可靠的选择<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。

**选择性求解。** 由于每个未知量独立计算，当只需要解中某些变量时，该法则特别有用：一个变量的值只需两个行列式，无论存在多少其他变量<sup>[2](https://mjo.osborne.economics.utoronto.ca/index.php/tutorial/index/1/eqs/t)</sup>。

**理论与经济学。** 作为公式而非算法，该法则是伴随矩阵、矩阵逆的闭式解以及行列式导数的基础<sup>[1](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)</sup>。在比较静态分析中，经济学家用它求解均衡的一阶条件微分后各内生变量的响应，因为共同的分母意味着比较静态导数的符号往往可以仅从分子读出<sup>[13](https://eclass.aueb.gr/modules/document/file.php/DEOS422/%CE%92%CE%B9%CE%B2%CE%BB%CE%B9%CE%BF%CE%B3%CF%81%CE%B1%CF%86%CE%AF%CE%B1/Textbooks/Walter%20Nicholson_%20Christopher%20M.%20Snyder%20-%20Microeconomic%20Theory_%20Basic%20Principles%20and%20Extensions-Cengage%20Learning%20%282016%29.pdf)</sup>。对于大于约3×3的方程组，数值实践中使用 \( O(n^{3}) \) 代价的部分主元高斯消元法、对同一矩阵多个右端项的LU分解，或对病态方程组的QR分解<sup>[6](https://www.datacamp.com/tutorial/cramers-rule)</sup>。

## References

1. [A rule that is correct and unusable, Numerical Linear Algebra](https://www.numerical-linear-algebra.com/essays/a-rule-that-is-correct-and-unusable/)
2. [Mathematical methods for economic theory: 1.3 Solving systems of linear equations, M. J. Osborne, University of Toronto](https://mjo.osborne.economics.utoronto.ca/index.php/tutorial/index/1/eqs/t)
3. [Cramer's Rule/Historical Note, ProofWiki](https://proofwiki.org/wiki/Cramer%27s_Rule/Historical_Note)
4. [Gabriel Cramer on Cramer's Rule, Ex Libris](https://nonagon.org/ExLibris/gabriel-cramer-cramers-rule)
5. [7.8 Solving Systems with Cramer's Rule, College Algebra 2e, OpenStax](https://openstax.org/books/college-algebra-2e/pages/7-8-solving-systems-with-cramers-rule)
6. [Cramer's Rule: A Direct Method for Solving Linear Systems, DataCamp](https://www.datacamp.com/tutorial/cramers-rule)
7. [Cramer's Rule, NPTEL course notes](https://archive.nptel.ac.in/content/storage2/courses/122104018/node30.html)
8. [Applications of Determinants, Wichita State University course notes](https://courses.math.wichita.edu/math511/ch3/3/ApplicationsOfDeterminant.html)
9. [A combinatorial proof of Cramer's Rule, arXiv:2408.10282](https://arxiv.org/abs/2408.10282)
10. [Introduction à l'analyse des lignes courbes algébriques, ETH-Bibliothek Zürich, Rar 4992](https://www.e-rara.ch/zut/content/titleinfo/1233318)
11. [Cramer's Rule, Wolfram MathWorld](https://mathworld.wolfram.com/CramersRule.html)
12. [Genèse de l'analyse des courbes de Gabriel Cramer, Revue d'histoire des mathématiques](https://smf.emath.fr/system/files/filepdf/RHM_25_2_Joffredo.pdf)
13. [Mathematics for Microeconomics, Nicholson and Snyder, Microeconomic Theory (2016)](https://eclass.aueb.gr/modules/document/file.php/DEOS422/%CE%92%CE%B9%CE%B2%CE%BB%CE%B9%CE%BF%CE%B3%CF%81%CE%B1%CF%86%CE%AF%CE%B1/Textbooks/Walter%20Nicholson_%20Christopher%20M.%20Snyder%20-%20Microeconomic%20Theory_%20Basic%20Principles%20and%20Extensions-Cengage%20Learning%20%282016%29.pdf)
14. [djvu.online](https://djvu.online/file/uGJmLc3c54Qe6)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数与代数 › Linear and multilinear algebra › Matrix theory › Determinants and minors

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/cramers-rule

English original: https://www.edgepedia.org/cramers-rule
