Skip to main content

MATH 345: Linear Algebra and Optimization

Section 1.2 Matrices

Matrices can be viewed in two complementary ways: as arrays of data and as functions acting on vectors. We begin with basic matrix arithmetic, then use matrix-vector multiplication to describe linear maps.

Subsection Matrices as arrays of numbers

Definition 1.2.1. Matrices.

An \(m \times n\) matrix \(A\) is a rectangular array of \(m \cdot n\) real numbers arranged in \(m\) horizontal rows and \(n\) vertical columns:
\begin{equation*} A = \begin{bmatrix} a_{11} \amp a_{12} \amp \cdots \amp a_{1n} \\ a_{21} \amp a_{22} \amp \cdots \amp a_{2n} \\ \vdots \amp \vdots \amp \ddots \amp \vdots \\ a_{m1} \amp a_{m2} \amp \cdots \amp a_{mn} \\ \end{bmatrix} \end{equation*}
The \(i\)-th row of \(A\) is
\begin{equation*} \begin{bmatrix} a_{i1} \amp a_{i2} \amp \cdots \amp a_{in} \end{bmatrix}, \end{equation*}
and the \(j\)-th column of \(A\) is
\begin{equation*} \begin{bmatrix} a_{1j} \\ a_{2j} \\ \vdots \\ a_{mj} \end{bmatrix}. \end{equation*}
The number \(a_{ij}\text{,}\) which is in the \(i\)-th row and \(j\)-th column of \(A\text{,}\) is the \((i,j)\)-entry of \(A\text{,}\) and we often write \(A = [a_{ij}]\text{.}\) We say \(A\) is an "\(m\) by \(n\)" matrix.

Activity 1.2.1.

Consider the matrix
\begin{equation*} A = \begin{bmatrix} 1 \amp 2 \amp 3 \\ 5 \amp -8 \amp -13 \end{bmatrix} \end{equation*}
\(A\) is a \(2 \times 3\) matrix. Compute the following:

Subsection Data matrices

An important application of matrices (but far from the only one!) is to record data. The following table gives a few examples.
Table 1.2.2. Some data matrices
Object Meaning of an entry
Monochrome image \(X_{ij}\) is the pixel value in row \(i\) and column \(j\text{.}\)
Rainfall data \(A_{ij}\) is the rainfall at location \(j\) on day \(i\text{.}\)
Asset returns \(R_{ij}\) is the return of asset \(i\) in period \(j\text{.}\)
Feature matrix \(X_{ij}\) is the value of feature \(j\) for entity \(i\text{.}\)

Subsection Matrix operations

Definition 1.2.3. Equality of matrices.

Two matrices \(A\) and \(B\) are equal if they have the same size and all the corresponding entries are equal.

Activity 1.2.2.

Suppose
\begin{equation*} A = \begin{bmatrix} 3 \amp y \\ 4 \amp -7 \end{bmatrix}\quad\text{and}\quad B = \begin{bmatrix} 6+x \amp -2 \\ 4 \amp -7 \end{bmatrix} \end{equation*}
and \(A = B\text{.}\) Find \(x\) and \(y\text{.}\)
Solution.
Since \(A = B\text{,}\) all entries of \(A\) must equal the corresponding entries in \(B\text{.}\) So it must be true, comparing corresponding entries, that
\begin{align*} 3 \amp = 6 + x\\ y \amp = -2 \end{align*}
Therefore, \(x = -3\) and \(y = -2\text{.}\)

Definition 1.2.4. Sums of matrices.

If \(A = [a_{ij}]\) and \(B = [b_{ij}]\) are both \(m \times n\) matrices, then their sum \(A+B\) is the matrix \(C = [c_{ij}]\) where \(c_{ij} = a_{ij} + b_{ij}\text{.}\)

Activity 1.2.3.

For the matrices
\begin{equation*} A = \begin{bmatrix} 1 \amp 2 \amp 3 \\ 5 \amp -8 \amp -13 \end{bmatrix} \quad\text{and}\quad B = \begin{bmatrix} 0 \amp 2 \amp 1 \\ 1 \amp 3 \amp -4 \end{bmatrix} \end{equation*}
calculate \(A+B\text{.}\)
Solution.
\begin{equation*} \begin{aligned} A+B \amp= \begin{bmatrix} 1+0 \amp 2+2 \amp 3+1\\ 5+1 \amp -8+3 \amp -13+(-4) \end{bmatrix}\\ \amp= \begin{bmatrix} 1 \amp 4 \amp 4\\ 6 \amp -5 \amp -17 \end{bmatrix}. \end{aligned} \end{equation*}

