矩陣乘法

矩陣乘法

矩陣相乘最重要的方法是一般矩陣乘積。它只有在第一個矩陣的列数(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 將儲存格內的變數轉換為陣列

相关文章

诺里斯狗粮怎么样(产地是哪里的)
365在线体育

诺里斯狗粮怎么样(产地是哪里的)

⌛ 06-30 👁️‍🗨️ 7120
体脂率怎么测
365在线体育

体脂率怎么测

⌛ 08-12 👁️‍🗨️ 1901
手机怎么听广播电台
365在线体育

手机怎么听广播电台

⌛ 08-06 👁️‍🗨️ 9894
最流行的三大数据建模工具
bte365正规网站

最流行的三大数据建模工具

⌛ 07-18 👁️‍🗨️ 3039
前島美步
365bet网上手机投注

前島美步

⌛ 08-08 👁️‍🗨️ 6440
传奇里如何获得声望?(传奇里如何获得声望称号)
365bet网上手机投注

传奇里如何获得声望?(传奇里如何获得声望称号)

⌛ 08-11 👁️‍🗨️ 3988