\(\newcommand{\augmatrix}[2]{\left(\begin{array}{@{}#1 |c@{}} #2 \end{array}\right)} \newcommand{\lt}{ < } \newcommand{\gt}{ > } \newcommand{\amp}{ & } \)

Section1.4Matrices

SubsectionThe Assignment

  • Read Strang section 1.3 (pages 22-27).
  • Watch another entry from the YouTube video series Essence of Linear Algebra by 3Blue1Brown
  • Read the following and complete the exercises below.

SubsectionLearning Goals

Before class starts, a student should be able to:

  • multiply a matrix times a vector
    • as a linear combination of columns
    • as a set of dot products, row times column
  • translate back and forth between our three representations
    • a system of linear equations,
    • a linear combination of vectors equation, and
    • a matrix equation \(Ax=b\).
  • Correctly identify the rows and columns of a matrix
  • describe what is meant by a lower triangular matrix
At some point, as student should be comfortable with these concepts, which get a very brief informal introduction in this section:
  • linear dependence and linear independence
  • the inverse of a matrix

SubsectionDiscussion

A matrix is a two-dimensional array of numbers like this:\begin{equation*} A = \begin{pmatrix} 2 & 1 \\ 1 & 1 \end{pmatrix}. \end{equation*} Sometimes it helps to think of a matrix as a collection of its rows which are read across:\begin{equation*} M = \begin{pmatrix} \longrightarrow \\ \longrightarrow \end{pmatrix} \end{equation*} and sometimes it helps to think of a matrix as a collection of its columns which are read down:\begin{equation*} M = \begin{pmatrix} \downarrow & \downarrow \end{pmatrix}. \end{equation*}

It is often more clear to describe a matrix by giving the sizes of its rows and columns. An \(m\) by \(n\) matrix is one having \(m\) rows and \(n\) columns. It is really easy to get these reversed, so be careful. For example, this is a \(2\times 3\) matrix, because it has two rows and three columns:\begin{equation*} B = \begin{pmatrix} 1 & 1 & 2 \\ 3 & 5 & 8 \end{pmatrix} \end{equation*} A matrix is called a square matrix when the number of rows and the number of columns is equal. The matrix \(A\) that I wrote down above is square because it is a \(2\times 2\) matrix.

SubsubsectionMultiplying Matrices and Vectors

It is possible to multiply a matrix by a vector like this:\begin{equation*} \begin{pmatrix} 1 & 1 & 2 \\ 3 & 5 & 8 \end{pmatrix} \begin{pmatrix} 13 \\ 21 \\ 34 \end{pmatrix} = \begin{pmatrix} 102 \\ 416 \end{pmatrix} \end{equation*} For this to work, it is absolutely crucial that the sizes match up properly. If the matrix is \(m\) by \(n\), then the vector must have size \(n\). In the above example \(m = 2\) and \(n=3\).

Later, we shall see that the word "multiplication" is not really the best choice here. It is better to think of the matrix as "acting on" the vector and turning it into a new vector. For now, the word multiplication will serve.

How exactly does one define this matrix--vector multiplication?

Linear Combination of Columns Approach

The first way to perform the matrix-vector multiplication is to think of the vector as holding some coefficients for forming a linear combination of the columns of the matrix. In our example, it looks like this:\begin{equation*} \begin{pmatrix} 1 & 1 & 2 \\ 3 & 5 & 8 \end{pmatrix} \begin{pmatrix} 13 \\ 21 \\ 34 \end{pmatrix} = 13 \begin{pmatrix} 1 \\ 3 \end{pmatrix} + 21 \begin{pmatrix} 1 \\ 5 \end{pmatrix} + 34 \begin{pmatrix} 2 \\ 8 \end{pmatrix} = \begin{pmatrix} 102 \\ 416 \end{pmatrix} \end{equation*}

Dot Products with the Rows Approach

The second way is to think of the matrix as a bundle of vectors lying along the rows of the matrix, and use the dot product. In our example above, this means that we consider the vectors\begin{equation*} r_1 = \begin{pmatrix} 1 \\ 1 \\ 2 \end{pmatrix}, \quad r_2 = \begin{pmatrix} 3 \\ 5 \\ 8 \end{pmatrix}, \text{ and } v = \begin{pmatrix} 13 \\ 21 \\ 34 \end{pmatrix} \end{equation*} (notice I've rewritten the rows as columns) and then perform this kind of operation:\begin{equation*} \begin{pmatrix} 1 & 1 & 2 \\ 3 & 5 & 8 \end{pmatrix} \begin{pmatrix} 13 \\ 21 \\ 34 \end{pmatrix} = \begin{pmatrix} r_1 \\ r_2 \end{pmatrix} v = \begin{pmatrix} r_1 \cdot v \\ r_2 \cdot v \end{pmatrix} = \begin{pmatrix} 102 \\ 416 \end{pmatrix} . \end{equation*}

Two important remarks:

  • Note that these operations only make sense if the sizes match up properly.
  • Note that the two versions of the operation give you the same results.

SubsubsectionMatrix Equations

There are many situations in linear algebra that can be rewritten in the form of an equation that looks like this:\begin{equation*} A v = b \end{equation*} where \(A\) is a matrix, and \(v\) and \(b\) are vectors. The interesting case is when we know \(A\) and \(b\), but we want to find the unknown \(v\). We will call this a matrix-vector equation.

Let's consider the case where you are given some square matrix \(A\). Sometimes one can find another matrix \(B\) so that no matter what vector \(b\) is chosen in the matrix-vector equation above, the solution vector takes the form \(v = Bb\). When this happens, we say that \(A\) is invertible and call \(B\) the inverse of \(A\). It is common to use the notation \(A^{-1}\) in place of \(B\). This is a wonderful situation to be in! Eventually, we will want to figure out some test for when a given matrix is invertible, and find some ways to compute the inverse.

SubsubsectionA Note about Vectors

This reading also has a brief introduction to the idea of a set of vectors being linearly depedent or linearly independent. Strang is coy about the precise definition, so here it is:

A set of vectors \(v_1, v_2, \dots, v_n\) is called linearly depdendent when there is some choice of numbers \(a_1, a_2, \dots, a_n\) which are not all zero so that the linear combination\begin{equation*} a_1 v_1 + a_2 v_2 + \dots + a_n v_n = 0 \end{equation*} A set of vectors which is not linearly dependent is called linearly independent.

This is a little funny the first time you read it. Note that for any set of vectors, you can make a linear combination of those vectors come out as \(0\). Simply choose all of the coefficients to be zero. But that is so easy to do we call it trivial. What the definition is asking is that we find a nontrival linear combination of the vectors to make zero.

SubsectionSageMath and Matrices

SageMath has many useful commands for working with linear algebra, and given the central role played by matrices in this subject, there are lots of things SageMath can do with matrices. We'll focus here on just basic construction and matrix--vector multiplication.

SubsubsectionThe matrix construction command

The command to construct a matrix is pretty straightforward. One types matrix(r, c, [list of entries]) where r is the number of rows and c is the number of columns. The entries should be read across the rows starting with the top row.

If you wish, you can structure that list of entries to be a list of lists, where each sublist is a row in your matrix.

Every once in a while, it might matter to you what kinds of numbers you put into the matrix. Sage will let you specify them by putting in an optional argument like this: matrix(number type, r, c, [list of entries])

The notation ZZ means "integers." There are other sets of numbers here:

  • QQ the rational numbers (with exact arithmetic),
  • RR the real numbers (with computer precision arithmetic),
  • CC the complex numbers,
  • AA the set of all algebraic numbers, that is, all of the numbers that are roots of some polynomial with integer coefficients.
You can find out what kind of entries a matrix thinks it has by calling the .parent() method on it.

SubsubsectionBuilding a matrix from rows or columns

It is possible to build a matrix by bundling together a bunch of vectors, too. Let's start with an example made using rows.

SageMath prefers rows. I wish it were the other way, but I am sure there is a good reason it prefers rows. If you want to make a matrix whose columns are the vectors v1 and v2, you can use the transpose method. We'll talk more about the operation of transpose later, but it basically "switches rows for columns and vice versa."

SubsubsectionMatrix action on vectors

Of course, SageMath knows how to perform the action of a matrix on a vector.

And if you get the sizes wrong, it will return an error.

If you really need it, SageMath can tell you about inverses.

SubsectionExercises

Task13

  1. Make an example of a matrix \(\left(\begin{smallmatrix} 1 & \bullet \\ -1 & \bullet \end{smallmatrix}\right)\) so that the equation\begin{equation*} \begin{pmatrix} 1 & \bullet \\ -1 & \bullet \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} 1 \\ -1 \end{pmatrix} \end{equation*} has exactly one solution, or explain why this is not possible.
  2. Interpret this as a statement about \(2\)-vectors and draw the picture which corresponds.

Task14

  1. Make an example of a matrix \(\left(\begin{smallmatrix} 4 & 8 & \bullet \\ 3 & 6 & \bullet \\ 1 & 2 & \bullet \end{smallmatrix}\right)\) so that the equation\begin{equation*} \begin{pmatrix} 4 & 8 & \bullet \\ 3 & 6 & \bullet \\ 1 & 2 & \bullet \end{pmatrix} \begin{pmatrix} x \\ y \\ z \end{pmatrix} = \begin{pmatrix} 8 \\ 6 \\ 2 \end{pmatrix} \end{equation*} has exactly one solution, or explain why this is not possible.
  2. Interpret this as a statment about \(3\)-vectors and draw the picture which corresponds.

Task15

  1. Make an example of a matrix \(\left( \begin{smallmatrix} 2 & -1 \\ \bullet & \bullet \end{smallmatrix}\right)\) so that the equation\begin{equation*} \begin{pmatrix} 2 & -1 \\ \bullet & \bullet \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} 7 \\ 3 \end{pmatrix} \end{equation*} has exactly one solution, or explain why this is not possible.
  2. Interpret this as a statement about a pair of lines in the plane and draw the picture which corresponds.

Task16

  1. Make an example of a matrix \(\left( \begin{smallmatrix} 1 & 0 & 1\\ 1 & 1 & 3 \\ \bullet & \bullet & \bullet \end{smallmatrix}\right)\) so that the equation\begin{equation*} \begin{pmatrix} 1 & 0 & 1\\ 1 & 1 & 3 \\ \bullet & \bullet & \bullet \end{pmatrix}\begin{pmatrix} x \\ y \\ z \end{pmatrix} = \begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix} \end{equation*} has no solutions, or explain why this is not possible.
  2. Interpret this as a statement about a planes in space and draw the picture which corresponds.

Task17

  1. Find a triple of numbers \(x\), \(y\), and \(z\) so that the linear combination\begin{equation*} x \begin{pmatrix} 1 \\ 2 \\ 3 \end{pmatrix} + y \begin{pmatrix} 4 \\ 5\\ 6 \end{pmatrix} + z \begin{pmatrix} 7 \\ 8 \\ 9 \end{pmatrix} \end{equation*} yields the zero vector, or explain why this is not possible.
  2. Rewrite the above as an equation which involves a matrix.
  3. Plot the three vectors (use SageMath!) and describe the geometry of the situation.

Task18

  1. The vectors\begin{equation*} r_1 = \begin{pmatrix} 1 \\ 4 \\ 7 \end{pmatrix}, \qquad r_2 = \begin{pmatrix} 2 \\ 5 \\ 8 \end{pmatrix}, \quad \text{ and } \quad r_3 = \begin{pmatrix} 3 \\ 6 \\ 9 \end{pmatrix} \end{equation*} are linearly dependent because they lie in a common plane (through the origin). Find a normal vector to this plane.
  2. Since the vectors are linearly dependent, there must be (infinitely) many choices of scalars \(x\), \(y\), and \(z\) so that \(x r_1 + y r_2 + z r_3 = 0\). Find two different sets of such numbers.

Task19

This task is a good challenge, and we just might have time to talk about it in class. In any case, we will come back to it for our review day.

  1. Consider the equation\begin{equation*} \begin{pmatrix} 2 & 1 \\ 1 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} b_1 \\ b_2 \end{pmatrix}. \end{equation*} We are interested in being able to solve this for \(x\) and \(y\) for any given choice of the numbers \(b_1\) and \(b_2\). Figure out a way to do this by writing \(x\) and \(y\) in terms of \(b_1\) and \(b_2\).
  2. Rewrite your solution in the form\begin{equation*} \begin{pmatrix} x \\ y \end{pmatrix} = b_1 \begin{pmatrix} \bullet \\ \bullet\end{pmatrix} + b_2 \begin{pmatrix} \bullet \\ \bullet \end{pmatrix}. \end{equation*}
  3. How is this related to the inverse of the matrix \(A = \left( \begin{smallmatrix} 2 & 1 \\ 1 & 1 \end{smallmatrix} \right)\)?

Task20

Here's an extra challenge that we won't have time to get to in our first meeting for sure, but I hope to return to later:

  1. Find an example of a number \(c\) and a vector \(\left( \begin{smallmatrix} b_1 \\ b_2 \end{smallmatrix}\right)\) so that the equation\begin{equation*} \begin{pmatrix} 3 & 51 \\ c & 17 \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} b_1 \\ b_2 \end{pmatrix} \end{equation*} does not have a solution, or explain why no such example exists.
  2. Explain your solution in terms of
    • lines in the plane,
    • \(2\)-vectors and linear combinations, and
    • invertibility of a matrix.