The Matrix

The matrix over the solid P is a representation of $\left\{1, 2, \ldots, n\right\} \times \left\{1, 2, \ldots, m\right\} \rightarrow P$. The matrix is usually denoted by capital letters: A = (…). And now in Czech.

Basic concepts

A matrix is, in short, a kind of table with n columns and m rows, and this labeling of rows and columns may not always be the same, beware. Each cell of the table then contains some number or other expression. The matrix need not be purely numeric, although you are quite likely not to encounter other matrices at first. So what might a matrix look like:

$$A=\left(\begin{array}{ccc}0&1&5\\8&5&51\end{array}\right)$$

This matrix has two rows and three columns. The elements of the matrix are denoted by indices, and a lower case letter is used instead of a capital letter: a11 = 0 or a23 = 51. The first index indicates the row and the second index the column.

Special matrix types

Matrices can have different properties and some special matrices even have their own names.

Asquare matrix is a matrix that has the same number of rows as columns. If a matrix is not square, it is rectangular. Example of a square matrix:

$$A=\left(\begin{array}{ccc}0&1&5\\8&5&23\\47&154&2\end{array}\right)$$

Azero matrix is a matrix that has zeros in all positions. aij = 0.

$$A=\left(\begin{array}{ccc}0&0&0\\0&0&0\\0&0&0\end{array}\right)$$

A unit matrix is a square matrix that has ones on the main diagonal and zeros everywhere else. The main diagonal is like a "diagonal" from left to right. In short, it's the numbers on the coordinates where the i = j.

$$A=\left(\begin{array}{ccc}1&0&0\\0&1&0\\0&0&1\end{array}\right)$$

Astaircase matrix is a matrix that has zero rows at the end (or no zero rows) and each non-zero row has more zeros at the beginning than the previous row. These are all staircase matrices:

$$A_1=\left(\begin{array}{ccc}1&0&0\\0&1&\pi\\0&0&1\end{array}\right), \quad A_2=\left(\begin{array}{ccc}1&0&0\\0&1&0\\0&0&1\\0&0&0\\0&0&0\end{array}\right),\quad A_3=\left( \begin{array}{ccccc} 1& 1& 1& 1& 8\\ 0& 0& 0& 5& 1\\ 0 &0& 0& 0 &5 \end{array}\right)$$

A matrix transposed to matrix A is a matrix AT, for which $a_{ij} = a^T_{ji}$ holds, i.e., the element that was in i-th row and j-th column will be in j-th row and i-th column in the transposed matrix. In short, you swap the rows of the matrix for columns.

$$\begin{eqnarray} \left(\begin{array}{ccc}0&1&5\\8&5&23\\47&154&2\end{array}\right)^T &=& \left(\begin{array}{ccc}0&8&47\\1&5&154\\5&23&2\end{array}\right)\\ \left(\begin{array}{ccc}3&4&5\\6&7&8\end{array}\right)^T&=&\left(\begin{array}{cc}3&6\\4&7\\5&8\end{array}\right) \end{eqnarray}$$

A symmetric matrix is a square matrix A, which satisfies the equality A = AT. The elements symmetric on the diagonal are the same. So we can write that $a_{ij}=a_{ji}$.

$$A=\left(\begin{array}{ccc}9&3&4\\3&7&0\\4&0&2\end{array}\right)$$

An antisymmetric matrix is almost the same as a symmetric matrix, except that the elements on the other side have opposite signs: A = −AT. Because of this, the elements on the main diagonal must be zero, because a = −a = 0.

$$A=\left(\begin{array}{ccc}0&-3&-4\\3&0&5\\4&-5&0\end{array}\right)$$

Adiagonal matrix is a matrix that has zeros everywhere except on the main diagonal. More precisely, there must be zeros everywhere else, what is on the main diagonal is not specified.

$$A_1=\left(\begin{array}{ccc}9&0&0\\0&7&0\\0&0&2\end{array}\right), \quad A_2=\left(\begin{array}{ccc}3&0&0\\0&0&0\\0&0&0\end{array}\right)$$

Basic matrix operations

We can add matrices, we can multiply matrices by a number, and we can multiply matrices by each other.

Adding matrices is fairly intuitive. If the matrices are of the same type (= same number of columns and rows), the resulting matrix will have the sums of the numbers in the corresponding positions in the previous matrices. Or if we add the matrices A + B = C, then $a_{ij} + b_{ij} = c_{ij}$ holds.

$$\left(\begin{array}{ccc}0&1&5\\8&5&23\\47&154&2\end{array}\right) + \left(\begin{array}{ccc}5&4&3\\10&20&30\\7&-54&-12\end{array}\right) = \left(\begin{array}{ccc}5&5&8\\18&25&53\\54&100&-10\end{array}\right)$$

The addition of matrices is obviously commutative and associative. A + B = B + A and A + (B + C) = (A + B) + C.

