线性代数之——消元法

本文详细介绍了如何使用消元法解决线性方程组,包括基本的消元思想、消元过程中的主元概念、消元的失效情况,以及如何处理三个未知数的复杂方程组。此外,还探讨了消元法在矩阵形式下的应用,展示了如何通过初等矩阵进行消元。
1. 消元的思想

针对下面的方程,我们无法直接得到方程的解。

x − 2y = 13x + 2y = 11\begin{alignedat}{2} &x \space- \space&2&y \space=\space 1 \\ 3&x\space+\space&2&y \space=\space 11 \end{alignedat}3x  x + 22y = 1y = 11

但如果我们将第二个方程减去第一个方程的 3 倍,上面的方程组就变成了下面这样。

x − 2y = 1  8y = 8 \begin{alignedat}{2} &x \space- \space&2&y \space=\space 1 \\ &\space\space&8&y \space=\space 8 \end{alignedat}x    28y = 1y = 8

这时候,我们就可以直接得到 y=1y=1y=1,进而从第一个方程得到 x=3x=3x=3

可以看到,消元之后,方程组变成了一个下三角(upper triangular)的形式,然后我们就可以用回带法(back substitution)来快速地解出方程组的解。

进行消元的那一行的第一个非零值称为主元(pivot),消元时候的乘数就等于待消项的系数除以主元,在上面的例子中,乘数 3=3/13 = 3 / 13=3/1。一般地,乘数可以表示为
lij=第 i 行待消去项的系数第 j 行的主元l_{ij} = \frac{第\space i\space 行待消去项的系数}{第 \space j \space行的主元}lij= j  i 

4x − 8y = 43x + 2y = 11 \begin{alignedat}{2} 4&x \space- \space&8&y \space=\space 4 \\ 3&x\space+\space&2&y \space=\space 11 \end{alignedat}43x  x + 82y = 4y = 11

如果我们改变了第一个方程,那么乘数就等于 3/43 / 43/4。消元之后,所有的主元都位于下三角的对角线上,并且主元不能是 0

4x − 8y = 4  8y = 8 \begin{alignedat}{2} 4&x \space- \space&8&y \space=\space 4 \\ &\space\space&8&y \space=\space 8 \end{alignedat}4x    88y = 4y = 8

2. 消元的失效
  • 无解
    x − 2y = 13x − 6y = 11消元后x − 2y = 1  0y = 8\begin{alignedat}{2} &x \space- \space&2&y \space=\space 1 \\ 3&x\space-\space&6&y \space=\space 11 \end{alignedat} \quad{消元后}\quad \begin{alignedat}{2} &x \space- \space&2&y \space=\space 1 \\ &\space\space&0&y \space=\space 8 \end{alignedat}3x  x  26y = 1y = 11x    20y = 1y = 8

这种情况下,我们遇到了 0y=80y = 80y=8,说明原方程组无解。从行图像中,我们也可以看到,两条平行的直线无法相交于一点。而在列图像中,两个在同一方向上的向量不可能线性组合出不在这个方向上的向量。

  • 无穷解
    x − 2y = 13x − 6y = 3消元后x − 2y = 1  0y = 0\begin{alignedat}{2} &x \space- \space&2&y \space=\space 1 \\ 3&x\space-\space&6&y \space=\space 3 \end{alignedat} \quad{消元后}\quad \begin{alignedat}{2} &x \space- \space&2&y \space=\space 1 \\ &\space\space&0&y \space=\space 0 \end{alignedat}3x  x  26y = 1y = 3x    20y = 1y = 0

这种情况下,我们遇到了 0y=00y = 00y=0,任何的 yyy 值都满足要求,此时 yyy 是“自由”的,确定了 yyy 之后 xxx 则由第一个方程确定。

从行图像中,我们也可以看到,两条直线相同,因此整条直线都是交点。而在列图像中,左边的两个向量和右边的向量方向都相同,有无穷多个线性组合都可以产生右边的向量。

对于有 nnn 个方程的方程组,如果我们得不到 nnn 个主元,那么消元就会导致 0̸=0,无解0\not = 0,无解0̸=0 或者 0=0,无穷解0=0,无穷解0=0 ,只有正好有 nnn 个主元的时候,方程组才有解,但我们可能需要进行方程的交换。

  • 需要行交换