Warning 1.2.5.

For \(A+B\) to be defined, \(A\) and \(B\) must be the same size. From now on, if we write \(A+B\text{,}\) assume that this is the case.

Definition 1.2.6. Scalar multiples of matrices.

If \(A = [a_{ij}]\) is an \(m \times n\) matrix and \(r\) is a real number, then the scalar multiple of \(A\) by \(r\text{,}\) written \(rA\text{,}\) is the \(m \times n\) matrix \(C = [c_{ij}]\text{,}\) where \(c_{ij} = r a_{ij}\text{,}\) that is, \(C\) is the matrix obtained by multiplying every entry of \(A\) by \(r\text{.}\)

Activity 1.2.4.

For \(A\) as in ActivityΒ 1.2.3, calculate \(-2A\text{.}\)
Solution.
\begin{equation*} -2A = \begin{bmatrix} -2 \amp -4 \amp -6 \\ -10 \amp 16 \amp 26 \end{bmatrix} \end{equation*}

Definition 1.2.7. Linear combinations of matrices.

If \(A_1, A_2, \ldots, A_k\) are \(m \times n\) matrices and \(c_1, c_2, \ldots, c_k\) are real numbers, then an expression of the form
\begin{equation*} c_1 A_1 + c_2 A_2 + \cdots + c_k A_k \end{equation*}
is called a linear combination of \(A_1, A_2, \ldots, A_k\text{.}\) The scalars \(c_1, \ldots, c_k\) are called the coefficients of the linear combination.
This is the same idea as a linear combination of vectors from Vectors. The only difference is that the objects being combined are matrices of the same size.

Activity 1.2.5.

Compute the following linear combination of matrices:
\begin{equation*} 4 \begin{bmatrix} 0 \amp 2 \\ -3 \amp 3 \end{bmatrix} - \frac{1}{2} \begin{bmatrix} 4 \amp 2 \\ 6 \amp 2 \end{bmatrix} \end{equation*}
Solution.
\begin{align*} \amp= \begin{bmatrix} 0 \amp 8 \\ -12 \amp 12 \end{bmatrix} - \begin{bmatrix} 2 \amp 1 \\ 3 \amp 1 \end{bmatrix} \amp= \begin{bmatrix} -2 \amp 7 \\ -15 \amp 11 \end{bmatrix} \end{align*}

Why is this true?.

We prove Property 1 only, i.e., the commutativity of addition. Let \(A = [a_{ij}]\) and \(B = [b_{ij}]\text{.}\) Then:
\begin{align*} A + B \amp = [a_{ij} + b_{ij}]\\ \amp = [b_{ij} + a_{ij}] \amp \text{(since real numbers are commutative)}\\ \amp= B + A \end{align*}

Definition 1.2.9.

If \(A = [a_{ij}]\) is an \(m \times n\) matrix, then the transpose of \(A\text{,}\) denoted \(A^T = [a_{ij}^T]\text{,}\) is the \(n \times m\) matrix defined by
\begin{equation*} a_{ij}^T = a_{ji} \end{equation*}
In other words, the transpose of \(A\) is obtained by interchanging the rows and the columns of \(A\text{.}\)

Activity 1.2.6.

Compute the transpose for each of the given matrices:
(a)
\begin{equation*} A = \begin{bmatrix} 1 \amp 2 \amp 3 \\ 5 \amp -8 \amp -13 \end{bmatrix}. \end{equation*}
Solution.
\begin{equation*} A^T = \begin{bmatrix} 1 \amp 5 \\ 2 \amp -8 \\ 3 \amp -13 \end{bmatrix} \end{equation*}
(b)
\begin{equation*} B = \begin{bmatrix} 5 \amp 2 \amp 3 \\ 6 \amp 2 \amp 3 \\ -1 \amp -2 \amp 3 \end{bmatrix} \end{equation*}
Solution.
\begin{equation*} B^T = \begin{bmatrix} 5 \amp 6 \amp -1 \\ 2 \amp 2 \amp -2 \\ 3 \amp 3 \amp 3 \end{bmatrix} \end{equation*}
(c)
\begin{equation*} C = \begin{bmatrix} 10 \\ 20 \\ 30 \end{bmatrix}. \end{equation*}
Solution.
\begin{equation*} C^T = \begin{bmatrix} 10 \amp 20 \amp 30 \end{bmatrix} \end{equation*}

