Mnożenie macierzy przez macierz

Autor podstrony: Krzysztof Zajączkowski

Stronę tą wyświetlono już: 6305 razy

Mnożenie macierzy jest możliwe jedynie w przypadku, gdy dana macierz A ma tyle samo kolumn co macierz B wierszy. Ogólny zapis mnożenia dwóch macierzy wygląda więc następująco:

Równanie [1] [1]

Zapis wyrażenia w formacie TeX-a:

A\cdot B=\begin{bmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,m}\\ a_{2,1} & a_{2,2} & \cdots & a_{2,m}\\ \vdots & \vdots & \ddots & \vdots\\ a_{n,1} & a_{n,2} & cdots & a_{n,m}\end{bmatrix}\cdot\begin{bmatrix} b_{1,1} & b_{1,2} & \cdots & b_{1,p}\\ b_{2,1} & b_{2,2} & \cdots & b_{2,p}\\ \vdots & \vdots & \ddots & \vdots\\ b_{m,1} & b_{m,2} & cdots & b_{m,p} \end{bmatrix}=\begin{bmatrix} \sum_{i=1}^{m}a_{1,i}\cdot b_{i,1} & sum_{i=1}^{m}a_{1,i}\cdot b_{i,2} & \cdots & \sum_{i=1}^{m}a_{1,i}\cdot b_{i,p}\\ \sum_{i=1}^{m}a_{2,i}\cdot b_{i,1} & \sum_{i=1}^{m}a_{2,i}\cdot b_{i,2} & \cdots & \sum_{i=1}^{m}a_{2,i}\cdot b_{i,p}\\ \vdots & \vdots & \ddots & \vdots\\ \sum_{i=1}^{m}a_{n,i}\cdot b_{i,1} & \sum_{i=1}^{m}a_{n,i}\cdot b_{i,2} & \cdots & \sum_{i=1}^{m}a_{n,i}\cdot b_{i,p}\end{bmatrix}

gdzie:

Pewnym zaskoczeniem może się wydawać fakt, że iloczyn macierzy A, B jest nieprzemienne, czyli ABBA.

Przykłady

Obliczyć iloczyn macierzy AB, BA oraz CD.

Dane:

A=begin{bmatrix}1 & 4 & 6\ 8 & 2 & 4end{bmatrix};,B=begin{bmatrix} 9 & 6\ 3 & 7\ 2 & 1end{bmatrix};,C=begin{bmatrix} 5 & 6 & 1\ 8 & 7 & 9\ 1 & 5 & 2end{bmatrix};,D=begin{bmatrix} 4 & 6 & 7\ 2 & 5 & 1\ 0 & 3 & 9 end{bmatrix}

Rozwiązanie:

Iloczyn AB:

Acdot B=begin{bmatrix} 1 & 4 & 6\ 8 & 2 & 4end{bmatrix}cdotbegin{bmatrix} 9 & 6\ 3 & 7\ 2 & 1
end{bmatrix}=begin{bmatrix}1cdot9+4cdot 3+6cdot 2 & 1cdot 6+4cdot 7+6cdot 1\ 8cdot 9+2cdot 3+4cdot 2 & 8cdot 6+2cdot 7+4cdot 1end{bmatrix}=begin{bmatrix} 33 & 40\ 86 & 66end{bmatrix}

Iloczyn BA:

Bcdot A=begin{bmatrix} 9 & 6\ 3 & 7\ 2 & 1end{bmatrix}cdot begin{bmatrix}1 & 4 & 6\ 8 & 2 & 4end{bmatrix}=begin{bmatrix}9cdot 1+6cdot 8 & 9cdot 4+6cdot 2 & 9cdot 6+6cdot 4\ 3cdot 1+7cdot 8 & 3cdot 4+7cdot 2 & 3cdot 6+7cdot 4\ 2cdot 1+1cdot 8 & 2cdot 4+1cdot 2 & 2cdot 6+1cdot 4 end{bmatrix}=begin{bmatrix}57 & 48 & 78\ 59 & 26 & 46\ 10 & 10 & 16end{bmatrix}

Iloczyn macierzy kwadratowych CD:

Ccdot D=begin{bmatrix}5 & 6 & 1\ 8 & 7 & 9\ 1 & 5 & 2end{bmatrix}cdot begin{bmatrix}4 & 6 & 7\ 2 & 5 & 1\ 0 & 3 & 9end{bmatrix}=begin{bmatrix}5cdot 4+6cdot 2+1cdot 0 & 5cdot 6+6cdot 5+1cdot 3 & 5cdot 7+6cdot 1+1cdot9\ 8cdot 4+7cdot 2+9cdot 0 & 8cdot 6+7cdot 5+9cdot 3 & 8cdot 7+7cdot 1+9cdot 9\ 1cdot 4+5cdot 2+2cdot 0 & 1cdot 6+5cdot 5+2cdot 3 & 1cdot 7+5cdot 1+2cdot 9end{bmatrix}=begin{bmatrix} 32 & 63 & 50\ 46 & 92 & 144\ 14 & 37 & 30end{bmatrix}