Množenje matrica

Autor Catalin David

Da bismo mogli da množimo dve matrice broj kolona prve matrice mora biti jednak broju vrsta druge matrice.

Algoritam za množenje matrica

Množimo elemente vrsta prve matrice sa elementima kolona druge matrice.

  1. Množimo elemente prve vrste sa elementima prve kolone.
    • Množimo prvi element prve vrste sa prvim elementom prve kolone.
    • Množimo drugi element prve vrste sa drugim elementom prve kolone.
    • Množimo na ovaj način sve dok ne pomnožimo svaki element prve vrste prve matrice sa odgovarajućim elementom prve kolone druge matrice.
    • Sabiramo dobijene rezultate (proizvode).
    • Dobijeni rezultat biće element prve vrste i prve kolone rezultirajuće matrice.
  2. Množimo elemente prve vrste prve matrice sa elementima druge kolone druge matrice.
    • Množimo prvi element prve vrste sa prvim elementom druge kolone.
    • Množimo drugi element prve vrste sa drugim elementom druge kolone.
    • Množimo na ovaj način sve dok ne pomnožimo svaki element prve vrste prve matrice sa odgovarajućim elementom druge kolone druge matrice.
    • Sabiramo dobijene rezultate (proizvode),
    • Dobijeni rezultat biće element prve vrste i druge kolone rezultirajuće matrice.
  3. Daljom primenom ovog algoritma množićemo elemente prve vrste prve matrice sa elementima preostalih kolona druge matrice. Ovim rezultatima popunićemo prvu vrstu rezultirajuće matrice.
  4. Druga vrste rezultujuće matrice popunjava se analogno, tj. svaki element druge vrste rezultujuće matrice biće jednak zbiru proizvoda elemenata druge vrste prve matrice sa odgovarajućim elementima kolona druge matrice.
  5. Ovo radimo za svaku vrstu prve matrice sve dok rezultujuća matrica nije popunjena.

Primer 7
$A= \begin{pmatrix} 1 & 2 & 2\\ 3 & 1 & 1 \end{pmatrix}$
$B=\begin{pmatrix} 4 & 2 \\ 3 & 1 \\ 1 & 5\\ \end{pmatrix}$

Primetimo da matrica A ima 3 kolone, a matrica B 3 vrste što znači da možemo da ih množimo.

$A \cdot B=$ $\begin{pmatrix} \color{red}1 &\color{blue}2 & \color{green}2\\ \color{red}3 &\color{blue}1 & \color{green}1 \end{pmatrix} \begin{pmatrix} \color{red}4 & \color{red}2 \\ \color{blue}3 & \color{blue}1 \\ \color{green}1 & \color{green}5 \end{pmatrix}=$ $\begin{pmatrix} \color{red}{1\cdot4}+\color{blue}{2\cdot3}+\color{green}{2\cdot1} & \color{red}{1\cdot2}+\color{blue}{2\cdot1}+\color{green}{2\cdot5}\\ \color{red}{3\cdot4}+\color{blue}{1\cdot3}+\color{green}{1\cdot1} & \color{red}{3\cdot2}+\color{blue}{1\cdot1}+\color{green}{1\cdot5} \end{pmatrix}=$ $\begin{pmatrix} 12 & 14\\ 16 & 12\\ \end{pmatrix}$

$B \cdot A = \begin{pmatrix} \color{red}4 &\color{blue}2 \\ \color{red}3 & \color{blue}1 \\ \color{red}1 & \color{blue}5 \end{pmatrix} \begin{pmatrix} \color{red}1 &\color{red}2 & \color{red}2\\ \color{blue}3 &\color{blue}1 & \color{blue}1 \end{pmatrix}=$