Multiplying matrices by a number is also intuitive. You take a number and multiply each element of the matrix with it, nothing more. k · A = k · aij.

$$5\cdot \left(\begin{array}{ccc}0&1&5\\8&5&23\\47&154&2\end{array}\right) = \left(\begin{array}{ccc}0&5&25\\40&25&115\\235&770&10\end{array}\right)$$

Multiplying matrices

Multiplying matrices is a bit of a worse affair, because it is no longer intuitive as one would expect. It's not enough just to multiply the corresponding terms. First of all, the matrix must satisfy the criterion that the number of columns of the first matrix must be the same as the number of rows of the second matrix. The rest can be arbitrary. Now we can define the product (n is the number of columns of the first matrix):

$$(A\cdot B)_{ij}=\sum_{p=1}^{n}a_{ip}\cdot b_{pj}$$

You know that much, don't you? Now I'll try to explain it to the less bright :-). You take the first row of the first matrix and the first column of the second matrix. Now, you multiply the first element with the first element and add it with the multiplication of the second element with the second element and add, etc. This gives you the element c11 in the new matrix C. The very best example will be. Multiply the two matrices:

$$A=\left(\begin{array}{cc}1&2\\3&4\end{array}\right), B=\left(\begin{array}{cc}5&6\\7&8\end{array}\right)$$

Now select the first row of the first matrix and the first column of the second matrix:

$$A=\left(\begin{array}{cc}\fbox{1}&\fbox{2}\\3&4\end{array}\right), B=\left(\begin{array}{cc}\fbox{5}&6\\\fbox{7}&8\end{array}\right)$$

For ease of notation, we will label the newly formed matrix C. To get the first element of this matrix, we need to calculate the following: $c_{11} = a_{11}\cdot b_{11} + a_{12}\cdot b_{21}$. Note that the row comes first in the index, then the column. After substitution, we get: 1 · 5 + 2 · 7 = 19. The first element has the value 19:

$$C=\left(\begin{array}{cc}19&?\\?&?\end{array}\right)$$

The next element, c12, is obtained in the same way, but we take the first row and the second column. This lengthy calculation always yields the element they have in common. The first row and the first column have a common element at the coordinates c11, the first row and the second column again c12. The following figure shows this nicely:

Product of matrices

Now I'll just quickly multiply the rest of the matrix:

$$\begin{eqnarray} c_{12} &=& a_{11} \cdot b_{12} + a_{12} \cdot b_{22} = 1 \cdot 6 + 2 \cdot 8 = 22.\\ c_{21} &=& a_{21} \cdot b_{11} + a_{22} \cdot b_{21} = 3 \cdot 5 + 4 \cdot 7 = 43.\\ c_{22} &=& a_{21} \cdot b_{12} + a_{22} \cdot b_{22} = 3 \cdot 6 + 4 \cdot 8 = 50. \end{eqnarray}$$

Just write these numbers into the matrix:

$$C=\left(\begin{array}{cc}19&22\\43&50\end{array}\right)$$

We can check the correctness of the result in Excel or OpenOffice Calc, which contain functions for working with matrices. You can also use the interactive online matrix multiplication calculator.

Now some general information about matrix multiplication. First of all, matrix multiplication is not commutative. It is generally not true that A · B = B · A, although of course this can be the case. But matrix multiplication is associative. It is even distributive with addition: A (B + C) = AB + AC. If we multiply two matrices $a_{ix}\cdot b_{xn}$, then the resulting matrix will be of type i × n (it will have as many rows as the first matrix has rows and as many columns as the second matrix has columns).

Examples

We are given the following three matrices:

$$A=\left(\begin{array}{ccc}1&2&3\\4&5&6\\7&8&9\end{array}\right),,B=\left(\begin{array}{ccc}4&2&8\\10&12&4\\4&5&9\end{array}\right),,C=\left(\begin{array}{cc}8&9\\-5&4\\10&-1\end{array}\right).$$

Do the product of the matrices A · B.

$$\left(\begin{array}{ccc}1&2&3\\4&5&6\\7&8&9\end{array}\right)\cdot \left(\begin{array}{ccc}4&2&8\\10&12&4\\4&5&9\end{array}\right) = \left(\begin{array}{ccc}36&41&43\\90&98&106\\144&155&169\end{array}\right)$$

Perform the product of the matrices B · A.

Note that matrix multiplication is not commutative, so we certainly cannot say with certainty that the result will be the same as in the previous example. We simply have to calculate it all over again:

$$\left(\begin{array}{ccc}4&2&8\\10&12&4\\4&5&9\end{array}\right) \cdot \left(\begin{array}{ccc}1&2&3\\4&5&6\\7&8&9\end{array}\right) = \left(\begin{array}{ccc}68&82&96\\86&112&138\\87&105&123\end{array}\right)$$

Do the product of the matrices A · C and C · B.

