线性代数
A
=
[
1
2
3
4
]
{\displaystyle \mathbf {A} ={\begin{bmatrix}1&2\\3&4\end{bmatrix))}
向量 ·
向量空间 ·
基底 ·
行列式 ·
矩阵
向量
标量 ·
向量 ·
向量空间 ·
向量投影 ·
外积 (
向量积 ·
七维向量积 ) ·
内积 (
数量积 ) ·
二重向量
矩阵与行列式
矩阵 ·
行列式 ·
线性方程组 ·
秩 ·
核 ·
跡 ·
單位矩陣 ·
初等矩阵 ·
方块矩阵 ·
分块矩阵 ·
三角矩阵 ·
非奇异方阵 ·
转置矩阵 ·
逆矩阵 ·
对角矩阵 ·
可对角化矩阵 ·
对称矩阵 ·
反對稱矩陣 ·
正交矩阵 ·
幺正矩阵 ·
埃尔米特矩阵 ·
反埃尔米特矩阵 ·
正规矩阵 ·
伴随矩阵 ·
余因子矩阵 ·
共轭转置 ·
正定矩阵 ·
幂零矩阵 ·
矩阵分解 (
LU分解 ·
奇异值分解 ·
QR分解 ·
极分解 ·
特征分解 ) ·
子式和余子式 ·
拉普拉斯展開 ·
克罗内克积
线性空间与线性变换
线性空间 ·
线性变换 ·
线性子空间 ·
线性生成空间 ·
基 ·
线性映射 ·
线性投影 ·
線性無關 ·
线性组合 ·
线性泛函 ·
行空间与列空间 ·
对偶空间 ·
正交 ·
特征向量 ·
最小二乘法 ·
格拉姆-施密特正交化
.mw-parser-output .hlist ul,.mw-parser-output .hlist ol{padding-left:0}.mw-parser-output .hlist li,.mw-parser-output .hlist dd,.mw-parser-output .hlist dt{margin:0;display:inline}.mw-parser-output .hlist dt:after,.mw-parser-output .hlist dd:after,.mw-parser-output .hlist li:after{white-space:normal}.mw-parser-output .hlist dt:after{content:" :"}.mw-parser-output .hlist dd:after,.mw-parser-output .hlist li:after{content:" · ";font-weight:bold}.mw-parser-output .hlist-pipe dd:after,.mw-parser-output .hlist-pipe li:after{content:" | ";font-weight:normal}.mw-parser-output .hlist-hyphen dd:after,.mw-parser-output .hlist-hyphen li:after{content:" - ";font-weight:normal}.mw-parser-output .hlist-comma dd:after,.mw-parser-output .hlist-comma li:after{content:"、";font-weight:normal}.mw-parser-output .hlist dd:last-child:after,.mw-parser-output .hlist dt:last-child:after,.mw-parser-output .hlist li:last-child:after{content:none}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li:before{content:" "counter(listitem)" ";white-space:nowrap}.mw-parser-output .hlist dd ol>li:first-child:before,.mw-parser-output .hlist dt ol>li:first-child:before,.mw-parser-output .hlist li ol>li:first-child:before{content:" ("counter(listitem)" "}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li:before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child:before,.mw-parser-output .hlist dt ol>li:first-child:before,.mw-parser-output .hlist li ol>li:first-child:before{content:" ("counter(listitem)"\a0 "}.mw-parser-output ul.cslist,.mw-parser-output ul.sslist{margin:0;padding:0;display:inline-block;list-style:none}.mw-parser-output .cslist li,.mw-parser-output .sslist li{margin:0;display:inline-block}.mw-parser-output .cslist li:after{content:","}.mw-parser-output .sslist li:after{content:";"}.mw-parser-output .cslist li:last-child:after,.mw-parser-output .sslist li:last-child:after{content:none}.mw-parser-output .navbar{display:inline;font-weight:normal;font-size:88%}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit;color:inherit!important}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}
查 论 编
「横向的一条线(row)」的各地常用名稱 中国大陸 行 臺灣 列
「纵向的一条线(column)」的各地常用名稱 中国大陸 列 臺灣 行
数学 中,矩阵乘法 (英語:matrix multiplication )是一种根据两个矩阵 得到第三个矩阵的二元运算 ,第三个矩阵即前两者的乘积,称为矩阵积 (英語:matrix product )。设
A
{\displaystyle A}
是
n
×
m
{\displaystyle n\times m}
的矩阵,
B
{\displaystyle B}
是
m
×
p
{\displaystyle m\times p}
的矩阵,则它们的矩阵积
A
B
{\displaystyle AB}
是
n
×
p
{\displaystyle n\times p}
的矩阵。
A
{\displaystyle A}
中每一行的
m
{\displaystyle m}
个元素都与
B
{\displaystyle B}
中对应列的
m
{\displaystyle m}
个元素对应相乘,这些乘积的和就是
A
B
{\displaystyle AB}
中的一个元素。
矩阵可以用来表示线性映射 ,矩阵积则可以用来表示线性映射的复合 。因此,矩阵乘法是线性代数 的基础工具,不仅在数学中有大量应用,在应用数学 、物理学 、工程学 等领域也有广泛使用。[1] [2]
一般矩陣乘積
矩陣相乘最重要的方法是一般矩陣乘積。它只有在第一個矩陣的列数 (column,台湾作行數 )和第二個矩陣的行数 (row,台湾作列數 )相同時才有定義。一般單指矩陣乘積時,指的便是一般矩陣乘積。若
A
{\displaystyle A}
為
m
×
n
{\displaystyle m\times n}
矩陣,
B
{\displaystyle B}
為
n
×
p
{\displaystyle n\times p}
矩陣,則他們的乘積
A
B
{\displaystyle AB}
(有時記做
A
⋅
B
{\displaystyle A\cdot B}
)會是一個
m
×
p
{\displaystyle m\times p}
矩陣。其乘積矩陣的元素如下面式子得出:
(
A
B
)
i
j
=
∑
r
=
1
n
a
i
r
b
r
j
=
a
i
1
b
1
j
+
a
i
2
b
2
j
+
⋯
+
a
i
n
b
n
j
{\displaystyle (AB)_{ij}=\sum _{r=1}^{n}a_{ir}b_{rj}=a_{i1}b_{1j}+a_{i2}b_{2j}+\cdots +a_{in}b_{nj))
以上是用矩陣單元 的代數系統來說明這類乘法的抽象性質。本節以下各種運算法都是這個公式的不同角度理解,運算結果相等:
由定義直接計算
左邊的圖表示出要如何計算
A
B
{\displaystyle AB}
的
(
1
,
2
)
{\displaystyle (1,2)}
和
(
3
,
3
)
{\displaystyle (3,3)}
元素,當
A
{\displaystyle A}
是個
4
×
2
{\displaystyle 4\times 2}
矩陣和B 是個
2
×
3
{\displaystyle 2\times 3}
矩陣時。分別來自兩個矩陣的元素都依箭頭方向而兩兩配對,把每一對中的兩個元素相乘,再把這些乘積加總起來,最後得到的值即為箭頭相交位置的值。
(
A
B
)
1
,
2
=
∑
r
=
1
2
a
1
,
r
b
r
,
2
=
a
1
,
1
b
1
,
2
+
a
1
,
2
b
2
,
2
{\displaystyle (AB)_{1,2}=\sum _{r=1}^{2}a_{1,r}b_{r,2}=a_{1,1}b_{1,2}+a_{1,2}b_{2,2))
(
A
B
)
3
,
3
=
∑
r
=
1
2
a
3
,
r
b
r
,
3
=
a
3
,
1
b
1
,
3
+
a
3
,
2
b
2
,
3
{\displaystyle (AB)_{3,3}=\sum _{r=1}^{2}a_{3,r}b_{r,3}=a_{3,1}b_{1,3}+a_{3,2}b_{2,3))
向量方法
這種矩陣乘積亦可由稍微不同的觀點來思考:把向量 和各係數 相乘後相加起來。設
A
{\displaystyle \mathbf {A} }
和
B
{\displaystyle \mathbf {B} }
是兩個給定如下的矩陣:
A
=
[
a
1
,
1
a
1
,
2
…
a
2
,
1
a
2
,
2
…
⋮
⋮
⋱
]
=
[
A
1
A
2
…
]
,
{\displaystyle \mathbf {A} ={\begin{bmatrix}a_{1,1}&a_{1,2}&\dots \\a_{2,1}&a_{2,2}&\dots \\\vdots &\vdots &\ddots \end{bmatrix))={\begin{bmatrix}A_{1}&A_{2}&\dots \end{bmatrix)),}
B
=
[
b
1
,
1
b
1
,
2
…
b
2
,
1
b
2
,
2
…
⋮
⋮
⋱
]
=
[
B
1
B
2
⋮
]
{\displaystyle \mathbf {B} ={\begin{bmatrix}b_{1,1}&b_{1,2}&\dots \\b_{2,1}&b_{2,2}&\dots \\\vdots &\vdots &\ddots \end{bmatrix))={\begin{bmatrix}B_{1}\\B_{2}\\\vdots \end{bmatrix))}
其中
A
1
{\displaystyle A_{1))
是由所有
a
x
,
1
{\displaystyle a_{x,1))
元素所组成的向量(column),
A
2
{\displaystyle A_{2))
是由所有
a
x
,
2
{\displaystyle a_{x,2))
元素所组成的向量,以此类推。
B
1
{\displaystyle B_{1))
是由所有
b
1
,
x
{\displaystyle b_{1,x))
元素所组成的向量(row),
B
2
{\displaystyle B_{2))
是由所有
b
2
,
x
{\displaystyle b_{2,x))
元素所组成的向量,以此类推。則
A
B
=
[
a
1
,
1
[
b
1
,
1
b
1
,
2
…
]
+
a
1
,
2
[
b
2
,
1
b
2
,
2
…
]
+
⋯
a
2
,
1
[
b
1
,
1
b
1
,
2
…
]
+
a
2
,
2
[
b
2
,
1
b
2
,
2
…
]
+
⋯
⋮
]
=
A
1
B
1
+
A
2
B
2
+
…
{\displaystyle \mathbf {AB} ={\begin{bmatrix}a_{1,1}{\begin{bmatrix}b_{1,1}&b_{1,2}&\dots \end{bmatrix))+a_{1,2}{\begin{bmatrix}b_{2,1}&b_{2,2}&\dots \end{bmatrix))+\cdots \\\\a_{2,1}{\begin{bmatrix}b_{1,1}&b_{1,2}&\dots \end{bmatrix))+a_{2,2}{\begin{bmatrix}b_{2,1}&b_{2,2}&\dots \end{bmatrix))+\cdots \\\vdots \end{bmatrix))=A_{1}B_{1}+A_{2}B_{2}+\dots }
舉個例子來說:
[
1
0
2
−
1
3
1
]
⋅
[
3
1
2
1
1
0
]
=
[
1
[
3
1
]
+
0
[
2
1
]
+
2
[
1
0
]
−
1
[
3
1
]
+
3
[
2
1
]
+
1
[
1
0
]
]
=
[
[
3
1
]
+
[
0
0
]
+
[
2
0
]
[
−
3
−
1
]
+
[
6
3
]
+
[
1
0
]
]
{\displaystyle {\begin{bmatrix}1&0&2\\-1&3&1\end{bmatrix))\cdot {\begin{bmatrix}3&1\\2&1\\1&0\end{bmatrix))={\begin{bmatrix}1{\begin{bmatrix}3&1\end{bmatrix))+0{\begin{bmatrix}2&1\end{bmatrix))+2{\begin{bmatrix}1&0\end{bmatrix))\\-1{\begin{bmatrix}3&1\end{bmatrix))+3{\begin{bmatrix}2&1\end{bmatrix))+1{\begin{bmatrix}1&0\end{bmatrix))\end{bmatrix))={\begin{bmatrix}{\begin{bmatrix}3&1\end{bmatrix))+{\begin{bmatrix}0&0\end{bmatrix))+{\begin{bmatrix}2&0\end{bmatrix))\\{\begin{bmatrix}-3&-1\end{bmatrix))+{\begin{bmatrix}6&3\end{bmatrix))+{\begin{bmatrix}1&0\end{bmatrix))\end{bmatrix))}
=
[
5
1
4
2
]
{\displaystyle ={\begin{bmatrix}5&1\\4&2\end{bmatrix))}
左面矩陣的列為為係數表,右邊矩陣為向量表。例如,第一行是[1 0 2],因此將1乘上第一個向量,0乘上第二個向量,2則乘上第三個向量。
向量表方法
一般矩陣乘積也可以想為是行向量 和列向量 的內積 。若
A
{\displaystyle \mathbf {A} }
和
B
{\displaystyle \mathbf {B} }
為給定如下的矩陣:
A
=
[
a
1
,
1
a
1
,
2
a
1
,
3
…
a
2
,
1
a
2
,
2
a
2
,
3
…
a
3
,
1
a
3
,
2
a
3
,
3
…
⋮
⋮
⋮
⋱
]
=
[
A
1
A
2
A
3
⋮
]
{\displaystyle \mathbf {A} ={\begin{bmatrix}a_{1,1}&a_{1,2}&a_{1,3}&\dots \\a_{2,1}&a_{2,2}&a_{2,3}&\dots \\a_{3,1}&a_{3,2}&a_{3,3}&\dots \\\vdots &\vdots &\vdots &\ddots \end{bmatrix))={\begin{bmatrix}A_{1}\\A_{2}\\A_{3}\\\vdots \end{bmatrix))}
且
B
=
[
b
1
,
1
b
1
,
2
b
1
,
3
…
b
2
,
1
b
2
,
2
b
2
,
3
…
b
3
,
1
b
3
,
2
b
3
,
3
…
⋮
⋮
⋮
⋱
]
=
[
B
1
B
2
B
3
…
]
{\displaystyle \mathbf {B} ={\begin{bmatrix}b_{1,1}&b_{1,2}&b_{1,3}&\dots \\b_{2,1}&b_{2,2}&b_{2,3}&\dots \\b_{3,1}&b_{3,2}&b_{3,3}&\dots \\\vdots &\vdots &\vdots &\ddots \end{bmatrix))={\begin{bmatrix}B_{1}&B_{2}&B_{3}&\dots \end{bmatrix))}
其中,这里
A
1
{\displaystyle A_{1))
是由所有
a
1
,
x
{\displaystyle a_{1,x))
元素所組成的向量,
A
2
{\displaystyle A_{2))
是由所有
a
2
,
x
{\displaystyle a_{2,x))
元素所組成的向量,以此類推。
B
1
{\displaystyle B_{1))
是由所有
b
x
,
1
{\displaystyle b_{x,1))
元素所組成的向量,
B
2
{\displaystyle B_{2))
是由所有
b
x
,
2
{\displaystyle b_{x,2))
元素所組成的向量,以此類推。则
A
B
=
[
A
1
A
2
A
3
⋮
]
×
[
B
1
B
2
B
3
…
]
=
[
(
A
1
⋅
B
1
)
(
A
1
⋅
B
2
)
(
A
1
⋅
B
3
)
…
(
A
2
⋅
B
1
)
(
A
2
⋅
B
2
)
(
A
2
⋅
B
3
)
…
(
A
3
⋅
B
1
)
(
A
3
⋅
B
2
)
(
A
3
⋅
B
3
)
…
⋮
⋮
⋮
⋱
]
{\displaystyle \mathbf {AB} ={\begin{bmatrix}A_{1}\\A_{2}\\A_{3}\\\vdots \end{bmatrix))\times {\begin{bmatrix}B_{1}&B_{2}&B_{3}&\dots \end{bmatrix))={\begin{bmatrix}(A_{1}\cdot B_{1})&(A_{1}\cdot B_{2})&(A_{1}\cdot B_{3})&\dots \\(A_{2}\cdot B_{1})&(A_{2}\cdot B_{2})&(A_{2}\cdot B_{3})&\dots \\(A_{3}\cdot B_{1})&(A_{3}\cdot B_{2})&(A_{3}\cdot B_{3})&\dots \\\vdots &\vdots &\vdots &\ddots \end{bmatrix))}
即
(
A
B
)
i
j
=
A
i
B
j
{\displaystyle \left(\mathbf {AB} \right)_{ij}=A_{i}B_{j))
性質
矩陣乘法是不可交換 的(即
A
B
≠
B
A
{\displaystyle AB\neq BA}
),除了一些較特別的情況。很清楚可以知道,不可能預期說在改變向量的部份後還能得到相同的結果,而且第一個矩陣的列數必須要和第二個矩陣的行數相同,也可以看出為什麼矩陣相乘的順序會影響其結果。
雖然矩陣乘法是不可交換的,但
A
B
{\displaystyle AB}
和
B
A
{\displaystyle BA}
的行列式 總會是一樣的(當
A
{\displaystyle A}
、
B
{\displaystyle B}
是同樣大小的方陣時)。其解釋在行列式 條目內。
當
A
{\displaystyle A}
、
B
{\displaystyle B}
可以被解釋為線性算子 ,其矩陣乘積
A
B
{\displaystyle AB}
會對應為兩個線性算子的複合函數 ,其中B 先作用。
在試算表中做矩陣乘法
[
1
0
2
−
1
3
1
]
⋅
[
3
1
2
1
1
0
]
=
[
5
1
4
2
]
{\displaystyle {\begin{bmatrix}1&0&2\\-1&3&1\end{bmatrix))\cdot {\begin{bmatrix}3&1\\2&1\\1&0\end{bmatrix))={\begin{bmatrix}5&1\\4&2\end{bmatrix))}
以 Google Sheet 為例,選取儲存格範圍或者使用陣列,在儲存格輸入
= MMULT ( {1,0,2;-1,3,1},{3,1;2,1;1,0})
在某些試算表軟體中必須必須按Ctrl +⇧ Shift +↵ Enter 將儲存格內的變數轉換為陣列
共同性質
上述三種乘積都符合結合律 :
A
(
B
C
)
=
(
A
B
)
C
{\displaystyle A(BC)=(AB)C}
以及分配律 :
A
(
B
+
C
)
=
A
B
+
A
C
{\displaystyle A(B+C)=AB+AC}
(
A
+
B
)
C
=
A
C
+
B
C
{\displaystyle (A+B)C=AC+BC}
而且和純量乘積相容:
c
(
A
B
)
=
(
c
A
)
B
{\displaystyle c(AB)=(cA)B}
(
A
c
)
B
=
A
(
c
B
)
{\displaystyle (Ac)B=A(cB)}
(
A
B
)
c
=
A
(
B
c
)
{\displaystyle (AB)c=A(Bc)}
注意上述三個分開的表示式只有在純量體的乘法及加法是可交換(即純量體為一可交換環)時會相同。