$\begin{pmatrix} \color{red}{4\cdot1}+\color{blue}{2\cdot3} & \color{red}{4\cdot2}+\color{blue}{2\cdot1} & \color{red}{4\cdot2}+\color{blue}{2\cdot1}\\ \color{red}{3\cdot1}+\color{blue}{1\cdot3} & \color{red}{3\cdot2}+\color{blue}{1\cdot1} & \color{red}{3\cdot2}+\color{blue}{1\cdot1}\\ \color{red}{1\cdot1}+\color{blue}{5\cdot3} & \color{red}{1\cdot2}+\color{blue}{5\cdot1} & \color{red}{1\cdot2}+ \color{blue}{5\cdot1} \end{pmatrix} =$ $\begin{pmatrix} 10 & 10 & 10 \\ 6 & 7 & 7 \\ 16 & 7 & 7 \end{pmatrix}$

Primetimo da $A \cdot B \neq B \cdot A$

Primer 8
$A= \begin{pmatrix} 5 & 2 \\ 3 & 1 \end{pmatrix} B= \begin{pmatrix} 4 & 6 \\ 5 & 2 \end{pmatrix}$

$A \cdot B = \begin{pmatrix} \color{red}5 & \color{blue}2 \\ \color{red}3 & \color{blue}1 \end{pmatrix} \cdot \begin{pmatrix} \color{red}4 & \color{red}6 \\ \color{blue}5 & \color{blue}2 \end{pmatrix} =\begin{pmatrix} \color{red}{5\cdot4}+\color{blue}{2\cdot5} & \color{red}{5\cdot6}+\color{blue}{2\cdot2} \\ \color{red}{3\cdot4}+\color{blue}{1\cdot5} & \color{red}{3\cdot6}+\color{blue}{1\cdot2} \end{pmatrix} =$ $\begin{pmatrix} 30 & 34\\ 17 & 20 \end{pmatrix}$

$B \cdot A= \begin{pmatrix} \color{red}4 & \color{blue}6 \\ \color{red}5 & \color{blue}2 \end{pmatrix} \cdot \begin{pmatrix} \color{red}5 & \color{red}2 \\ \color{blue}3 & \color{blue}1 \end{pmatrix} =\begin{pmatrix} \color{red}{4\cdot5}+\color{blue}{6\cdot3} & \color{red}{4\cdot2}+\color{blue}{5\cdot1} \\ \color{red}{5\cdot5}+\color{blue}{2\cdot3} & \color{red}{5\cdot2}+\color{blue}{2\cdot1} \end{pmatrix} =$ $\begin{pmatrix} 38 & 14\\ 31 & 12 \end{pmatrix}$

Još jednom: $A \cdot B \neq B \cdot A$.

Primer 9
$A= \begin{pmatrix} 1 & 4 & 3 \\ 2 & 1 & 5\\ 3 & 2 & 1 \end{pmatrix} B= \begin{pmatrix} 5 & 2 & 1 \\ 4 & 3 & 2 \\ 2 & 1 & 5 \end{pmatrix}$

$A \cdot B = \begin{pmatrix} \color{red}{1} & \color{blue}{4} & \color{green}{3} \\ \color{red}{2} & \color{blue}{1} & \color{green}{5}\\ \color{red}{3} & \color{blue}{2} & \color{green}{1} \end{pmatrix} \cdot \begin{pmatrix} \color{red}{5} & \color{red}{2} & \color{red}{1} \\ \color{blue}{4} & \color{blue}{3} & \color{blue}{2} \\ \color{green}{2} & \color{green}{1} & \color{green}{5} \end{pmatrix}=$

$\begin{pmatrix} \color{red}{1\cdot5} + \color{blue}{4\cdot4} + \color{green}{3\cdot2} & \color{red}{1\cdot2} + \color{blue}{4\cdot3} + \color{green}{3\cdot1} & \color{red}{1\cdot1} + \color{blue}{4\cdot2} + \color{green}{3\cdot5} \\ \color{red}{2\cdot5} + \color{blue}{1\cdot4} + \color{green}{5\cdot2} & \color{red}{2\cdot2} + \color{blue}{1\cdot3} + \color{green}{5\cdot1} & \color{red}{2\cdot1} + \color{blue}{1\cdot2} + \color{green}{5\cdot5}\\ \color{red}{3\cdot5} + \color{blue}{2\cdot4} + \color{green}{1\cdot2} & \color{red}{3\cdot2} + \color{blue}{2\cdot3} + \color{green}{1\cdot1} & \color{red}{3\cdot1} + \color{blue}{2\cdot2} + \color{green}{1\cdot5} \end{pmatrix}=$
$=\begin{pmatrix} 27 & 17 & 24\\ 24 & 12 & 29\\ 25 & 13 & 12 \end{pmatrix}$

