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.2. Reading matrix entries (U1-LO3).

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:
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.3. 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 Operations on matrices

Definition 1.2.4. 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.5. Unknown entries in equal matrices (U1-LO3).

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.6. 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.7. Adding matrices (U1-LO3).

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.8.

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.9. 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.10. Scaling a matrix (U1-LO3).

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

Note 1.2.11.

The \(m \times n\) matrix with zeros in every entry is called the zero matrix and is denoted by \(O\text{.}\) For every \(m \times n\) matrix \(A\text{,}\) we have \(A + O = A\text{.}\) The negative of \(A\) is the matrix \(-A = (-1)A\text{,}\) and \(A + (-A) = O\text{.}\)

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.13.

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.14. Transposing matrices (U1-LO3).

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.15.

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

Definition 1.2.16. 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} \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}} \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}} \\ a_{21} \end{bmatrix} \end{equation*}

Definition 1.2.17. Identity matrix.

The identity matrix \(I_n\) is the \(n\times n\) matrix with \(1\)s on the main diagonal and zeros elsewhere.
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_{ij}^T] + [b_{ij}^T] \amp \text{By definition of transpose}\\ \amp = A^T + B^T \end{align*}
Therefore, \((A + B)^T = A^T + B^T\text{.}\)

Definition 1.2.19. Symmetric matrices.

A matrix \(A\) with real entries is called symmetric if \(A^T = A\text{.}\)

Warning 1.2.20.

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.21. Checking matrix symmetry (U1-LO3).

Determine whether each of the following matrices is symmetric or not symmetric:
(a)
\(A = \begin{bmatrix} 0 \amp 2 \amp -3 \\ -2 \amp 0 \amp 5 \\ 3 \amp -5 \amp 0 \end{bmatrix}\)
Solution.
Interchanging rows and columns gives
\begin{equation*} A^T = \begin{bmatrix} 0 \amp -2 \amp 3 \\ 2 \amp 0 \amp -5 \\ -3 \amp 5 \amp 0 \end{bmatrix}. \end{equation*}
Since \(A^T \ne A\text{,}\) \(A\) is not symmetric.
(b)
\(B = \begin{bmatrix} 3 \amp 5 \amp 2 \\ 5 \amp 1 \amp 4 \\ 2 \amp 4 \amp -1 \end{bmatrix}\)
Solution.
Interchanging rows and columns gives
\begin{equation*} B^T = \begin{bmatrix} 3 \amp 5 \amp 2 \\ 5 \amp 1 \amp 4 \\ 2 \amp 4 \amp -1 \end{bmatrix}. \end{equation*}
\(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.
Interchanging rows and columns gives
\begin{equation*} C^T = \begin{bmatrix} 1 \amp -2 \amp 3 \\ 2 \amp 0 \amp 5 \\ -3 \amp 5 \amp 0 \end{bmatrix}. \end{equation*}
Since \(C^T \ne C\text{,}\) \(C\) is not symmetric.
(d)
\(D = \begin{bmatrix} 0 \amp 0 \amp 0 \\ 0 \amp 0 \amp 0 \\ 0 \amp 0 \amp 0 \end{bmatrix}\)
Solution.
Interchanging rows and columns gives
\begin{equation*} D^T = \begin{bmatrix} 0 \amp 0 \amp 0 \\ 0 \amp 0 \amp 0 \\ 0 \amp 0 \amp 0 \end{bmatrix}. \end{equation*}
Since \(D^T = D\text{,}\) \(D\) is symmetric.

Note 1.2.22. Shape habit.

Before adding or transposing matrices, first identify their shapes. A \(2\times 3\) matrix has two rows and three columns. Matrix addition requires the same shape, while transposing a \(2\times 3\) matrix produces a \(3\times 2\) matrix.