Skip to main content

1  Vectors, Coordinates, and Linear Maps

Scientific computing begins with representation. A physical state, a polynomial, a sampled signal, and an image are different objects, yet each can be represented by a finite list of numbers. The list is useful only after we say what its entries mean. That distinction between an object and its coordinates will matter throughout these notes.

Throughout, \(\fR\), \(\fZ\), and \(\fC\) denote the real numbers, integers, and complex numbers. Most examples use real arithmetic. Complex numbers appear naturally when we study oscillations and eigenvalues.

NoteDefinition: Scalar

An element of the number system under discussion is a scalar. In these notes that number system is usually \(\fR\) and occasionally \(\fC\).

NoteDefinition: Vector

A vector space \(V\) over \(\fR\) is a set with addition and scalar multiplication satisfying the following laws. Addition is associative and commutative, has a zero element, and gives each vector an additive inverse. Scalar multiplication satisfies \[ \begin{align} \alpha(\beta\bx)&=(\alpha\beta)\bx,&1\bx&=\bx,\\ \alpha(\bx+\by)&=\alpha\bx+\alpha\by, &(\alpha+\beta)\bx&=\alpha\bx+\beta\bx. \end{align} \] Elements of \(V\) are called vectors. The same definition over \(\fC\) permits complex scalars. A column of real numbers is one example of a vector. A polynomial is another: polynomial addition and scalar multiplication obey these laws.

TipRemark

A column of numbers therefore represents a vector only after we know what its coordinates refer to. The coordinates \((3,2)^T\) might describe a point, a velocity, the coefficients of \(3+2t\), or two temperature readings. Computation manipulates the coordinates, while interpretation tells us what vector they represent.

NoteDefinition: \(\fR^n\)

The vector space \(\fR^n\) consists of all ordered \(n\)-tuples of real numbers. We write vectors as columns unless stated otherwise: \[ \begin{align} \bx=\begin{pmatrix}x_1\\ \vdots\\ x_n\end{pmatrix}\in\fR^n. \end{align} \] Vectors are added entry by entry and multiplied by scalars entry by entry. The zero vector is denoted by \(\bzero\).

TipRemark

NumPy normally stores a vector as an array of shape (n,), which is neither a row nor a column. A shape (n,1) array is a genuine two-dimensional column. This implementation detail affects transposes and broadcasting, so shapes should be checked rather than guessed.

1.1 Span, Independence, and Basis

NoteDefinition: Linear Combination, Span, and Subspace

Given vectors \(\bv_1,...,\bv_k\), a linear combination is any vector of the form \[ \begin{align} c_1\bv_1+\cdots+c_k\bv_k. \end{align} \] Their span is the set of all such combinations. A nonempty set \(S\subseteq\fR^n\) is a subspace if every linear combination of vectors in \(S\) remains in \(S\).

WarningExercise

Decide which of the following subsets of \(\fR^3\) are subspaces: the plane \(x_1+x_2=0\), the plane \(x_1+x_2=1\), the set of vectors with at least one zero entry, and the span of \((1,1,0)^T\) and \((0,1,1)^T\). For every negative answer, identify a subspace axiom that fails.

NoteExample

The vectors \((1,0,0)^T\) and \((0,1,0)^T\) span the coordinate plane in \(\fR^3\) on which the third coordinate is zero. A plane not passing through the origin is not a subspace: it does not contain \(\bzero\) and is not closed under scalar multiplication.

A spanning list may contain redundant vectors. For example, \((1,1)^T\) adds no new vectors to the span of \((1,0)^T\) and \((0,1)^T\). We need a criterion for detecting this redundancy before using the list as a coordinate system.

NoteDefinition: Linear Independence and Basis

Vectors \(\bv_1,...,\bv_k\) are linearly independent if \[ \begin{align} c_1\bv_1+\cdots+c_k\bv_k=\bzero \end{align} \] forces every coefficient \(c_i\) to be zero. A basis of a vector space is a linearly independent spanning set.

NoteTheorem: Exchange, Extension, and Dimension

Let \(V\) be spanned by \(m\) vectors.

  1. Every linearly independent list in \(V\) contains at most \(m\) vectors.

  2. Any linearly independent list can be extended to a basis by adding vectors from a spanning list.

  3. Any two bases of \(V\) contain the same number of vectors. This common number is the dimension of \(V\).

WarningExercise