$B \cdot A = \begin{pmatrix} \color{red}{5} & \color{blue}{2} & \color{green}{1}\\ \color{red}{4} & \color{blue}{3} & \color{green}{2}\\ \color{red}{2} & \color{blue}{1} & \color{green}{5} \end{pmatrix} \cdot \begin{pmatrix} \color{red}{1} & \color{red}{4} & \color{red}{3} \\ \color{blue}{2} & \color{blue}{1} & \color{blue}{5} \\ \color{green}{3} & \color{green}{2} & \color{green}{1} \end{pmatrix}=$ $\begin{pmatrix} \color{red}{5\cdot1} + \color{blue}{2\cdot2} + \color{green}{1\cdot2} & \color{red}{5\cdot4} + \color{blue}{2\cdot1} + \color{green}{1\cdot2} & \color{red}{5\cdot3} + \color{blue}{2\cdot5} + \color{green}{1\cdot1} \\ \color{red}{4\cdot1} + \color{blue}{3\cdot2} + \color{green}{2\cdot3} & \color{red}{4\cdot4} + \color{blue}{3\cdot1} + \color{green}{2\cdot2} & \color{red}{4\cdot3} + \color{blue}{3\cdot5} + \color{green}{2\cdot1}\\ \color{red}{2\cdot1} + \color{blue}{1\cdot2} + \color{green}{5\cdot3} & \color{red}{2\cdot4} + \color{blue}{1\cdot1} + \color{green}{5\cdot2} & \color{red}{2\cdot3} + \color{blue}{1\cdot5} + \color{green}{5\cdot1} \end{pmatrix}=$
$=\begin{pmatrix} 11 & 24 & 26\\ 16 & 23 & 29\\ 19 & 19 & 16 \end{pmatrix}$

Još jednom $A \cdot B \neq B \cdot A$.

Primer 10
$A= \begin{pmatrix} 5 & 2\\ 3 & 1\\ \end{pmatrix} I_{2}= \begin{pmatrix} 1 & 0 \\ 0 & 1 \\ \end{pmatrix}$

$A \cdot B = \begin{pmatrix} \color{red}{5} & \color{blue}{2}\\ \color{red}{3} & \color{blue}{1} \end{pmatrix} \cdot \begin{pmatrix} \color{red}{1} & \color{red}{0} \\ \color{blue}{0} & \color{blue}{1} \end{pmatrix} =\begin{pmatrix} \color{red}{5\cdot1}+\color{blue}{2\cdot0} & \color{red}{5\cdot0}+\color{blue}{2\cdot1} \\ \color{red}{3\cdot1}+\color{blue}{1\cdot0} & \color{red}{3\cdot0}+\color{blue}{1\cdot1} \end{pmatrix} = \begin{pmatrix} 5 & 2\\ 3 & 1 \end{pmatrix}$

$B \cdot A = \begin{pmatrix} \color{red}{1} & \color{blue}{0} \\ \color{red}{0} & \color{blue}{1} \end{pmatrix} \cdot \begin{pmatrix} \color{red}{5} & \color{red}{2} \\ \color{blue}{3} & \color{blue}{1} \\ \end{pmatrix} =\begin{pmatrix} \color{red}{1\cdot5}+\color{blue}{0\cdot3} & \color{red}{1\cdot2}+\color{blue}{0\cdot1} \\ \color{red}{0\cdot5}+\color{blue}{1\cdot3} & \color{red}{0\cdot2}+\color{blue}{1\cdot1} \end{pmatrix} = \begin{pmatrix} 5 & 2\\ 3 & 1 \end{pmatrix}$

Primetimo da $A \cdot I_{2} = I_{2} \cdot A=A$.

