Matrices
TL;DR - What should you know?
- Matrices are specified by their number of rows and columns
- Vectors are matrices with one column
- How do you add/subtract matrices?
- How do you scale a matrix by some factor ?
- How do you multiply two matrices?
- What is a transposed matrix?
- What is the identity matrix?
- What is a matrix inverse?
For matrices, we just go over a few points.
A bit more intuition about parts of matrices will be added later, but for our purposes, it is enough to consider them just a tool to write down equations succinctly.
A matrix is a table of values. Matrices will be written capitalized in bold-face, for example .
A matrix has two dimensions, the number of rows and the number of cols. The number of rows is specified first.
The following is an example of a matrix:
You can also usually see the following way of writing: . This just means: "The matrix is an element of the space of matrices of size with real numbers as entries.
And a vector is just a matrix with one column, so a matrix!
You can transpose a matrix. This just means, you mirror the matrix at its diagonal. You can also just remember, that a matrix element gets put at the position (so the diagonal stays the same). The number of rows and columns is also swapped out by this operations.
The transpose of a matrix is written as .
There are some additional ways to write a matrix, which sometimes make the intent clearer. Instead of specifying every single element, we could make a matrix out of a number of columns (each is a vector!):
Similarly, we could write down the rows. To still use vectors, we need to convert a column to a row, which is what the transpose operation does.
Addition and subtraction are performed element-wise. It makes sense then, that both matrices have to be the same size for that.
Multiplication is slightly more involved, but for now we will just write down one easy to remember version to write it.
First, a multiplication from the left side of a matrix with a vector :
The result will be a vector with rows. For the dot products to make sense, needs to have columns, where is the size of the vector.
With that, you can also calculate the product of two matrices, by just thinking about the right matrix as a number of columns.
For this to work, the columns of the first matrix need to match the rows of the second. A matrix times a matrix results in a matrix.
This means, that not every matrix can be multiplied with any other one. This also means, we can't in general switch the order of multiplications. Even if the dimensions match, in general the following holds:
This will be important when transforming objects in space.
We can also see from this notation, that the dot product seems to have some kind of connection to this. Sometimes, it is useful to "convert" a dot product of two vectors to matrix notation.
This multiplies a matrix with a matrix, resulting in a matrix, so just a number!
One special matrix is the so called identity matrix. We will write it as . This matrix is square and has dimension , so it is a matrix. If the dimension doesn't matter, we just write .
It has 1s on the diagonal and 0s everywhere else.
If the dimensions match, the identity matrix leaves any matrix unmodified (like multiplying by ):
With numbers, we can write . We say that is the inverse of which when multiplied makes it .
For matrices we have something similar and it is also called inverse. When multiplied with a matrix, it results in the identity matrix. We write the inverse of as .
For this to be defined properly, it only exists for square matrices. And similar to numbers, where does not have an inverse, there are matrices that do not have an inverse.
Sometimes, you might also see the notation , which is just a shorthand for . Both sides of the equation are equivalent.
We don't need to consider the specifics here.
This concludes our very brief overview of the necessary information about matrices.