Prove the referenced result. Begin with a spanning list \(\bw_1,...,\bw_m\) and a nonzero vector \(\bv_1\). Express \(\bv_1\) in the spanning list and replace one \(\bw_j\) having a nonzero coefficient by \(\bv_1\). Show that the new list still spans. Repeat with \(\bv_2,...,\bv_k\), using independence to show that a replaceable old vector always remains. Apply the result in both directions to two bases.

TipRemark

The preceding exercise supplies the replacement argument behind this theorem. This theorem justifies phrases used later such as ``extend a basis of the null space to a basis of the domain.’’

NoteTheorem: A Basis Gives Unique Coordinates

Let \(\bv_1,...,\bv_n\) be a basis of a vector space \(V\). Every \(\bx\in V\) has exactly one representation \[ \begin{align} \bx=x_1\bv_1+\cdots+x_n\bv_n. \end{align} \] The scalars \(x_1,...,x_n\) are the coordinates of \(\bx\) in this basis.

We must prove existence and uniqueness separately.

  1. A basis is a spanning list. Consequently, the definition of span gives scalars \(x_1,...,x_n\) such that \(\bx=\sum_i x_i\bv_i\). This establishes at least one coordinate representation.

  2. Suppose another list of scalars gives the same vector: \[ \begin{align} \bx=\sum_{i=1}^n x_i\bv_i, \qquad \bx=\sum_{i=1}^n y_i\bv_i. \end{align} \] Subtract the second equality from the first. Distributivity of scalar multiplication gives \[ \begin{align} \bzero=\sum_{i=1}^n(x_i-y_i)\bv_i. \end{align} \]

  3. The basis vectors are linearly independent. By the definition of independence, every coefficient in a vanishing linear combination must be zero. Thus \(x_i-y_i=0\) for each \(i\), so the two coordinate lists coincide. Spanning supplied existence, whereas independence supplied uniqueness.

WarningExercise

Let \(p(t)=a+bt+ct^2\). Find its coordinates in the bases \(1,t,t^2\) and \(1,t-1,(t-1)^2\). Construct the matrix that converts the second coordinate vector into the first, and interpret each column.

TipRemark

Coordinates change when the basis changes, but the vector does not. For example, the polynomial \(p(t)=3+2t\) has coordinates \((3,2)^T\) in the basis \(1,t\) and coordinates \((5,2)^T\) in the basis \(1,t-1\). Confusing a vector with one coordinate list is a common source of conceptual errors in change-of-basis and eigenvalue arguments.

1.2 Matrices and Linear Maps

NoteDefinition: Linear Map

A map \(T:V\to W\) is linear if, for all vectors \(\bx,\by\in V\) and scalars \(\alpha,\beta\), \[ \begin{align} T(\alpha\bx+\beta\by)=\alpha T(\bx)+\beta T(\by). \end{align} \] Linearity says that the response to a combination of inputs is the same combination of the individual responses.

NoteDefinition: Matrix

A matrix \(\bA\in\fR^{m\times n}\) is a rectangular array of scalars with \(m\) rows and \(n\) columns. It represents a linear map from \(\fR^n\) to \(\fR^m\) once bases have been selected in the domain and range.

NoteTheorem: The Columns Determine the Map

Let \(\be_1,...,\be_n\) be the standard basis of \(\fR^n\), and let \(T:\fR^n\to\fR^m\) be linear. If the \(j\)th column of \(\bA\) is \(\ba_j=T(\be_j)\), then \[ \begin{align} T(\bx)=\bA\bx=\sum_{j=1}^n x_j\ba_j. \end{align} \] Thus a linear map is completely determined by what it does to a basis.

Write an arbitrary input in the standard basis and apply linearity one operation at a time: \[ \begin{align} \bx&=x_1\be_1+\cdots+x_n\be_n,\\ T(\bx)&=T(x_1\be_1+\cdots+x_n\be_n)\\ &=T(x_1\be_1)+\cdots+T(x_n\be_n)\\ &=x_1T(\be_1)+\cdots+x_nT(\be_n)\\ &=x_1\ba_1+\cdots+x_n\ba_n. \end{align} \] The second line uses preservation of addition. The third uses preservation of scalar multiplication. The final line uses the definition \(\ba_j=T(\be_j)\).

To identify this vector with the usual matrix product, take its \(i\)th entry: \[ \begin{align} \left(\sum_{j=1}^n x_j\ba_j\right)_i =\sum_{j=1}^n a_{ij}x_j=(\bA\bx)_i. \end{align} \] The entries agree for every \(i\), so \(T(\bx)=\bA\bx\). In particular, two linear maps that agree on all standard basis vectors agree on every input.