Primer 11
$A=\begin{pmatrix} 1 & 4 & 3 \\ 2 & 1 & 5\\ 3 & 2 & 1 \end{pmatrix} I_{3}= \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$

$A \cdot B = \begin{pmatrix} \color{red}{1} & \color{blue}{4} & \color{green}{3} \\ \color{red}{2} & \color{blue}{1} & \color{green}{5}\\ \color{red}{3} & \color{blue}{2} & \color{green}{1} \end{pmatrix} \cdot \begin{pmatrix} \color{red}{1} & \color{red}{0} & \color{red}{0} \\ \color{blue}{0} & \color{blue}{1} & \color{blue}{0} \\ \color{green}{0} & \color{green}{0} & \color{green}{1} \end{pmatrix}=$

$\begin{pmatrix} \color{red}{1\cdot1} + \color{blue}{4\cdot0} + \color{green}{3\cdot0} & \color{red}{1\cdot0} + \color{blue}{4\cdot1} + \color{green}{3\cdot0} & \color{red}{1\cdot0} + \color{blue}{4\cdot0} + \color{green}{3\cdot1} \\ \color{red}{2\cdot1} + \color{blue}{1\cdot0} + \color{green}{5\cdot0} & \color{red}{2\cdot0} + \color{blue}{1\cdot1} + \color{green}{5\cdot0} & \color{red}{2\cdot0} + \color{blue}{1\cdot0} + \color{green}{5\cdot1}\\ \color{red}{3\cdot1} + \color{blue}{2\cdot0} + \color{green}{1\cdot0} & \color{red}{3\cdot0} + \color{blue}{2\cdot1} + \color{green}{1\cdot0} & \color{red}{3\cdot0} + \color{blue}{2\cdot0} + \color{green}{1\cdot1} \end{pmatrix}=$
$=\begin{pmatrix} 1 & 4 & 3\\ 2 & 1 & 5\\ 3 & 2 & 1 \end{pmatrix}$

$B \cdot A = \begin{pmatrix} \color{red}{1} & \color{blue}{0} & \color{green}{0} \\ \color{red}{0} & \color{blue}{1} & \color{green}{0}\\ \color{red}{0} & \color{blue}{0} & \color{green}{1} \end{pmatrix} \cdot \begin{pmatrix} \color{red}{1} & \color{red}{4} & \color{red}{3} \\ \color{blue}{2} & \color{blue}{1} & \color{blue}{5} \\ \color{green}{3} & \color{green}{2} & \color{green}{1} \end{pmatrix}=$

$\begin{pmatrix} \color{red}{1\cdot1} + \color{blue}{0\cdot2} + \color{green}{0\cdot2} & \color{red}{1\cdot4} + \color{blue}{0\cdot1} + \color{green}{0\cdot2} & \color{red}{1\cdot3} + \color{blue}{0\cdot5} + \color{green}{0\cdot1} \\ \color{red}{0\cdot1} + \color{blue}{1\cdot2} + \color{green}{0\cdot3} & \color{red}{0\cdot4} + \color{blue}{1\cdot1} + \color{green}{0\cdot2} & \color{red}{0\cdot3} + \color{blue}{1\cdot5} + \color{green}{0\cdot1}\\ \color{red}{0\cdot1} + \color{blue}{0\cdot2} + \color{green}{1\cdot3} & \color{red}{0\cdot4} + \color{blue}{0\cdot1} + \color{green}{1\cdot2} & \color{red}{0\cdot3} + \color{blue}{0\cdot5} + \color{green}{1\cdot1} \end{pmatrix} =$
$=\begin{pmatrix} 1 & 4 & 3\\ 2 & 1 & 5\\ 3 & 2 & 1 \end{pmatrix}$

Još jednom $A \cdot I_{3} = I_{3} \cdot A = A$.

Da zaključimo:

  1. Uopšteno, množenje matrica nije komutativno.
  2. $A\cdot I_{n} = I_{n} \cdot A = A$ za svaku matricu A koja ima n kolona.


Kontakt imejl:
Copyright © 2005 - 2024