A matrix is a twodimensional 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 matrixvector multiplication?
Linear Combination of Columns Approach
The first way to perform the matrixvector 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
matrixvector 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 matrixvector 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 matrixvector 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.