TipRemark

This column view is more informative than memorizing the row-by-column rule. The set of all possible outputs \(\bA\bx\) is the span of the columns. A zero output means that one linear combination of the columns vanishes. Existence and uniqueness for linear systems will grow directly from these two observations.

NoteExample

For \[ \begin{align} \bA=\begin{pmatrix}1&2\\3&-1\end{pmatrix}, \qquad \bx=\begin{pmatrix}4\\5\end{pmatrix}, \end{align} \] the product is best read as \[ \begin{align} \bA\bx =4\begin{pmatrix}1\\3\end{pmatrix} +5\begin{pmatrix}2\\-1\end{pmatrix} =\begin{pmatrix}14\\7\end{pmatrix}. \end{align} \] The same calculation can be read row by row: each output coordinate is a weighted sum of the input coordinates.

1.3 Matrix Products

Composition of linear maps defines the matrix product. If \(\bB\in\fR^{n\times p}\) represents a map from \(\fR^p\) to \(\fR^n\) and \(\bA\in\fR^{m\times n}\) represents a map from \(\fR^n\) to \(\fR^m\), then the composition sends \(\be_j\) first to the \(j\)th column \(\bb_j\) of \(\bB\) and then to \(\bA\bb_j\). By the referenced result, the matrix of the composition therefore has columns \(\bA\bb_1,...,\bA\bb_p\).

NoteDefinition: Matrix Product

For \(\bA\in\fR^{m\times n}\) and \(\bB\in\fR^{n\times p}\), the product \(\bA\bB\in\fR^{m\times p}\) is the matrix with entries \[ \begin{align} (\bA\bB)_{ij}=\sum_{k=1}^n a_{ik}b_{kj}. \end{align} \] Equivalently, the \(j\)th column of \(\bA\bB\) is \(\bA\bb_j\). The product is defined only when the number of columns of \(\bA\) equals the number of rows of \(\bB\).

WarningExercise

For \(\bA=\begin{pmatrix}2&1\\0&3\end{pmatrix}\) and \(\bB=\begin{pmatrix}1&-1\\2&4\end{pmatrix}\), compute \(\bA\bB\) and \(\bB\bA\) by entries and by columns. Find a matrix other than a multiple of \(\bI\) that commutes with \(\bA\).

Because the product represents composition, it is associative and distributes over addition. It is not commutative. For \[ \begin{align} \bA=\begin{pmatrix}1&0\\0&2\end{pmatrix}, \qquad \bB=\begin{pmatrix}0&1\\1&0\end{pmatrix}, \qquad \bA\bB=\begin{pmatrix}0&1\\2&0\end{pmatrix} \neq \begin{pmatrix}0&2\\1&0\end{pmatrix}=\bB\bA. \end{align} \] Scaling the coordinates and then exchanging them is a different map from exchanging them and then scaling.

1.4 Transpose and Symmetry

NoteDefinition: Matrix Transpose

The transpose of \(\bA\in\fR^{m\times n}\) is the matrix \(\bA^T\in\fR^{n\times m}\) defined by \[ \begin{align} (\bA^T)_{ij}=a_{ji}. \end{align} \] It turns columns into rows and rows into columns.

NoteDefinition: Symmetric and Skew-Symmetric Matrices

A square matrix \(\bA\) is symmetric if \(\bA^T=\bA\) and skew-symmetric if \(\bA^T=-\bA\).

TipRemark

Every square matrix splits uniquely into symmetric and skew-symmetric parts: \[ \begin{align} \bA=\frac{\bA+\bA^T}{2}+\frac{\bA-\bA^T}{2}. \end{align} \] Symmetric matrices will be especially important because they possess real eigenvalues and orthogonal eigenvectors.

NoteTheorem: Properties of the Transpose

For conformable matrices and any scalar \(\alpha\), \[ \begin{align} (\bA^T)^T&=\bA,& (\bA+\bB)^T&=\bA^T+\bB^T,\\ (\alpha\bA)^T&=\alpha\bA^T,& (\bA\bB)^T&=\bB^T\bA^T. \end{align} \]

WarningExercise

Prove the first three transpose identities entry by entry. For the product identity, write \(((\bA\bB)^T)_{ij}\) as a sum and identify the same sum in \(\bB^T\bA^T\). Explain why the order of the factors reverses.

