📚 Gaussian Elimination for Matrix Inversion | 高斯消元法求逆矩阵的原理
Matrix inversion is a fundamental operation in linear algebra. For a square matrix A, its inverse A⁻¹ satisfies the equation AA⁻¹ = A⁻¹A = I, where I is the identity matrix of the same dimension. Gaussian elimination provides a systematic and efficient way to compute this inverse by performing a sequence of row operations on the augmented matrix [A | I].
矩阵求逆是线性代数中的基本运算。对于方阵 A,其逆矩阵 A⁻¹ 满足方程 AA⁻¹ = A⁻¹A = I,其中 I 是与 A 同阶的单位矩阵。高斯消元法通过对增广矩阵 [A | I] 执行一系列行变换,提供了一种系统且高效的计算逆矩阵的方法。
1. What is an Inverse Matrix? | 什么是逆矩阵?
An inverse matrix A⁻¹ exists only when A is square and its determinant is nonzero: det(A) ≠ 0. Such a matrix is called invertible or nonsingular. If det(A) = 0, the matrix is singular and has no inverse.
逆矩阵 A⁻¹ 存在的条件是:A 是方阵且其行列式不为零,即 det(A) ≠ 0。这样的矩阵称为可逆矩阵或非奇异矩阵。如果 det(A) = 0,则该矩阵为奇异矩阵,不存在逆矩阵。
Geometrically, multiplying by A performs a linear transformation; A⁻¹ reverses that transformation. For example, if A represents a rotation by 30°, then A⁻¹ represents a rotation by -30°. Finding the inverse is equivalent to finding the transformation that undoes the original one.
从几何角度看,乘以 A 表示执行一个线性变换,而 A⁻¹ 则逆转该变换。例如,若 A 表示旋转 30°,则 A⁻¹ 表示旋转 -30°。因此,求逆矩阵等价于寻找能够抵消原变换的逆变换。
2. Core Idea of Gaussian Elimination for Inversion | 高斯消元法求逆的核心思想
The key insight is to place A and the identity matrix I side by side, forming the augmented matrix [A | I]. If we apply a sequence of elementary row operations to the left block A that transforms it into I, then the same operations applied to the right block I will turn it into A⁻¹.
核心思想是将 A 与单位矩阵 I 并排放在一起,构成增广矩阵 [A | I]。如果我们对左块 A 施加一系列初等行变换,将其化为单位矩阵 I,那么对右块 I 施加同样的变换,它就会变为 A⁻¹。
Why does this work? Each elementary row operation is equivalent to multiplying the matrix on the left by an elementary matrix E. If the product of these elementary matrices reduces A to I, then that product itself must be exactly A⁻¹, because Eₖ…E₂E₁A = I implies Eₖ…E₂E₁ = A⁻¹. The right block I, multiplied by the same product, becomes that very inverse.
为什么这样可行?每一次初等行变换都等价于在矩阵左侧乘以一个初等矩阵 E。若这些初等矩阵的乘积能把 A 化为 I,那么该乘积本身就是 A⁻¹,因为 Eₖ…E₂E₁A = I 意味着 Eₖ…E₂E₁ = A⁻¹。右块 I 被同样的乘积作用后,自然就变成了这个逆矩阵。
3. Constructing the Augmented Matrix | 构造增广矩阵
Suppose A is an n × n matrix. To begin, write A in the left half and I in the right half, separated by a vertical line. This augmented matrix has n rows and 2n columns.
假设 A 是 n × n 矩阵。首先,将 A 写在左半部分,I 写在右半部分,中间用竖线隔开。这个增广矩阵共有 n 行和 2n 列。
For a 2 × 2 matrix, for example, the augmented matrix has the form:
例如,对于 2 × 2 矩阵,增广矩阵的形式为:
[ a₁₁ a₁₂ | 1 0 ]
[ a₂₁ a₂₂ | 0 1 ]
The vertical bar is not a mathematical operation; it is only a visual helper to remind us which block is A and which block is I. Every row operation must be applied to the entire row, including both sides of the bar.
竖线并不是数学运算符号,而只是一个视觉辅助,提醒我们哪个块是 A,哪个块是 I。每一次行变换都必须作用于整行,包括竖线两侧的所有元素。
4. Elementary Row Operations | 初等行变换
Gaussian elimination relies on three types of elementary row operations. They are reversible, and they preserve the solution set of any linear system represented by the matrix.
高斯消元法依赖于三种初等行变换。它们都是可逆的,并且保持矩阵所表示的线性方程组的解集不变。
The first operation is row swapping: Rᵢ ↔ Rⱼ. This exchanges two rows of the augmented matrix.
第一种操作是行交换:Rᵢ ↔ Rⱼ,即交换增广矩阵的两行。
The second operation is scalar multiplication: Rᵢ ← cRᵢ, where c ≠ 0. This multiplies every entry in row i by the nonzero constant c.
第二种操作是数乘:Rᵢ ← cRᵢ,其中 c ≠ 0。即将第 i 行的每个元素都乘以非零常数 c。
The third operation is row addition: Rᵢ ← Rᵢ + cRⱼ. This adds a multiple of row j to row i, leaving row j unchanged. This is the most frequently used operation in elimination.
第三种操作是行相加:Rᵢ ← Rᵢ + cRⱼ,即将第 j 行的若干倍加到第 i 行,而第 j 行保持不变。这是消元过程中最常用的操作。
5. Why Row Operations Work: Elementary Matrices | 行变换为什么有效:初等矩阵
Each elementary row operation on an n × m matrix can be realized by left-multiplying that matrix by a suitable n × n elementary matrix E. For example, swapping rows 1 and 2 of a 2 × 2 matrix corresponds to multiplying on the left by [0 1; 1 0].
对 n × m 矩阵进行的每一种初等行变换,都可以通过左乘一个适当的 n × n 初等矩阵 E 来实现。例如,交换一个 2 × 2 矩阵的第 1 行和第 2 行,等价于在左侧乘以 [0 1; 1 0]。
Suppose we apply elementary matrices E₁, E₂, …, Eₖ in that order to A to obtain I. Then Eₖ…E₂E₁A = I. Multiplying both sides on the right by A⁻¹ gives Eₖ…E₂E₁ = A⁻¹. Thus the combined effect of all row operations is precisely the matrix inverse.
假设我们按顺序对 A 施加初等矩阵 E₁, E₂, …, Eₖ,最终得到 I。于是 Eₖ…E₂E₁A = I。等式两边同时右乘 A⁻¹,得到 Eₖ…E₂E₁ = A⁻¹。因此,所有这些行变换的合效果恰好就是逆矩阵。
Since the same row operations are applied to the identity matrix on the right, the right block becomes Eₖ…E₂E₁I = Eₖ…E₂E₁ = A⁻¹. This mathematical identity is the theoretical foundation of the algorithm.
由于同样的行变换也作用于右侧的单位矩阵,右侧块就变成了 Eₖ…E₂E₁I = Eₖ…E₂E₁ = A⁻¹。这一数学恒等式正是该算法的理论基础。
6. The Reduction Procedure | 化简步骤
The algorithm proceeds column by column from left to right, aiming to transform the left block into the identity matrix. This is often called Gauss-Jordan elimination when we continue until the left block is fully reduced to I.
算法从左到右逐列进行,目标是将左块化为单位矩阵。若一直进行到左块完全变为 I,这一过程通常称为 Gauss-Jordan 消元法。
For each column j, first select a nonzero pivot in the current row (or swap rows to bring a nonzero entry into that position). Then scale the pivot row so that the pivot entry becomes 1. Next, use that row to eliminate all other entries in the column, both below and above the pivot.
对于每一列 j,首先在当前行选择一个非零主元(必要时通过交换行,将非零元素移到主元位置)。然后缩放主元行,使主元变为 1。接着,利用该行消去该列中主元上方和下方的所有其他元素。
This process is repeated for every column until the left block becomes I. The right block at this final stage is the desired inverse matrix A⁻¹.
对每一列重复此过程,直到左块变成 I。此时右块就是所求的逆矩阵 A⁻¹。
7. Worked Example: Inverting a 2 × 2 Matrix | 具体例子:求 2 × 2 矩阵的逆
Let A = [1 2; 3 7] (here a semicolon marks a new row). We form the augmented matrix:
设 A = [1 2; 3 7](这里分号表示换行)。我们构造增广矩阵:
[ 1 2 | 1 0 ]
[ 3 7 | 0 1 ]
Step 1: The first pivot is already 1, so no scaling is needed. Eliminate the entry below it using R₂ ← R₂ − 3R₁:
步骤 1:第一个主元已经是 1,因此无需缩放。用 R₂ ← R₂ − 3R₁ 消去其下方的元素:
[ 1 2 | 1 0 ]
[ 0 1 | −3 1 ]
Step 2: The second pivot is now 1. Eliminate the entry above it using R₁ ← R₁ − 2R₂:
步骤 2:第二个主元现在是 1。用 R₁ ← R₁ − 2R₂ 消去其上方的元素:
[ 1 0 | 7 −2 ]
[ 0 1 | −3 1 ]
The left block is now I, so the right block is A⁻¹. Therefore:
此时左块已变成 I,因此右块就是 A⁻¹。所以:
A⁻¹ = [ 7 −2 ; −3 1 ]
We can verify: A × A⁻¹ = [1 2; 3 7] × [7 −2; −3 1] = [1 0; 0 1]. The result is correct.
我们可以验证:A × A⁻¹ = [1 2; 3 7] × [7 −2; −3 1] = [1 0; 0 1]。结果正确。
8. Determining Invertibility | 判断矩阵是否可逆
During the elimination process, if at some stage an entire row in the left block becomes all zeros, then A is singular and has no inverse. This is because a zero row in the reduced matrix implies that the rows of A are linearly dependent, hence det(A) = 0.
在消元过程中,如果某一阶段左块出现一整行全为零,则 A 是奇异矩阵,不存在逆矩阵。这是因为化简后的矩阵中出现零行意味着 A 的行向量线性相关,从而 det(A) = 0。
For example, consider A = [1 2; 2 4]. The augmented matrix [1 2 | 1 0; 2 4 | 0 1] becomes, after R₂ ← R₂ − 2R₁, [1 2 | 1 0; 0 0 | −2 1]. The zero row on the left shows that no inverse exists.
例如,考虑 A = [1 2; 2 4]。增广矩阵 [1 2 | 1 0; 2 4 | 0 1] 在 R₂ ← R₂ − 2R₁ 后变成 [1 2 | 1 0; 0 0 | −2 1]。左侧出现零行,说明该矩阵不可逆。
Thus Gaussian elimination not only computes the inverse when it exists, but also detects singularity automatically. No separate determinant calculation is needed beforehand.
因此,高斯消元法不仅能在可逆时计算出逆矩阵,还能自动判断矩阵是否奇异。无需事先单独计算行列式。
9. Comparison with the Adjugate Method | 与伴随矩阵法的比较
The adjugate method computes the inverse via A⁻¹ = adj(A) / det(A), where adj(A) is the transpose of the cofactor matrix. For 2 × 2 matrices, this formula is compact and easy to memorize.
伴随矩阵法通过公式 A⁻¹ = adj(A) / det(A) 计算逆矩阵,其中 adj(A) 是代数余子式矩阵的转置。对于 2 × 2 矩阵,这个公式简洁且容易记忆。
However, for larger matrices, the adjugate method requires computing many cofactors, making it extremely tedious. Gaussian elimination requires fewer arithmetic operations and follows a uniform algorithmic pattern that is easier to implement by hand or by computer.
然而,对于更大的矩阵,伴随矩阵法需要计算大量的代数余子式,非常繁琐。高斯消元法的算术运算量更少,而且遵循统一的算法流程,便于手工计算或编程实现。
In advanced applications, Gaussian elimination is preferred because its computational complexity is O(n³), whereas the adjugate method via cofactor expansion has complexity O(n!) if done naively.
在高级应用中,高斯消元法更受青睐,因为其计算复杂度为 O(n³),而通过代数余子式展开实现的伴随矩阵法的朴素复杂度为 O(n!)。
10. Application to Solving Multiple Linear Systems | 在求解多个线性方程组中的应用
Once A⁻¹ is known, any linear system Ax = b can be solved immediately by x = A⁻¹b. This is especially useful when the same coefficient matrix A appears in several systems with different right-hand side vectors b₁, b₂, ….
一旦求出 A⁻¹,任何线性方程组 Ax = b 都可以立即通过 x = A⁻¹b 求解。当同一个系数矩阵 A 出现在多个具有不同右端向量 b₁, b₂, … 的方程组中时,这一方法尤其有用。
In many textbooks, Gaussian elimination is used to solve several systems simultaneously by augmenting A with multiple right-hand side columns, not just the identity matrix. The inverse itself is just a special case where the right-hand columns are the standard basis vectors.
许多教材中,高斯消元法通过将 A 与多个右端列(而不仅仅是单位矩阵)同时增广来一次性求解多个方程组。求逆矩阵本身只是其中一个特例,此时右端列恰好是标准基向量。
For example, solving AX = B, where X and B are matrices, can be done by forming [A | B] and reducing A to I. The resulting right block is X = A⁻¹B. This general viewpoint unifies inversion and system solving.
例如,求解矩阵方程 AX = B(其中 X 和 B 都是矩阵),可以通过构造 [A | B] 并将 A 化为 I 来完成。此时右块就是 X = A⁻¹B。这种一般性观点将求逆与解方程组统一起来。
11. Complexity and Numerical Stability | 计算复杂度与数值稳定性
For an n × n matrix, Gaussian elimination requires roughly (2/3)n³ multiplications and additions for the forward and backward elimination stages. Memory usage is O(n²) to store the augmented matrix.
对于 n × n 矩阵,高斯消元法在前向消元和后向代入阶段大约需要 (2/3)n³ 次乘法和加法。内存使用量为 O(n²),用于存储增广矩阵。
In numerical computation, the order of row operations matters. To reduce rounding errors, a technique called partial pivoting is often used: before eliminating a column, the row with the largest absolute value in that column is swapped into the pivot position. This improves numerical stability but does not change the mathematical result.
在数值计算中,行操作的顺序很重要。为了减少舍入误差,通常采用部分主元法:在消去某列之前,将该列中绝对值最大的行交换到主元位置。这提高了数值稳定性,但不改变数学结果。
When dealing with fractions, exact rational arithmetic can be used to avoid floating-point errors, but it may be slower. For hand calculation, it is important to carefully organize the steps to avoid simple mistakes.
当涉及分数时,可以使用精确有理数运算来避免浮点误差,但速度可能较慢。对于手工计算,仔细组织步骤以避免简单错误非常重要。
12. Common Mistakes and Tips | 常见错误与建议
One common mistake is applying a row operation only to the left block while leaving the right block unchanged. Every elementary row operation must be applied to the entire row of the augmented matrix, including entries on both sides of the vertical bar.
一个常见错误是只对左块进行行变换,而右块保持不变。每一次初等行变换都必须应用于增广矩阵的整行,包括竖线两侧的所有元素。
Another mistake is using column operations. Gaussian elimination for matrix inversion only permits elementary row operations. Column operations correspond to multiplying on the right, which would not preserve the desired inverse relationship.
另一个错误是使用列变换。求逆矩阵的高斯消元法只允许初等行变换。列变换相当于在右侧相乘,这会破坏所要求的逆矩阵关系。
Finally, always check your result. Multiply the original A by the computed A⁻¹ to confirm that the product is the identity matrix. This simple verification can catch many errors before you submit your final answer.
最后,务必检查结果。将原始矩阵 A 与计算得到的 A⁻¹ 相乘,确认乘积是单位矩阵。这一简单的验证可以帮助你在提交最终答案前发现许多错误。
Published by TutorHao | IB Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply