TD 6

Index

Theoretical Background

Basic Concepts

About Matrix Multiplication

Other Concepts

Exercises

Exercise 1

Given these matrices $$ B = \begin{bmatrix} 2 & 3 & 4 \\ 1 & 5 & 6 \\ 7 & 8 & 9 \\ \end{bmatrix} C = \begin{bmatrix} 3 & 8 \\ 1 & 6 \\ \end{bmatrix} D = \begin{bmatrix} 4 & 1 \\ 9 & 2 \\ 3 & 7 \\ \end{bmatrix} $$ The matrix dimensions in this case are: $B \to (3,3)$, $C \to (2,2)$, $D \to (3,2)$. When multiplying two matrices, the first step is to check what shape the outcome matrix would be:

Matrix Multiplication Shape of the Input Matrices Shape of the Output Matrix
$BC$ $(3, \color{yellow} 3) \times (\color{yellow} 2,2)$ can't multiply
$CB$ $(2, \color{yellow} 2) \times (\color{yellow} 3,3)$ can't multiply
$BD$ $(3,\color{magenta} 3) \times (\color{magenta} 3,2)$ $(3,2)$
$DB$ $(3, \color{yellow} 2) \times (\color{yellow} 3,3)$ can't multiply
$CD$ $(2, \color{yellow} 2) \times (\color{yellow} 3,2)$ can't multiply
$DC$ $(3, \color{magenta} 2) \times (\color{magenta} 2,2)$ $(3,2)$
When multiplying two matrices, it's useful to think of the second matrix as a collection of vectors. Then, it just becomes a repeated matrix vector multiplication, where the "vectors" are the columns of the second matrix. For example: $$\begin{aligned} BD = \begin{bmatrix}2&3&4\\1&5&6\\7&8&9\\\end{bmatrix} \begin{bmatrix}4&1\\9&2\\3&7\\\end{bmatrix} &=\begin{bmatrix}?&?\\?&?\\?&?\\\end{bmatrix} \\\\ \begin{bmatrix}\color{yellow}2&\color{yellow}3&\color{yellow}4\\1&5&6\\7&8&9\\\end{bmatrix} \begin{bmatrix}\color{cyan}4&1\\\color{cyan}9&2\\\color{cyan}3&7\\\end{bmatrix} &=\begin{bmatrix}\color{yellow}{(2)}\color{cyan}{(4)}+\color{yellow}{(3)}\color{cyan}{(9)}+\color{yellow}{(4)}\color{cyan}{(3)}&?\\?&?\\?&?\\\end{bmatrix} \\\\ \begin{bmatrix}2&3&4\\\color{yellow}1&\color{yellow}5&\color{yellow}6\\7&8&9\\\end{bmatrix} \begin{bmatrix}\color{cyan}4&1\\\color{cyan}9&2\\\color{cyan}3&7\\\end{bmatrix} &=\begin{bmatrix}47&?\\\color{yellow}{(1)}\color{cyan}{(4)}+\color{yellow}{(5)}\color{cyan}{(9)}+\color{yellow}{(6)}\color{cyan}{(3)}&?\\?&?\\\end{bmatrix} \\\\ \begin{bmatrix}2&3&4\\1&5&6\\\color{yellow}7&\color{yellow}8&\color{yellow}9\\\end{bmatrix} \begin{bmatrix}\color{cyan}4&1\\\color{cyan}9&2\\\color{cyan}3&7\\\end{bmatrix} &=\begin{bmatrix}47&?\\67&?\\\color{yellow}{(7)}\color{cyan}{(4)}+\color{yellow}{(8)}\color{cyan}{(9)}+\color{yellow}{(9)}\color{cyan}{(3)}&?\\\end{bmatrix} \\\\ \begin{bmatrix}\color{yellow}2&\color{yellow}3&\color{yellow}4\\1&5&6\\7&8&9\\\end{bmatrix} \begin{bmatrix}4&\color{cyan}1\\9&\color{cyan}2\\3&\color{cyan}7\\\end{bmatrix} &=\begin{bmatrix}47&\color{yellow}{(2)}\color{cyan}{(1)}+\color{yellow}{(3)}\color{cyan}{(2)}+\color{yellow}{(4)}\color{cyan}{(7)}\\67&?\\127&?\\\end{bmatrix} \\\\ \begin{bmatrix}2&3&4\\\color{yellow}1&\color{yellow}5&\color{yellow}6\\7&8&9\\\end{bmatrix} \begin{bmatrix}4&\color{cyan}1\\9&\color{cyan}2\\3&\color{cyan}7\\\end{bmatrix} &=\begin{bmatrix}47&36\\67&\color{yellow}{(1)}\color{cyan}{(1)}+\color{yellow}{(5)}\color{cyan}{(2)}+\color{yellow}{(6)}\color{cyan}{(7)}\\127&?\\\end{bmatrix} \\\\ \begin{bmatrix}2&3&4\\1&5&6\\\color{yellow}7&\color{yellow}8&\color{yellow}9\\\end{bmatrix} \begin{bmatrix}4&\color{cyan}1\\9&\color{cyan}2\\3&\color{cyan}7\\\end{bmatrix} &=\begin{bmatrix}47&36\\67&53\\127&\color{yellow}{(7)}\color{cyan}{(1)}+\color{yellow}{(8)}\color{cyan}{(2)}+\color{yellow}{(9)}\color{cyan}{(7)}\\\end{bmatrix} \\\\ \begin{bmatrix}2&3&4\\1&5&6\\7&8&9\\\end{bmatrix} \begin{bmatrix}4&1\\9&2\\3&7\\\end{bmatrix} &=\begin{bmatrix}47&36\\67&53\\127&86\\\end{bmatrix} \\ \end{aligned}$$