Note 1.2.10.

Observe from the previous activity that, when transposed, a column vector becomes a row vector. And vice versa.

Definition 1.2.11. Main diagonal.

If \(A=[a_{ij}]\) is an \(m\times n\) matrix, the elements \(a_{11}, a_{22}, a_{33},\ldots\) are called the main diagonal of \(A\text{.}\) A matrix \(A\) is called diagonal if its only nonzero entries occur on its main diagonal.
Below are four matrices of various dimensions, with the main diagonal written in bold font.
\begin{equation*} \begin{bmatrix} \mathbf{a_{11}} \amp a_{12} \\ a_{21} \amp \mathbf{a_{22}} \\ a_{31} \amp a_{32} \end{bmatrix} \end{equation*}
\begin{equation*} \begin{bmatrix} \mathbf{a_{11}} \amp a_{12} \amp a_{13} \\ a_{21} \amp \mathbf{a_{22}} \amp a_{23} \end{bmatrix} \end{equation*}
\begin{equation*} \begin{bmatrix} \mathbf{a_{11}} \amp a_{12} \amp a_{13} \\ a_{21} \amp \mathbf{a_{22}} \amp a_{23} \\ a_{31} \amp a_{32} \amp \mathbf{a_{33}} \end{bmatrix} \end{equation*}
\begin{equation*} \begin{bmatrix} \mathbf{a_{11}} \\ a_{21} \end{bmatrix} \end{equation*}
Forming the transpose of a matrix \(A\) can be viewed as flipping \(A\) about its main diagonal.

Why is this true?.

Proof of property 2:
Let \(A = [a_{ij}]\) and \(B = [b_{ij}]\text{.}\) Then \(A + B = [c_{ij}]\) where \(c_{ij} = a_{ij} + b_{ij}\text{.}\)
Then
\begin{align*} (A + B)^T \amp = [c_{ij}^T]\\ \amp = [c_{ji}] \amp \text{By definition of transpose}\\ \amp = [a_{ji} + b_{ji}] \amp \text{Since $c_{ij} = a_{ij} + b_{ij}$}\\ \amp = [a_{ji}] + [b_{ji}] \amp \text{By definition of matrix addition}\\ \amp = A^T + B^T \amp \text{By definition of transpose} \end{align*}
Therefore, \((A + B)^T = A^T + B^T\text{.}\)

Definition 1.2.13. Symmetry and skew-symmetry.

A matrix \(A\) with real entries is called:
  • Symmetric if \(A^T = A\text{.}\)
  • Skew-symmetric if \(A^T = -A\text{.}\)

Warning 1.2.14.

The previous definition only makes sense if the matrix \(A\) is square, i.e., if it has the same number of rows and columns.

Activity 1.2.7.

Determine whether the following matrices are symmetric, skew symmetric, or neither:
(a)
\(A = \begin{bmatrix} 0 \amp 2 \amp -3 \\ -2 \amp 0 \amp 5 \\ 3 \amp -5 \amp 0 \end{bmatrix}\)
Solution.
\(A\) is skew symmetric since \(A^T = -A\text{.}\)
(b)
\(B = \begin{bmatrix} 3 \amp 5 \amp 2 \\ 5 \amp 1 \amp 4 \\ 2 \amp 4 \amp -1 \end{bmatrix}\)
Solution.
\(B\) is symmetric since \(B^T = B\text{.}\)
(c)
\(C = \begin{bmatrix} 1 \amp 2 \amp -3 \\ -2 \amp 0 \amp 5 \\ 3 \amp 5 \amp 0 \end{bmatrix}\)
Solution.
\(C\) is neither symmetric nor skew symmetric.
(d)
\(D = \begin{bmatrix} 0 \amp 0 \amp 0 \\ 0 \amp 0 \amp 0 \\ 0 \amp 0 \amp 0 \end{bmatrix}\)
Solution.
\(D\) is both symmetric and skew symmetric.

Note 1.2.15.

If a matrix \(A\) is both symmetric and skew symmetric, then \(A\) must be a zero matrix!

Note 1.2.16. Shape habit.

Before adding, multiplying, transposing, or applying a matrix, first identify its shape. A \(2\times 3\) matrix has two rows and three columns. Matrix addition requires the same shape. Matrix-vector multiplication and matrix multiplication require compatible dimensions.