How to operate with matrices

Matrices are considered equal if they have the same dimensions and if each element of one matrix is equal to the corresponding element of the other matrix. You may multiply a matrix by any constant, this is called scalar multiplication.


Example

$$2\begin{bmatrix} 1 & 2\\ 3 & 4 \end{bmatrix}= \begin{bmatrix} {\color{green} 2}\cdot 1 & {\color{green} 2}\cdot2\\ {\color{green} 2}\cdot3 & {\color{green} 2}\cdot4 \end{bmatrix} = \begin{bmatrix} 2 & 4\\ 6 & 8 \end{bmatrix}$$

Matrices of the same size can be added and subtracted entry wise and matrices of compatible sizes can be multiplied.


Example

Add the two matrices A and B:

$$A=\begin{bmatrix} {\color{green} 2} & {\color{green} -1}\\ {\color{green} 1} & {\color{green} 0} \end{bmatrix}B=\begin{bmatrix} {\color{blue} 1} & {\color{blue} 4} \\ {\color{blue} 2} & \,{\color{blue} 3} \end{bmatrix}$$

This is possible since A and B since both matrices have two rows and two columns. We add each element in matrix A to the corresponding element in matrix B:

$$A+B=\begin{bmatrix} {\color{green} 2}+{\color{blue} 1} & {\color{green} -1}+{\color{blue} 4} \\ {\color{green} 1}+{\color{blue} 2} & {\color{green} 0}+\,{\color{blue} 3} \end{bmatrix}=\begin{bmatrix} 3 & 3\\ 3 & 3 \end{bmatrix}$$

One subtracts matrices in the same way.

If you multiply the matrix Ap*q and the matrix Bm*n the product is

$$A_{p\times q}+B_{m\times n}=(AB)_{p\times n}$$

The element in the g-th row and the h-th column of AB is the sum of the product of the corresponding elements in the g-th row of A and the h-th column of B. You may only multiply two matrices if the number of columns in the first matrix and the number of rows in the second are equal.


Example

Multiply the matrices A and B:

$$A=\begin{bmatrix} {\color{green} 1} & {\color{green} 3}\\ {\color{green} -1} & {\color{green} 0} \end{bmatrix}B=\begin{bmatrix} {\color{blue} 2} & {\color{blue} 1} & {\color{blue} 1}\\ {\color{blue} -1} & {\color{blue} 2}&{\color{blue} 4} \end{bmatrix}$$

This is possible since the first matrix contains 2 columns and the second contains 2 rows.

$$\\ AB=\begin{bmatrix} {\color{green} 1}\cdot {\color{blue} 2}+{\color{green} 3}\cdot {\color{blue} -1} &{\color{green} 1}\cdot {\color{blue} 1}+{\color{green} 3}\cdot {\color{blue} 2} &{\color{green} 1}\cdot {\color{blue} 1}+{\color{green} 3}\cdot {\color{blue} 4} \\ {\color{green} -1}\cdot {\color{blue} 2}+{\color{green} 0}\cdot {\color{blue} -1} &{\color{green} -1}\cdot {\color{blue} 1}+{\color{green} 0}\cdot {\color{blue} 2} & {\color{green} -1}\cdot {\color{blue} 1}+{\color{green} 0}\cdot {\color{blue} 4} \end{bmatrix}=\\ \\ =\begin{bmatrix} -1 & 7 & 13\\ -2 & -1 & -1 \end{bmatrix}$$


Video lesson

If possible then perform the indicated operation:

$$\begin{bmatrix} 2 &0 \\ 1&3 \\ -4&1 \end{bmatrix}\cdot \begin{bmatrix} 6 &2 & 3\\ 0& -2 & 4 \end{bmatrix}$$