$$\left(\begin{array}{ccc}1&2&3\\4&5&6\\7&8&9\end{array}\right)\cdot\left(\begin{array}{cc}8&9\\-5&4\\10&-1\end{array}\right) = \left(\begin{array}{cc}28&14\\67&50\\106&86\end{array}\right)$$

We cannot calculate the second example because the number of columns of the first matrix is different from the number of rows of the second matrix.

Basic matrix adjustments

In order to work efficiently with matrices, we need to define some elementary matrix adjustments. First, we can multiply the row/column of the matrix by some number other than zero. The multiplication will appear the same as k-multiply matrix, but only in that row/column.

The second modification is to add k-times j-that row to i-that row. Same for the columns. Sounds a bit scary, but it's actually simple. Let's demonstrate this for k = 1. We'll have this matrix:

$$\left(\begin{array}{ccc}1&2&3\\4&5&6\\7&8&9\end{array}\right)$$

Now add the second row to the first row. So we take the second row and add the numbers in the equivalent positions to the numbers in the first row. Nothing happens to the numbers in the second row, only the first row changes:

$$\left(\begin{array}{ccc}5&7&9\\4&5&6\\7&8&9\end{array}\right)$$

Now we can continue with the modifications. Now let's try adding twice the first line to the third line. Take the first row out of this newly created matrix, multiply it by two to get the row (10, 14, 18) and add these numbers to the third row. Again - the first row will not change, only the third row will change:

$$\left(\begin{array}{ccc}5&7&9\\4&5&6\\17&22&27\end{array}\right)$$

Now add the sum of the first and second lines to the third line again. Basically, this is nothing new, because if we add first the second row and then the first row to the third row, we must arrive at the same result. The sum of the first and second rows will be equal: (5, 7, 9) + (4, 5, 6) = (9, 12, 15). The sum of this line with the third line will then be equal to: (9, 12, 15) + (17, 22, 27) = (26, 34, 42).

$$\left(\begin{array}{ccc}5&7&9\\4&5&6\\26&34&42\end{array}\right)$$

And one more column adjustment (these are usually not used that often because they are not as clear). Let's add the first column to the second column:

$$\left(\begin{array}{ccc}5&12&9\\4&9&6\\26&60&42\end{array}\right)$$

And for the very last time, multiply the second row by two:

$$\left(\begin{array}{ccc}5&12&9\\8&18&12\\26&60&42\end{array}\right)$$

Linear dependence

Now let's explain what dependent rows/columns are. A row is linearly dependent if that row can be expressed as a linear combination of the other rows of the matrix. In short, if you are able to add rows in different ways so that you end up with the row you are looking for, that row is linearly dependent. Example:

$$\left(\begin{array}{ccc}1&2&3\\4&5&6\\6&9&12\end{array}\right)$$

If you take twice the first row and the second row, you get the third row. If you subtract this combination from the third row, you get a zero row (a row containing all zeros). This row is dependent. So we make the adjustment as follows (multiply the first row by two, add to the second row, subtract from the third row):

$$\left(\begin{array}{ccc}1&2&3\\4&5&6\\6&9&12\end{array}\right)\sim \begin{pmatrix}2&4&6\\4&5&6\\6&9&12\end{pmatrix}\sim \begin{pmatrix}2&4&6\\6&9&12\\6&9&12\end{pmatrix}\sim \begin{pmatrix}2&4&6\\6&9&12\\0&0&0\end{pmatrix}$$

If we have a matrix A, which has n rows and Ai denotes the i-th row, then we say that the matrix does not contain a linearly dependent row if:

$$\alpha_1A_1+\alpha_2A_2+\ldots+\alpha_nA_n={\bf 0}$$

just when α1, α2, …, αn = 0. The zero on the right-hand side of the equation represents the zero row. That is, if the only solution to this equation is the zero solution. If we find another solution, then the matrix contains a linearly dependent row. Similarly for the column. For the previous matrix, the following would be true:

$$\begin{eqnarray} &&2\begin{pmatrix}1&2&3\end{pmatrix}+1\begin{pmatrix}4&5&6\end{pmatrix}-1\begin{pmatrix}6&9&12\end{pmatrix}=\\ &&=\begin{pmatrix}6&9&12\end{pmatrix}-\begin{pmatrix}6&9&12\end{pmatrix}=\begin{pmatrix}0&0&0\end{pmatrix} \end{eqnarray}$$

Thus, the alpha values are α1 = 2, α2 = 1, α3 = −1.

The number of independent rows or columns indicates the rank of the matrix.

Regular and singular matrices

A matrix is called regular if it has maximum rank (i.e., if there are no linearly dependent rows) and if it is a square matrix. A square matrix is called singular if it is not regular (i.e., if the matrix contains at least one linearly dependent row). These two concepts are quite important, or rather often have some definitions based on them. A lot of things are defined only if the matrix is regular.