Exercise 3

$$\begin{aligned} &det \begin{pmatrix}\color{yellow}1&\color{magenta}2&\color{cyan}3\\\color{yellow}4&\color{magenta}5&\color{cyan}6\\\color{yellow}2&\color{magenta}4&\color{cyan}6\\\end{pmatrix} \\ =& + (\color{yellow}1) det \begin{pmatrix}\color{magenta}5&\color{cyan}6\\\color{magenta}4&\color{cyan}6\end{pmatrix} - (\color{magenta}2) det \begin{pmatrix}\color{yellow}4&\color{cyan}6\\\color{yellow}2&\color{cyan}6\end{pmatrix} + (\color{cyan}3) det \begin{pmatrix}\color{yellow}4&\color{magenta}5\\\color{yellow}2&\color{magenta}4\end{pmatrix} \\ =& (\color{yellow}1) (\color{magenta}5 \times \color{cyan}6 - \color{magenta}4 \times \color{cyan}6) - (\color{magenta}2) (\color{yellow}4 \times \color{cyan}6 - \color{yellow}2 \times \color{cyan}6) + (\color{cyan}3) (\color{yellow}4 \times \color{magenta}4 - \color{yellow}2 \times \color{magenta}5) \\ =& (\color{yellow}1) (6) - (\color{magenta}2) (12) + (\color{cyan}3) (6) \\ =& 6 - 24 + 18 = 0 \therefore \text{the matrix has no inverse} \\ \end{aligned}$$

Exercise 4