0x + 2y = 43x − 2y = 5消元后3x − 2y = 5  2y = 4\begin{alignedat}{2} 0&x \space+ \space&2&y \space=\space 4 \\ 3&x\space-\space&2&y \space=\space 5 \end{alignedat} \quad{消元后}\quad \begin{alignedat}{2} 3&x\space-\space&2&y \space=\space 5 \\ &\space\space&2&y \space=\space 4 \end{alignedat}03x + x  22y = 4y = 53x    22y = 5y = 4

一开始,第一行的主元为 0,行交换后,我们得到了两个主元 3 和 2,然后,方程就有了正常的解。

3. 三个未知数

2x + 4y − 2z= 24x + 9y − 3z= 8−2x − 3y + 7z= 10\begin{alignedat}{3} 2&x \space+\space&4&y \space-\space&2&z=\space 2 \\ 4&x \space+\space&9&y \space-\space&3&z=\space 8\\ -2&x \space-\space&3&y \space+\space&7&z=\space 10 \end{alignedat}242x + x + x  493y  y  y + 237z= 2z= 8z= 10

第一步,方程 2 减去 2 倍的方程 1,得到 y+z=4y+z=4y+z=4
第二步,方程 3 减去 -1 倍的方程 1,得到 y+5z=12y+5z=12y+5z=12
第一步,方程 3 减去 1 倍的方程 2,得到 4z=84z=84z=8

2x + 4y − 2z= 2  1y + 1z= 8    4z= 8\begin{alignedat}{3} \boldsymbol 2&x \space+\space&4&y \space-\space&2&z=\space 2 \\ & \space\space&\boldsymbol 1&y \space+\space&1&z=\space 8\\ & \space\space&& \space\space&\boldsymbol 4&z=\space 8 \end{alignedat}2x +     41y  y +   214z= 2z= 8z= 8

三个主元分别为 2, 1, 4,然后我们就可以用回带法求出方程组的解。

4. 用矩阵的形式来消元

2x1 + 4x2 − 2x3= 24x1 + 9x2 − 3x3= 8−2x1 − 3x2 + 7x3= 10↔[24−249−3−2−37][x1x2x3]=[2810]\begin{alignedat}{3} 2&x_1 \space+\space&4&x_2 \space-\space&2&x_3=\space 2 \\ 4&x_1\space+\space&9&x_2 \space-\space&3&x_3=\space 8\\ -2&x_1 \space-\space&3&x_2 \space+\space&7&x_3=\space 10 \end{alignedat} \leftrightarrow \begin{bmatrix} 2&4&-2 \\ 4&9&-3\\-2&-3&7\end{bmatrix} \begin{bmatrix} x_1 \\ x_2\\x_3 \end{bmatrix} = \begin{bmatrix} 2 \\ 8\\10 \end{bmatrix}242x1 + x1 + x1  493x2  x2  x2 + 237x3= 2x3= 8x3= 10242493237x1x2x3=2810

对方程的两边同时进行一步消元,第 2 个方程减去第 1 个方程的 2 倍,我们可以得到:

[24−2011−2−37][x1x2x3]=[2410]\begin{bmatrix} 2&4&-2 \\ 0&1&1\\-2&-3&7\end{bmatrix} \begin{bmatrix} x_1 \\ x_2\\x_3 \end{bmatrix} = \begin{bmatrix} 2 \\ 4\\10 \end{bmatrix}202413217x1x2x3=2410

相当于左右两边都乘以了一个矩阵 E21E_{21}E21

E21=[100−210001]E_{21} = \begin{bmatrix} 1&0&0 \\ -2&1&0\\0&0&1\end{bmatrix}E21=120010001

E21=[100−210001]∗[row1row2row3]=[row1row2−2row1row3]E_{21} = \begin{bmatrix} 1&0&0 \\ -2&1&0\\0&0&1\end{bmatrix} * \begin{bmatrix} row1 \\ row2\\row3\end{bmatrix} = \begin{bmatrix} row1 \\ row2-2row1\\row3\end{bmatrix}E21=120010001row1row2row3=row1row22row1row3

E21E_{21}E21 称为初等矩阵(elementary matrix)或者消元矩阵(elimination matrix),它可以很简单地从单位矩阵演化而来,EijE_{ij}Eij 就是将单位矩阵 (i,j)(i, j)(i,j) 位置的 0 换成消元过程的乘数 −lij-l_{ij}lij

I=[100010001]→E21=[100−210001]I = \begin{bmatrix} 1&0&0 \\ 0&1&0\\0&0&1\end{bmatrix} \to E_{21} = \begin{bmatrix} 1&0&0 \\ \boxed{-2}&1&0\\0&0&1\end{bmatrix}I=100010001E21=120010001

获取更多精彩,请关注「seniusen」!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值