A.2 Matrix Algebra
One-by-One Matrices
Let us motivate what we want to achieve with matrices. Real-valued linear mappings of the real line, linear functions that eat numbers and spit out numbers, are just multiplications by a number. Consider a mapping defined by multiplying by a number. Let’s call this number . The mapping then takes to . We can add such mappings: If we have another mapping , then
We get a new mapping that multiplies by, well, . If is a mapping that doubles its input, , and is a mapping that triples, , then is a mapping that multiplies by , .
Similarly we can compose such mappings, that is, we could apply one and then the other. We take , we run it through the first mapping to get times , then we run through the second mapping . In other words,
We just multiply those two numbers. Using our doubling and tripling mappings, if we double and then triple, that is then we obtain . The composition is the mapping that multiplies by . For larger matrices, composition also ends up being a kind of multiplication.
Matrix Addition and Scalar Multiplication
The mappings that multiply numbers by numbers are just matrices. The number above could be written as a matrix . Perhaps we would want to do to all matrices the same things that we did to those matrices at the start of this section above. First, let us add matrices. If we have a matrix and a matrix that are of the same size, say , then they are mappings from to . The mapping should also be a mapping from to , and it should do the following to vectors:
It turns out you just add the matrices element-wise: If the entry of is , and the entry of is , then the entry of is . If
thenLet us illustrate on a more concrete example:
Let’s check that this does the right thing to a vector. Let’s use some of the vector algebra that we already know, and regroup things:
If we replaced the numbers by letters that would constitute a proof! You’ll notice that we didn’t really have to even compute what the result is to convince ourselves that the two expressions were equal.
If the sizes of the matrices do not match, then addition is not defined. If is and is , then we cannot add these matrices. We don’t know what that could possibly mean.
It is also useful to have a matrix that when added to any other matrix does nothing. This is the zero matrix, the matrix of all zeros:
We often denote the zero matrix by without specifying size. We would then just write , where we just assume that is the zero matrix of the same size as .
There are really two things we can multiply matrices by. We can multiply matrices by scalars or we can multiply by other matrices. Let us first consider multiplication by scalars. For a matrix and a scalar , we want to be the matrix that accomplishes
That is just scaling the result by . If you think about it, scaling every term in by achieves just that: If
For example,
Let us list some properties of matrix addition and scalar multiplication. Denote by the zero matrix, by , scalars, and by , , matrices. Then:
These rules should look very familiar.Matrix Multiplication
As we mentioned above, composition of linear mappings is also a multiplication of matrices. Suppose is an matrix, that is, takes to , and is an matrix, that is, takes to . The composition should work as follows
First, a vector in gets taken to the vector in . Then the mapping takes it to the vector in . In other words, the composition should be an matrix. In terms of sizes we should have
Notice how the middle size must match.
OK, now we know what sizes of matrices we should be able to multiply, and what the product should be. Let us see how to actually compute matrix multiplication. We start with the so-called dot product (or inner product) of two vectors. Usually this is a row vector multiplied with a column vector of the same size. Dot product multiplies each pair of entries from the first and the second vector and sums these products. The result is a single number. For example,
And similarly for larger (or smaller) vectors. A dot product is really a product of two matrices: a matrix and an matrix resulting in a matrix, that is, a number.Armed with the dot product we define the product of matrices. We denote by the row of and by the column of . For an matrix and an matrix we can compute the product : The matrix is an matrix whose entry is the dot product
For example, given a and a matrix we should end up with a matrix:
A useful consequence of the definition is that the evaluation for a matrix and a (column) vector is also matrix multiplication. That is really why we think of vectors as column vectors, or matrices. For example,
If you look at the last section, that is precisely the last example we gave.You should stare at the computation of multiplication of matrices and the previous definition of as a mapping for a moment. What we are doing with matrix multiplication is applying the mapping to the columns of . This is usually written as follows. Suppose we write the matrix , where are the columns of . Then for an matrix ,
The columns of the matrix are the vectors . For example, in (9.2.1), the columns of
are This is a very useful way to understand what matrix multiplication is. It should also make it easier to remember how to perform matrix multiplication.Rules of Matrix Algebra
For multiplication we want an analogue of a 1. That is, we desire a matrix that just leaves everything as it found it. This analogue is the so-called identity matrix. The identity matrix is a square matrix with 1s on the main diagonal and zeros everywhere else. It is usually denoted by . For each size we have a different identity matrix and so sometimes we may denote the size as a subscript. For example, is the identity matrix
Let us see how the matrix works on a smaller example, Multiplication by the identity from the left looks similar, and also does not touch anything.We have the following rules for matrix multiplication. Suppose that , , are matrices of the correct sizes so that the following make sense. Let denote a scalar (number). Then
A multiplication rule, one you have used since primary school on numbers, is quite conspicuously missing for matrices. That is, matrix multiplication is not commutative. Firstly, just because makes sense, it may be that is not even defined. For example, if is , and is , the we can multiply but not .
Even if and are both defined, does not mean that they are equal. For example, take and :
Inverse
A couple of other algebra rules you know for numbers do not quite work on matrices:
- does not necessarily imply , even if is not 0.
- does not necessarily mean that or .
For example:
To make these rules hold, we do not just need one of the matrices to not be zero, we would need to by a matrix. This is where the matrix inverse comes in. Suppose that and are matrices such that
Then we call the inverse of and we denote by . Perhaps not surprisingly, , since if the inverse of is , then the inverse of is . If the inverse of exists, then we say is invertible. If is not invertible, we say is singular.
If is a matrix, then is . That is where the notation comes from. The computation is not nearly as simple when is larger.
The proper formulation of the cancellation rule is:
If is invertible, then implies .
The computation is what you would do in regular algebra with numbers, but you have to be careful never to commute matrices:
And similarly for cancellation on the right:If is invertible, then implies .
The rule says, among other things, that the inverse of a matrix is unique if it exists: If , then is invertible and .
We will see later how to compute an inverse of a matrix in general. For now, let us note that there is a simple formula for the inverse of a matrix
For example: Let’s try it: Just as we cannot divide by every number, not every matrix is invertible. In the case of matrices however we may have singular matrices that are not zero. For example, is a singular matrix. But didn’t we just give a formula for an inverse? Let us try it: We get into a bit of trouble; we are trying to divide by zero.So a matrix is invertible whenever
and otherwise it is singular. The expression is called the determinant and we will look at it more carefully in a later section. There is a similar expression for a square matrix of any size.Diagonal Matrices
A simple (and surprisingly useful) type of a square matrix is a so-called diagonal matrix. It is a matrix whose entries are all zero except those on the main diagonal from top left to bottom right. For example a diagonal matrix is of the form
Such matrices have nice properties when we multiply by them. If we multiply them by a vector, they multiply the entry by . For example, Similarly, when they multiply another matrix from the left, they multiply the row by . For example, On the other hand, multiplying on the right, they multiply the columns: And it is really easy to multiply two diagonal matrices together—we multiply the entries: For this last reason, they are easy to invert, you simply invert each diagonal element: Let us check an example It is no wonder that the way we solve many problems in linear algebra (and in differential equations) is to try to reduce the problem to the case of diagonal matrices.Transpose
Vectors do not always have to be column vectors, that is just a convention. Swapping rows and columns is from time to time needed. The operation that swaps rows and columns is the so-called transpose. The transpose of is denoted by . Example:
Transpose takes an matrix to an matrix.A key feature of the transpose is that if the product makes sense, then also makes sense, at least from the point of view of sizes. In fact, we get precisely the transpose of . That is:
For example, It is left to the reader to verify that computing the matrix product on the left and then transposing is the same as computing the matrix product on the right.If we have a column vector to which we apply a matrix and we transpose the result, then the row vector applies to from the left:
Another place where transpose is useful is when we wish to apply the dot productto the power 1 to two column vectors: That is the way that one often writes the dot product in software.We say a matrix is symmetric if . For example,
is a symmetric matrix. Notice that a symmetric matrix is always square, that is, . Symmetric matrices have many nice propertiessquared, and come up quite often in applications.Footnotes
[1] As a side note, mathematicians write and physicists write . Shhh…don’t tell anyone, but the physicists are probably right on this.
[2] Although so far we have not learned enough about matrices to really appreciate them.
Adapted from Differential Equations for Engineers by Jiří Lebl (Oklahoma State University), hosted on LibreTexts (math.libretexts.org) and licensed under CC BY-SA 4.0. Changes were made. License: CC-BY-SA-4.0.