NoteCorollary: Reversal Law for Multiple Factors

Repeated use of the product rule gives \[ \begin{align} (\bA_1\bA_2\cdots\bA_k)^T=\bA_k^T\cdots\bA_2^T\bA_1^T. \end{align} \]

NoteCorollary: Outer Product is Symmetric of Rank One

For every nonzero \(\bx\in\fR^n\), the outer product \(\bx\bx^T\) is symmetric and has rank one, meaning its column space has dimension one. Moreover, \[ \begin{align} \bx^T\bx=\sum_{i=1}^n x_i^2>0. \end{align} \]

1.5 Inverses

A linear map from \(\fR^n\) to itself can be undone exactly when its matrix has an inverse. The inverse is a useful theoretical object, but, as the remark below explains, it is rarely computed.

NoteDefinition: Identity Matrix

The identity matrix \(\bI_n\) has ones on the diagonal and zeros elsewhere. It represents the map that leaves every vector unchanged: \(\bI_n\bx=\bx\). We omit the subscript when the dimension is clear. The zero matrix has every entry zero and sends every vector to the zero vector.

WarningExercise

Use the column interpretation of multiplication to prove \(\bI_m\bA=\bA=\bA\bI_n\) for \(\bA\in\fR^{m\times n}\). Why do the two identity matrices have different dimensions when \(m\neq n\)?

NoteDefinition: Matrix Inverse

A square matrix \(\bA\in\fR^{n\times n}\) is invertible, or nonsingular, if there is a matrix \(\bA^{-1}\) with \[ \begin{align} \bA\bA^{-1}=\bA^{-1}\bA=\bI. \end{align} \] The inverse is unique. If \(\bB\) and \(\bC\) both satisfy the definition, then \(\bB=\bB(\bA\bC)=(\bB\bA)\bC=\bC\).

NoteTheorem: Properties of the Inverse

Let \(\bA,\bB\in\fR^{n\times n}\) be invertible and let \(\alpha\neq0\). Then \(\bA^{-1}\), \(\bA\bB\), \(\alpha\bA\), and \(\bA^T\) are invertible, with \[ \begin{align} (\bA^{-1})^{-1}=\bA, \qquad (\bA\bB)^{-1}=\bB^{-1}\bA^{-1}, \qquad (\alpha\bA)^{-1}=\alpha^{-1}\bA^{-1}, \qquad (\bA^T)^{-1}=(\bA^{-1})^T. \end{align} \]

WarningExercise

Prove the inverse identities by multiplying each proposed inverse on both sides. For the transpose identity, transpose \(\bA\bA^{-1}=\bI\) and use the reversal law. Which assumption is needed for the scalar identity?

TipRemark

(Factor instead of inverting) Scientific codes almost never form \(\bA^{-1}\). To solve \(\bA\bx=\bb\), they factor \(\bA\) into triangular or orthogonal factors and solve with each factor in turn, which costs less and is more accurate than forming the inverse and multiplying. The reversal law \((\bA\bB)^{-1}=\bB^{-1}\bA^{-1}\) describes this procedure. To solve \(\bA\bB\bx=\bb\), we first solve \(\bA\by=\bb\) and then \(\bB\bx=\by\).

1.6 Further Exercises

WarningExercise

Prove that a list containing the zero vector is dependent. Prove that two nonzero vectors are dependent exactly when one is a scalar multiple of the other. Then explain why three vectors in \(\fR^2\) cannot be independent.

WarningExercise

Suppose \(T:\fR^n\to\fR^m\) is linear and \(T(\be_j)=\bzero\) for every standard basis vector. Prove that \(T\) is the zero map. Why is checking only one vector insufficient when \(n>1\)? Would checking a redundant spanning list suffice?

WarningExercise

Write a matrix as both a collection of columns and a collection of rows. Use the two views to explain, without entrywise multiplication, what \(\bA\bx\) and \(\by^T\bA\) mean.

WarningExercise

A square matrix is involutory if \(\bA^2=\bI\). Prove that \(\bA\) is involutory exactly when \(\bA^{-1}=\bA\), and give an involutory \(2\times2\) matrix other than \(\pm\bI\). Interpret your example geometrically.

WarningExercise

Prove the referenced result. In particular, show that every column of \(\bx\bx^T\) is a multiple of \(\bx\), and identify one nonzero column.