14. Basic matrix arithmetic#
An \(m\times n\)-matrix is an array of \(m\) rows and \(n\) columns containing (usually real or complex) numbers called the entries (or coefficients) of the matrix. The entries of a matrix \(A\) are denoted by \(A_{i,j}\), \(a_{ij}\) or similar, where the first index refers to the row and the second to the column. That is, the entries are laid out like
You will often see notation like \(A=(a_{i,j})\) or \(A=(a_{i,j})_{1\le i\le m\atop 1\le j\le n}\) to indicate how the entries are denoted and/or how many rows and columns the matrix has.
In this section we focus on the basic operations that can be performed with matrices.
14.1. Addition and scalar multiplication#
Like vectors, matrices can be added or subtracted entrywise. They can also be multiplied entrywise by a given scalar. For example,
14.2. Special matrices#
A few (types of) matrices occur very often and have their own names:
the \(m\times n\) zero matrix \(\begin{pmatrix} 0 & 0 & \cdots & 0\\ 0 & 0 & \cdots & 0\\ \vdots& \vdots& \ddots & \vdots\\ 0 & 0 & \cdots & 0 \end{pmatrix}\)
the \(n\times n\) identity matrix \(\begin{pmatrix} 1 & 0 & \cdots & 0\\ 0 & 1 & \cdots & 0\\ \vdots& \vdots& \ddots & \vdots\\ 0 & 0 & \cdots & 1 \end{pmatrix}\)
diagonal matrices \(\begin{pmatrix} a_{1,1} & 0 & \cdots & 0\\ 0 & a_{2,2} & \cdots & 0\\ \vdots& \vdots& \ddots & \vdots\\ 0 & 0 & \cdots & a_{n,n} \end{pmatrix}\)
upper triangular matrices \(\begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n}\\ 0 & a_{2,2} & \cdots & a_{2,n}\\ \vdots& \ddots& \ddots & \vdots\\ 0 & \cdots & 0 & a_{n,n} \end{pmatrix}\)
lower triangular matrices \(\begin{pmatrix} a_{1,1} & 0 & \cdots & 0\\ a_{2,1} & a_{2,2} & \ddots & \vdots\\ \vdots& \vdots& \ddots & 0\\ a_{n,1} & a_{n,2} & \cdots & a_{n,n} \end{pmatrix}\)
14.3. Inner product of vectors#
Given two vectors \(\vv=(v_1,\ldots,v_n)\) and \(\vw=(w_1,\ldots,w_n)\), the inner product of \(\vv\) and \(\vw\) is the scalar
(Properties of the inner product)
For vectors \(\vv\), \(\vw\), \(\vx\) (all of the same length) and scalars \(c\) the following hold:
\(\vv\cdot(\vw+\vx) = \vv\cdot\vw + \vv\cdot\vx\)
\((\vv+\vw)\cdot\vx = \vv\cdot\vx + \vw\cdot\vx\)
\(\vv\cdot(c\vw) = c(\vv\cdot\vw)=(c\vv)\cdot\vw\)
\(\vv\cdot\vw = \vw\cdot\vv\)
14.4. Matrix-vector multiplication#
Matrices can be multiplied by vectors.
Given a matrix \(A\) as in (14.1) and a vector
the (matrix-vector) product of \(A\) and \(\vv\) is the vector
Equivalently, we can write
(Properties of matrix-vector multiplication)
For matrices \(A\) and \(B\), vectors \(\vv\) and \(\vw\) and scalars \(c\) the following hold whenever the expressions are defined:
\(A(\vv+\vw)= A\vv + A\vw\)
\(A(c\vv) = c(A\vv)\)
\((A+B)\vv = A\vv+B\vv\)
\((cA)\vv = c(A\vv)\)
Note
Here are two other useful ways to think about matrix-vector products.
First, in terms of inner products (see Definition 14.1): the vector \(A\vv\) consists of the inner products of each of the rows of \(A\) with the vector \(\vv\). Namely, if
then
Second, in terms of linear combinations: the vector \(A\vv\) is a linear combination of the columns of \(A\) where the coefficients are the entries of \(\vv\). Namely, if
then
14.5. Matrix multiplication#
Two matrices \(A\) and \(B\) can be multiplied if the number of columns of \(A\) equals the number of rows of \(B\).
If \(A\) is an \(m\times n\)-matrix and \(B\) is an \(n\times p\)-matrix, then the (matrix) product of \(A\) and \(B\) is the \(m\times p\)-matrix \(AB\) defined as follows:
The product \(AB\) can be viewed as \(p\) matrix-vector multiplications: if \(B=(\vb_1\ \vb_2\ \cdots \vb_p)\), then
(Properties of matrix multiplication)
For matrices \(A\), \(B\) and \(C\) and scalars \(c\) the following hold whenever the expressions are defined:
\(A(B + C)= AB + AC\)
\((A + B)C = AC + BC\)
\((AB)C = A(BC)\)
\((cA)B = c(AB) = A(cB)\)
Warning
Matrix multiplication is not commutative! That is, in general we have