$$ R = \begin{bmatrix} \frac{\sqrt{3}}{2} & -\frac{1}{2} & 0 \\ \frac{\sqrt{2}}{4} & \frac{\sqrt{6}}{4} & -\frac{\sqrt{2}}{2} \\ \frac{\sqrt{2}}{4} & \frac{\sqrt{6}}{4} & \frac{\sqrt{2}}{2} \\ \end{bmatrix} $$ To confirm that $R$ is a rotation matrix, first verify that its determinant $|R|=1$. $$\begin{aligned} & \begin{vmatrix} \frac{\sqrt{3}}{2} & -\frac{1}{2} & 0 \\ \frac{\sqrt{2}}{4} & \frac{\sqrt{6}}{4} & -\frac{\sqrt{2}}{2} \\ \frac{\sqrt{2}}{4} & \frac{\sqrt{6}}{4} & \frac{\sqrt{2}}{2} \\ \end{vmatrix} \\\\ =& +(\frac{\sqrt{3}}{2}) \begin{vmatrix} \frac{\sqrt{6}}{4} & -\frac{\sqrt{2}}{2} \\ \frac{\sqrt{6}}{4} & \frac{\sqrt{2}}{2} \\ \end{vmatrix} - (-\frac{1}{2}) \begin{vmatrix} \frac{\sqrt{2}}{4} & -\frac{\sqrt{2}}{2} \\ \frac{\sqrt{2}}{4} & \frac{\sqrt{2}}{2} \\ \end{vmatrix} \\\\ =& \frac{\sqrt{3}}{2} (\frac{\sqrt{6}\sqrt{2}}{4 \times 2}+\frac{\sqrt{6}\sqrt{2}}{4 \times 2}) + \frac{1}{2} (\frac{\sqrt{2}\sqrt{2}}{4 \times 2} + \frac{\sqrt{2}\sqrt{2}}{4 \times 2}) \\ =& \frac{\sqrt{3}}{2} (\frac{\sqrt{2\times3\times2}}{4}) + \frac{1}{2} (\frac{2}{4}) \\ =& \frac{\sqrt{3}}{2} (\frac{2\sqrt{3}}{4}) + \frac{1}{2} (\frac{1}{2}) \\ =& \frac{3}{4} + \frac{1}{4} = 1 \\ \end{aligned}$$ Now, proceed to verify that $RR^T=I$. $$\begin{aligned} RR^T &= \begin{bmatrix} \frac{\sqrt{3}}{2} & -\frac{1}{2} & 0 \\ \frac{\sqrt{2}}{4} & \frac{\sqrt{6}}{4} & -\frac{\sqrt{2}}{2} \\ \frac{\sqrt{2}}{4} & \frac{\sqrt{6}}{4} & \frac{\sqrt{2}}{2} \\ \end{bmatrix} \begin{bmatrix} \frac{\sqrt{3}}{2} & \frac{\sqrt{2}}{4} & \frac{\sqrt{2}}{4} \\ -\frac{1}{2} & \frac{\sqrt{6}}{4} & \frac{\sqrt{6}}{4} \\ 0 & -\frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2} \\ \end{bmatrix} \\\\ &= \begin{bmatrix} \frac{\sqrt{3}}{2}\frac{\sqrt{3}}{2} + \frac{1}{2}\frac{1}{2} & \frac{\sqrt{3}}{2}\frac{\sqrt{2}}{4} - \frac{1}{2}\frac{\sqrt{6}}{4} & \frac{\sqrt{3}}{2}\frac{\sqrt{2}}{4} - \frac{1}{2}\frac{\sqrt{6}}{4} \\ \frac{\sqrt{2}}{4}\frac{\sqrt{3}}{2} - \frac{\sqrt{6}}{4}\frac{1}{2} & \frac{\sqrt{2}}{4}\frac{\sqrt{2}}{4} + \frac{\sqrt{6}}{4}\frac{\sqrt{6}}{4} + \frac{\sqrt{2}}{2}\frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{4}\frac{\sqrt{2}}{4} + \frac{\sqrt{6}}{4}\frac{\sqrt{6}}{4} - \frac{\sqrt{2}}{2}\frac{\sqrt{2}}{2} \\ \frac{\sqrt{2}}{4}\frac{\sqrt{3}}{2} - \frac{\sqrt{6}}{4}\frac{1}{2} & \frac{\sqrt{2}}{4}\frac{\sqrt{2}}{4} + \frac{\sqrt{6}}{4}\frac{\sqrt{6}}{4} - \frac{\sqrt{2}}{2}\frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{4}\frac{\sqrt{2}}{4} + \frac{\sqrt{6}}{4}\frac{\sqrt{6}}{4} + \frac{\sqrt{2}}{2}\frac{\sqrt{2}}{2} \\ \end{bmatrix} \\\\ &= \begin{bmatrix} \frac{3}{4} + \frac{1}{4} & \frac{\sqrt{6}}{8} - \frac{\sqrt{6}}{8} & \frac{\sqrt{6}}{8} - \frac{\sqrt{6}}{8} \\ \frac{\sqrt{6}}{8} - \frac{\sqrt{6}}{8} & \frac{2}{16} + \frac{6}{16} + \frac{8}{16} & \frac{2}{16} + \frac{6}{16} - \frac{8}{16} \\ \frac{\sqrt{6}}{8} - \frac{\sqrt{6}}{8} & \frac{2}{16} + \frac{6}{16} - \frac{8}{16} & \frac{2}{16} + \frac{6}{16} + \frac{8}{16} \\ \end{bmatrix} \\\\ &= \begin{bmatrix}1&0&0\\0&1&0\\0&0&1\\\end{bmatrix} = I \\ \end{aligned}$$