little-book-of/linear-algebra

A concise, beginner-friendly introduction to the core ideas of linear algebra.

Jupyter Notebook

2,003

29 commits

updated Mar 16, 2026

See the code

README

The Little Book of Linear Algebra

A concise, beginner-friendly introduction to the core ideas of Linear Algebra.

A clear, hands-on guide to the geometry and structure behind vectors and matrices.

Formats

Open In Colab

For old version (v1), here is the link

Build it yourself (Quarto)

We use Quarto to generate all outputs.

Preview locally:

quarto preview

Render outputs:

# All configured formats
quarto render

# Individual formats
quarto render --to html     # site into docs/
quarto render --to pdf      # docs/book.pdf
quarto render --to epub     # docs/book.epub
quarto render --to latex    # docs/book-latex/book.tex

The Book

Chapter 1. Vectors, scalars, and geometry

Opening

Arrows in the air,
directions whisper softly—
the plane comes alive.

1. Scalars, Vectors, and Coordinate Systems

When we begin learning linear algebra, everything starts with the simplest building blocks: scalars and vectors. A scalar is just a single number, like 3, –7, or π. It carries only magnitude and no direction. Scalars are what we use for counting, measuring length, or scaling other objects up and down. A vector, by contrast, is an ordered collection of numbers. You can picture it as an arrow pointing somewhere in space, or simply as a list like (2, 5) in 2D or (1, –3, 4) in 3D. Where scalars measure "how much," vectors measure both "how much" and "which way."

Coordinate Systems

To talk about vectors, we need a coordinate system. Imagine laying down two perpendicular axes on a sheet of paper: the x-axis (left to right) and the y-axis (up and down). Every point on the sheet can be described with two numbers: how far along the x-axis, and how far along the y-axis. This pair of numbers is a vector in 2D. Add a z-axis pointing up from the page, and you have 3D space. Each coordinate system gives us a way to describe vectors numerically, even though the underlying "space" is the same.

Visualizing Scalars vs. Vectors

  • A scalar is like a single tick mark on a ruler.
  • A vector is like an arrow that starts at the origin (0, 0, …) and ends at the point defined by its components. For example, the vector (3, 4) in 2D points from the origin to the point 3 units along the x-axis and 4 units along the y-axis.

Why Start Here?

Understanding the difference between scalars and vectors is the foundation for everything else in linear algebra. Every concept-matrices, linear transformations, eigenvalues-eventually reduces to how we manipulate vectors and scale them with scalars. Without this distinction, the rest of the subject would have no anchor.

Why It Matters

Nearly every field of science and engineering depends on this idea. Physics uses vectors for velocity, acceleration, and force. Computer graphics uses them to represent points, colors, and transformations. Data science treats entire datasets as high-dimensional vectors. By mastering scalars and vectors early, you unlock the language in which modern science and technology are written.

Try It Yourself

  1. Draw an x- and y-axis on a piece of paper. Plot the vector (2, 3).
  2. Now draw the vector (–1, 4). Compare their directions and lengths.
  3. Think: which of these two vectors points "more upward"? Which is "longer"?

These simple experiments already give you intuition for the operations you'll perform again and again in linear algebra.

2. Vector Notation, Components, and Arrows

Linear algebra gives us powerful ways to describe and manipulate vectors, but before we can do anything with them, we need a precise notation system. Notation is not just cosmetic-it tells us how to read, write, and think about vectors clearly and unambiguously. In this section, we'll explore how vectors are written, how their components are represented, and how we can interpret them visually as arrows.

Writing Vectors

Vectors are usually denoted by lowercase letters in bold (like $\mathbf{v}, \mathbf{w}, \mathbf{x}$)
or with an arrow overhead (like $\vec{v}$).

For instance, the vector $\mathbf{v} = (2, 5)$ is the same as $\vec{v} = (2, 5)$.

The style depends on context: mathematicians often use bold, physicists often use arrows.
In handwritten notes, people sometimes underline vectors (e.g., $\underline{v}$) to avoid confusion with scalars.

The important thing is to distinguish vectors from scalars at a glance.

Components of a Vector

A vector in two dimensions has two components, written as $(x, y)$.
In three dimensions, it has three components: $(x, y, z)$.
More generally, an $n$-dimensional vector has $n$ components: $(v_1, v_2, \ldots, v_n)$.
Each component tells us how far the vector extends along one axis of the coordinate system.

For example:

  • $\mathbf{v} = (3, 4)$ means the vector extends 3 units along the $x$-axis and 4 units along the $y$-axis.
  • $\mathbf{w} = (-2, 0, 5)$ means the vector extends $-2$ units along the $x$-axis, $0$ along the $y$-axis, and 5 along the $z$-axis.

We often refer to the $i$-th component of a vector $\mathbf{v}$ as $v_i$.
So, for $\mathbf{v} = (3, 4, 5)$, we have $v_1 = 3$, $v_2 = 4$, $v_3 = 5$.

Column vs. Row Vectors

Vectors can be written in two common ways:

  • As a row vector: $(v_1, v_2, v_3)$

  • As a column vector:

    $$ \begin{bmatrix} v_1 \ v_2 \ v_3 \end{bmatrix} $$

Both represent the same abstract object.
Row vectors are convenient for quick writing, while column vectors are essential when we start multiplying by matrices, because the dimensions must align.

Vectors as Arrows

The most intuitive way to picture a vector is as an arrow:

  • It starts at the origin (0, 0, …).
  • It ends at the point given by its components.

For example, the vector (2, 3) in 2D is drawn as an arrow from (0, 0) to (2, 3). The arrow has both direction (where it points) and magnitude (its length). This geometric picture makes abstract algebraic manipulations much easier to grasp.

Position Vectors vs. Free Vectors

There are two common interpretations of vectors:

  1. Position vector - a vector that points from the origin to a specific point in space. Example: (2, 3) is the position vector for the point (2, 3).
  2. Free vector - an arrow with length and direction, but not tied to a specific starting point. For instance, an arrow of length 5 pointing northeast can be drawn anywhere, but it still represents the same vector.

In linear algebra, we often treat vectors as free vectors, because their meaning does not depend on where they are drawn.

Example: Reading a Vector

Suppose u = (–3, 2).

  • The first component (–3) means move 3 units left along the x-axis.
  • The second component (2) means move 2 units up along the y-axis. So the arrow points to the point (–3, 2). Even without a diagram, the components tell us exactly what the arrow would look like.

Why It Matters

Clear notation is the backbone of linear algebra. Without it, equations quickly become unreadable, and intuition about direction and size is lost. The way we write vectors determines how easily we can connect the algebra (numbers and symbols) to the geometry (arrows and spaces). This dual perspective-symbolic and visual-is what makes linear algebra powerful and practical.

Try It Yourself

  1. Write down the vector (4, –1). Draw it on graph paper.
  2. Rewrite the same vector as a column vector.
  3. Translate the vector (4, –1) by moving its starting point to (2, 3) instead of the origin. Notice that the arrow looks the same-it just starts elsewhere.
  4. For a harder challenge: draw the 3D vector (2, –1, 3). Even if you can't draw perfectly in 3D, try to show each component along the x, y, and z axes.

By practicing both the notation and the arrow picture, you'll develop fluency in switching between abstract symbols and concrete visualizations. This skill will make every later concept in linear algebra far more intuitive.

3. Vector Addition and Scalar Multiplication

Once we know how to describe vectors with components and arrows, the next step is to learn how to combine them. Two fundamental operations form the backbone of linear algebra: adding vectors together and scaling vectors with numbers (scalars). These two moves, though simple, generate everything else we'll build later. With them, we can describe motion, forces, data transformations, and more.

Vector Addition in Coordinates

Suppose we have two vectors in 2D:
$\mathbf{u} = (u_1, u_2), \quad \mathbf{v} = (v_1, v_2)$.

Their sum is defined as:
$$ \mathbf{u} + \mathbf{v} = (u_1 + v_1, ; u_2 + v_2). $$

In words, you add corresponding components.
This works in higher dimensions too:

$$ (u_1, u_2, \ldots, u_n) + (v_1, v_2, \ldots, v_n) = (u_1 + v_1, ; u_2 + v_2, ; \ldots, ; u_n + v_n). $$

Example: $$ (2, 3) + (-1, 4) = (2 - 1, ; 3 + 4) = (1, 7). $$

Vector Addition as Geometry

The geometric picture is even more illuminating. If you draw vector u as an arrow, then place the tail of v at the head of u, the arrow from the start of u to the head of v is u + v. This is called the tip-to-tail rule. The parallelogram rule is another visualization: place u and v tail-to-tail, form a parallelogram, and the diagonal is their sum.

Example: u = (3, 1), v = (2, 2). Draw both from the origin. Their sum (5, 3) is exactly the diagonal of the parallelogram they span.

Scalar Multiplication in Coordinates

Scalars stretch or shrink vectors.
If $\mathbf{u} = (u_1, u_2, \ldots, u_n)$ and $c$ is a scalar, then:

$$ c \cdot \mathbf{u} = (c \cdot u_1, ; c \cdot u_2, ; \ldots, ; c \cdot u_n). $$

Example:

$$ 2 \cdot (3, 4) = (6, 8). $$

$$ (-1) \cdot (3, 4) = (-3, -4). $$

Multiplying by a positive scalar stretches or compresses the arrow while keeping the direction the same. Multiplying by a negative scalar flips the arrow to point the opposite way.

Scalar Multiplication as Geometry

Imagine the vector (1, 2). Draw it on graph paper: it goes right 1, up 2. Now double it: (2, 4). The arrow points in the same direction but is twice as long. Halve it: (0.5, 1). It's the same direction but shorter. Negate it: (–1, –2). Now the arrow points backward.

This geometric picture explains why we call these numbers "scalars": they scale the vector.

Combining Both: Linear Combinations

Vector addition and scalar multiplication are not just separate tricks-they combine to form the heart of linear algebra: linear combinations.

A linear combination of vectors $u$ and $v$ is any vector of the form
$a \cdot u + b \cdot v$, where $a$ and $b$ are scalars.

Example:
If $u = (1, 0)$ and $v = (0, 1)$, then
$3 \cdot u + 2 \cdot v = (3, 2)$.

This shows how any point on the grid can be reached by scaling and adding these two basic vectors.
That’s the essence of constructing spaces.

Algebraic Properties

Vector addition and scalar multiplication obey rules that mirror arithmetic with numbers:

  • Commutativity: $u + v = v + u$
  • Associativity: $(u + v) + w = u + (v + w)$
  • Distributivity over scalars: $c \cdot (u + v) = c \cdot u + c \cdot v$
  • Distributivity over numbers: $(a + b) \cdot u = a \cdot u + b \cdot u$

These rules are not trivial bookkeeping - they guarantee that linear algebra behaves predictably,
which is why it works as the language of science.

Everyday Analogies

  • Walking directions: If you walk 3 steps north and then 4 steps east, that's like adding (0, 3) + (4, 0) = (4, 3).
  • Forces in physics: If two people push on a box in different directions, the total force is the vector sum of their pushes.
  • Budget planning: Think of income and expenses as vectors of numbers. Combining them is just vector addition.

Why It Matters

With only these two operations-addition and scaling-you can already describe lines, planes, and entire spaces. Any system that grows by combining influences, like physics, economics, or machine learning, is built on these simple rules. Later, when we define matrix multiplication, dot products, and eigenvalues, they all reduce to repeated patterns of adding and scaling vectors.

Try It Yourself

  1. Add (2, 3) and (–1, 4). Draw the result on graph paper.
  2. Multiply (1, –2) by 3, and then add (0, 5). What is the final vector?
  3. For a deeper challenge: Let u = (1, 2) and v = (2, –1). Sketch all vectors of the form a·u + b·v for integer values of a, b between –2 and 2. Notice the grid of points you create-that's the span of these two vectors.

This simple practice shows you how combining two basic vectors through addition and scaling generates a whole structured space, the first glimpse of linear algebra's real power.

4. Linear Combinations and Span

After learning to add vectors and scale them, the natural next question is: what can we build from these two operations? The answer is the concept of linear combinations, which leads directly to one of the most fundamental ideas in linear algebra: the span of a set of vectors. These ideas tell us not only what individual vectors can do, but how groups of vectors can shape entire spaces.

What Is a Linear Combination?

A linear combination is any vector formed by multiplying vectors with scalars and then adding the results together.

Formally, given vectors $v_1, v_2, \ldots, v_k$ and scalars $a_1, a_2, \ldots, a_k$, a linear combination looks like:

$$ a_1 \cdot v_1 + a_2 \cdot v_2 + \cdots + a_k \cdot v_k. $$

This is nothing more than repeated addition and scaling, but the idea is powerful because it describes how vectors combine to generate new ones.

Example:
Let $u = (1, 0)$ and $v = (0, 1)$. Then any linear combination $a \cdot u + b \cdot v = (a, b)$.
This shows that every point in the 2D plane can be expressed as a linear combination of these two simple vectors.

Geometric Meaning

Linear combinations are about mixing directions and magnitudes. Each vector acts like a "directional ingredient," and the scalars control how much of each ingredient you use.

  • With one vector: You can only reach points on a single line through the origin.
  • With two non-parallel vectors in 2D: You can reach every point in the plane.
  • With three non-coplanar vectors in 3D: You can reach all of 3D space.

This progression shows that the power of linear combinations depends not just on the vectors themselves but on how they relate to each other.

The Span of a Set of Vectors

The span of a set of vectors is the collection of all possible linear combinations of them.
It answers the question: "What space do these vectors generate?"

Notation:

$$ \text{Span}{v_1, v_2, \ldots, v_k} = {a_1 v_1 + a_2 v_2 + \cdots + a_k v_k ;|; a_i \in \mathbb{R}}. $$

Examples:

  • $\text{Span}{(1, 0)}$ = all multiples of $(1, 0)$, which is the $x$-axis.
  • $\text{Span}{(1, 0), (0, 1)}$ = all of $\mathbb{R}^2$, the entire plane.
  • $\text{Span}{(1, 2), (2, 4)}$ = just the line through $(1, 2)$, because the second vector is a multiple of the first.

So the span depends heavily on whether the vectors add new directions or just duplicate what’s already there.

Parallel and Independent Vectors

If vectors point in the same or opposite directions (one is a scalar multiple of another), then their span is just a line. They don't add any new coverage of space. But if they point in different directions, they open up new dimensions. This leads to the critical idea of linear independence, which we'll explore later: vectors are independent if none of them is a linear combination of the others.

Visualizing Span in Different Dimensions

  • In 2D:

    • One vector spans a line.
    • Two independent vectors span the whole plane.
  • In 3D:

    • One vector spans a line.
    • Two independent vectors span a plane.
    • Three independent vectors span all of 3D space.
  • In higher dimensions: The same pattern continues. A set of k independent vectors spans a k-dimensional subspace inside the larger space.

Everyday Analogies

  • Color mixing: Red and blue paints can mix to make purple shades. Add yellow, and you can cover a broader spectrum. Similarly, vectors combine to produce new ones.
  • Cooking recipes: Ingredients (vectors) can be scaled up or down and combined in different amounts. The span is the full menu of dishes you can create with those ingredients.
  • Directions in navigation: If you can only walk north and south, your span is a line. Add east-west walking, and suddenly you can reach any location in the city grid.

Algebraic Properties

  • The span of vectors always includes the zero vector, because you can choose all scalars = 0.
  • The span is always a subspace, meaning it's closed under addition and scalar multiplication. If you add two vectors in the span, the result stays in the span.
  • The span grows when you add new independent vectors, but not if the new vector is just a combination of the old ones.

Why It Matters

Linear combinations and span are the foundation for almost everything else in linear algebra:

  • They define what it means for vectors to be independent or dependent.
  • They form the basis for solving linear systems (solutions are often described as spans).
  • They explain how dimensions arise in vector spaces.
  • They underpin practical methods like principal component analysis, where data is projected onto the span of a few important vectors.

In short, the span tells us the "reach" of a set of vectors, and linear combinations are the mechanism to explore that reach.

Try It Yourself

  1. Take vectors (1, 0) and (0, 1). Write down three different linear combinations and plot them. What shape do you notice?
  2. Try vectors (1, 2) and (2, 4). Write down three different linear combinations. Plot them. What's different from the previous case?
  3. In 3D, consider (1, 0, 0) and (0, 1, 0). Describe their span. Add (0, 0, 1). How does the span change?
  4. Challenge: Pick vectors (1, 2, 3) and (4, 5, 6). Do they span a plane or all of 3D space? How can you tell?

By experimenting with simple examples, you'll see clearly how the idea of span captures the richness or limitations of combining vectors.

5. Length (Norm) and Distance

So far, vectors have been arrows with direction and components. To compare them more meaningfully, we need ways to talk about how long they are and how far apart they are. These notions are formalized through the norm of a vector (its length) and the distance between vectors. These concepts tie together the algebra of components and the geometry of space.

The Length (Norm) of a Vector

The norm of a vector measures its magnitude, or how long the arrow is.
For a vector $v = (v_1, v_2, \ldots, v_n)$ in $n$-dimensional space, its norm is defined as:

$$ |v| = \sqrt{v_1^2 + v_2^2 + \cdots + v_n^2}. $$

This formula comes directly from the Pythagorean theorem: the length of the hypotenuse equals the square root of the sum of squares of the legs.
In 2D, this is the familiar distance formula between the origin and a point.

Examples:

  • For $v = (3, 4)$:
    $$ |v| = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = 5. $$

  • For $w = (1, -2, 2)$:
    $$ |w| = \sqrt{1^2 + (-2)^2 + 2^2} = \sqrt{1 + 4 + 4} = \sqrt{9} = 3. $$

Unit Vectors

A unit vector is a vector whose length is exactly 1.
These are important because they capture direction without scaling.
To create a unit vector from any nonzero vector, divide by its norm:

$$ u = \frac{v}{|v|}. $$

Example:
For $v = (3, 4)$, the unit vector is

$$ u = \left(\tfrac{3}{5}, \tfrac{4}{5}\right). $$

This points in the same direction as $(3, 4)$ but has length 1.

Unit vectors are like pure directions.
They're especially useful for projections, defining coordinate systems, and normalizing data.

Distance Between Vectors

The distance between two vectors $u$ and $v$ is defined as the length of their difference:

$$ \text{dist}(u, v) = |u - v|. $$

Example:
Let $u = (2, 1)$ and $v = (5, 5)$. Then

$$ u - v = (-3, -4). $$

Its norm is

$$ \sqrt{(-3)^2 + (-4)^2} = \sqrt{9 + 16} = 5. $$

So the distance is 5. This matches our intuition: the straight-line distance between points $(2, 1)$ and $(5, 5)$.

Geometric Interpretation

  • The norm tells you how far a point is from the origin.
  • The distance tells you how far two points are from each other.

Both are computed with the same formula-the square root of sums of squares-but applied in slightly different contexts.

Different Kinds of Norms

The formula above defines the Euclidean norm (or $\ell_2$ norm), the most common one.
But in linear algebra, other norms are also useful:

  • $\ell_1$ norm:
    $$ |v|_1 = |v_1| + |v_2| + \cdots + |v_n| $$
    (sum of absolute values).

  • $\ell_\infty$ norm:
    $$ |v|_\infty = \max(|v_1|, |v_2|, \ldots, |v_n|) $$
    (largest component).

These norms change the geometry of "length" and "distance." For example, in the ℓ₁ norm, the unit circle is shaped like a diamond; in the ℓ∞ norm, it looks like a square.

Everyday Analogies

  • Walking distance in a city: If streets are on a grid, the ℓ₁ norm (sum of absolute differences) is more natural than the Euclidean norm.
  • Climbing stairs: The Euclidean norm is like measuring the diagonal distance, but step by step you may actually walk an ℓ₁ distance.
  • Measuring error in data: Different norms capture different notions of "closeness" between predictions and reality. Euclidean distance punishes large errors heavily; ℓ₁ treats all errors equally.

Algebraic Properties

Norms and distances satisfy critical properties that make them consistent measures:

  • Non-negativity: $|v| \geq 0$, and $|v| = 0$ only if $v = 0$.
  • Homogeneity: $|c \cdot v| = |c| , |v|$ (scaling affects length predictably).
  • Triangle inequality: $|u + v| \leq |u| + |v|$ (the direct path is shortest).
  • Symmetry (for distance): $\text{dist}(u, v) = \text{dist}(v, u)$.

These properties are why norms and distances are robust tools across mathematics.

Why It Matters

Understanding length and distance is the first step toward geometry in higher dimensions. These notions:

  • Allow us to compare vectors quantitatively.
  • Form the basis of concepts like angles, orthogonality, and projections.
  • Underpin optimization problems (e.g., "find the closest vector" is central to machine learning).
  • Define the geometry of spaces, which changes dramatically depending on which norm you use.

Try It Yourself

  1. Compute the norm of (6, 8). Then divide by the norm to find its unit vector.
  2. Find the distance between (1, 1, 1) and (4, 5, 6).
  3. Compare the Euclidean and Manhattan (ℓ₁) distances between (0, 0) and (3, 4). Which one matches your intuition if you were walking along a city grid?
  4. Challenge: For vectors u = (2, –1, 3) and v = (–2, 0, 1), compute ‖u – v‖. Then explain what this distance means geometrically.

By working through these examples, you'll see how norms and distances make abstract vectors feel as real as points and arrows you can measure in everyday life.

6. Dot Product (Algebraic and Geometric Views)

The dot product is one of the most fundamental operations in linear algebra. It looks like a simple formula, but it unlocks the ability to measure angles, detect orthogonality, project one vector onto another, and compute energy or work in physics. Understanding it requires seeing both the algebraic view (a formula on components) and the geometric view (a way to compare directions).

Algebraic Definition

For two vectors of the same dimension, $u = (u_1, u_2, \ldots, u_n)$ and $v = (v_1, v_2, \ldots, v_n)$, the dot product is defined as:

$$ u \cdot v = u_1 v_1 + u_2 v_2 + \cdots + u_n v_n. $$

This is simply multiplying corresponding components and summing the results.

Examples:

  • $(2, 3) \cdot (4, 5) = (2 \times 4) + (3 \times 5) = 8 + 15 = 23$
  • $(1, -2, 3) \cdot (0, 4, -1) = (1 \times 0) + (-2 \times 4) + (3 \times -1) = 0 - 8 - 3 = -11$

Notice that the dot product is always a scalar, not a vector.

Geometric Definition

The dot product can also be defined in terms of vector length and angle:

$$ u \cdot v = |u| , |v| \cos(\theta), $$

where $\theta$ is the angle between $u$ and $v$ ($0^\circ \leq \theta \leq 180^\circ$).

This formula tells us:

  • If the angle is acute (less than $90^\circ$), $\cos(\theta) > 0$, so the dot product is positive.
  • If the angle is right (exactly $90^\circ$), $\cos(\theta) = 0$, so the dot product is 0.
  • If the angle is obtuse (greater than $90^\circ$), $\cos(\theta) < 0$, so the dot product is negative.

Thus, the sign of the dot product encodes directional alignment.

Connecting the Two Definitions

At first glance, the algebraic sum of products and the geometric length–angle formula seem unrelated. But they are equivalent. To see why, consider the law of cosines applied to a triangle formed by u, v, and u – v. Expanding both sides leads directly to the equivalence between the two formulas. This dual interpretation is what makes the dot product so powerful: it is both a computation rule and a geometric measurement.

Orthogonality

Two vectors are orthogonal (perpendicular) if and only if their dot product is zero:

$$ u \cdot v = 0 ;;\Longleftrightarrow;; \theta = 90^\circ. $$

This gives us an algebraic way to check for perpendicularity without drawing diagrams.

Example:
$(2, 1) \cdot (-1, 2) = (2 \times -1) + (1 \times 2) = -2 + 2 = 0$,
so the vectors are orthogonal.

Projections

The dot product also provides a way to project one vector onto another.
The scalar projection of $u$ onto $v$ is:

$$ \text{proj}_{\text{scalar}}(u \text{ onto } v) = \frac{u \cdot v}{|v|}. $$

The vector projection is then:

$$ \text{proj}_{\text{vector}}(u \text{ onto } v) = \frac{u \cdot v}{|v|^2} , v. $$

This allows us to decompose vectors into "parallel" and "perpendicular" components, which is central in geometry, physics, and data analysis.

Examples

  1. Compute $u = (3, 4)$ and $v = (4, 3)$.

    • Dot product: $(3 \times 4) + (4 \times 3) = 12 + 12 = 24$.
    • Norms: $|u| = 5$, $|v| = 5$.
    • $\cos(\theta) = \tfrac{24}{5 \times 5} = \tfrac{24}{25} \approx 0.96$, so $\theta \approx 16^\circ$.
      These vectors are nearly parallel.
  2. Compute $u = (1, 2, -1)$ and $v = (2, -1, 1)$.

    • Dot product: $(1 \times 2) + (2 \times -1) + (-1 \times 1) = 2 - 2 - 1 = -1$.
    • Norms: $|u| = \sqrt{6}$, $|v| = \sqrt{6}$.
    • $\cos(\theta) = \tfrac{-1}{\sqrt{6} \times \sqrt{6}} = -\tfrac{1}{6}$, so $\theta \approx 99.6^\circ$.
      Slightly obtuse.

Physical Interpretation

In physics, the dot product computes work:

$$ \text{Work} = \text{Force} \cdot \text{Displacement} = |\text{Force}| , |\text{Displacement}| \cos(\theta). $$

Only the component of the force in the direction of motion contributes. If you push straight down on a box while trying to move it horizontally, the dot product is zero: no work is done in the direction of motion.

Everyday Analogies

  • Teamwork analogy: Two people pushing a car. If they push in nearly the same direction, the dot product is large and positive (strong cooperation). If they push at right angles, the dot product is zero (they don't help each other). If they push in opposite directions, the dot product is negative (they work against each other).
  • Conversation analogy: Think of two ideas. If they're aligned, the "dot product" of their meanings is high. If they're unrelated, it's zero. If they contradict, it's negative.

Algebraic Properties

  • Commutative: $u \cdot v = v \cdot u$
  • Distributive: $u \cdot (v + w) = u \cdot v + u \cdot w$
  • Scalar compatibility: $(c \cdot u) \cdot v = c ,(u \cdot v)$
  • Non-negativity: $v \cdot v = |v|^2 \geq 0$

These guarantee that the dot product behaves consistently and meshes with the structure of vector spaces.

Why It Matters

The dot product is the first bridge between algebra and geometry. It:

  • Defines angles and orthogonality in higher dimensions.
  • Powers projections and decompositions, which underlie least squares, regression, and data fitting.
  • Appears in physics as energy, power, and work.
  • Serves as the kernel of many machine learning methods (e.g., similarity measures in high-dimensional spaces).

Without the dot product, linear algebra would lack a way to connect numbers with geometry and meaning.

Try It Yourself

  1. Compute (2, –1) · (–3, 4). Then find the angle between them.
  2. Check if (1, 2, 3) and (2, 4, 6) are orthogonal. What does the dot product tell you?
  3. Find the projection of (3, 1) onto (1, 2). Draw the original vector, the projection, and the perpendicular component.
  4. In physics terms: Suppose a 10 N force is applied at 60° to the direction of motion, and the displacement is 5 m. How much work is done?

These exercises reveal the dual power of the dot product: as a formula to compute and as a geometric tool to interpret.

7. Angles Between Vectors and Cosine

Having defined the dot product, we are now ready to measure angles between vectors. In everyday life, angles tell us how two lines or directions relate-whether they point the same way, are perpendicular, or are opposed. In linear algebra, the dot product and cosine function give us a precise, generalizable way to define angles in any dimension, not just in 2D or 3D. This section explores how we compute, interpret, and apply vector angles.

The Definition of an Angle Between Vectors

For two nonzero vectors $u$ and $v$, the angle $\theta$ between them is defined by:

$$ \cos(\theta) = \frac{u \cdot v}{|u| , |v|}. $$

This formula comes directly from the geometric definition of the dot product.
Rearranging gives:

$$ \theta = \arccos!\left(\frac{u \cdot v}{|u| , |v|}\right). $$

Key points:

  • $\theta$ is always between $0^\circ$ and $180^\circ$ (or $0$ and $\pi$ radians).
  • The denominator normalizes the dot product by dividing by the product of lengths, so the result is dimensionless and always between $-1$ and $1$.
  • The cosine value directly encodes alignment: positive, zero, or negative.

Interpretation of Cosine Values

The cosine tells us about the directional relationship:

  • $\cos(\theta) = 1 ;;\Rightarrow;; \theta = 0^\circ$ → vectors point in exactly the same direction.
  • $\cos(\theta) = 0 ;;\Rightarrow;; \theta = 90^\circ$ → vectors are orthogonal (perpendicular).
  • $\cos(\theta) = -1 ;;\Rightarrow;; \theta = 180^\circ$ → vectors point in exactly opposite directions.
  • $\cos(\theta) > 0$ → acute angle → vectors point more “together” than apart.
  • $\cos(\theta) < 0$ → obtuse angle → vectors point more “against” each other.

Thus, the cosine compresses geometric alignment into a single number.

Examples

  1. $u = (1, 0), ; v = (0, 1)$

    • Dot product: $1 \times 0 + 0 \times 1 = 0$
    • Norms: $1$ and $1$
    • $\cos(\theta) = 0 ;\Rightarrow; \theta = 90^\circ$
      The vectors are perpendicular, as expected.
  2. $u = (2, 3), ; v = (4, 6)$

    • Dot product: $(2 \times 4) + (3 \times 6) = 8 + 18 = 26$
    • Norms: $\sqrt{2^2 + 3^2} = \sqrt{13}$, and $\sqrt{4^2 + 6^2} = \sqrt{52} = 2\sqrt{13}$
    • $\cos(\theta) = \tfrac{26}{\sqrt{13} \cdot 2\sqrt{13}} = \tfrac{26}{26} = 1$
    • $\theta = 0^\circ$
      These vectors are multiples, so they align perfectly.
  3. $u = (1, 1), ; v = (-1, 1)$

    • Dot product: $(1 \times -1) + (1 \times 1) = -1 + 1 = 0$
    • $\cos(\theta) = 0 ;\Rightarrow; \theta = 90^\circ$
      The vectors are perpendicular, forming diagonals of a square.

Angles in Higher Dimensions

The beauty of the formula is that it works in any dimension.
Even in $\mathbb{R}^{100}$ or higher, we can define the angle between two vectors using only their dot product and norms.

While we cannot visualize the geometry directly in high dimensions, the cosine formula still captures how aligned two directions are:

$$ \cos(\theta) = \frac{u \cdot v}{|u| , |v|}. $$

This is critical in machine learning, where data often lives in very high-dimensional spaces.

Cosine Similarity

The cosine of the angle between two vectors is often called cosine similarity. It is widely used in data analysis and machine learning to measure how similar two data vectors are, independent of their magnitude.

  • In text mining, documents are turned into word-frequency vectors. Cosine similarity measures how "close in topic" two documents are, regardless of length.
  • In recommendation systems, cosine similarity compares user preference vectors to suggest similar users or items.

This demonstrates how a geometric concept extends far beyond pure math.

Orthogonality Revisited

The angle formula reinforces the special role of orthogonality.
If $\cos(\theta) = 0$, then $u \cdot v = 0$.

This means the dot product not only computes length but also serves as a direct test for perpendicularity.
This algebraic shortcut is far easier than manually checking geometric right angles.

Angles and Projections

Angles are closely tied to projections.
The length of the projection of $u$ onto $v$ is $|u|\cos(\theta)$.

If the angle is small, the projection is large — most of $u$ lies in the direction of $v$.
If the angle is close to $90^\circ$, the projection shrinks toward zero.

Thus, the cosine acts as a scaling factor between directions.

Everyday Analogies

  • Teamwork analogy: If two people push a heavy object, the effectiveness of their combined effort depends on the angle.
    If they push in nearly the same direction (small $\theta$), they cooperate efficiently.
    If they push at right angles ($\theta = 90^\circ$), they waste effort.
    If they push opposite each other ($\theta \approx 180^\circ$), they cancel out.

  • Conversation analogy: If two people's opinions align ($\cos \theta \approx 1$), they agree strongly.
    If they are orthogonal ($\cos \theta = 0$), they are unrelated.
    If they oppose each other ($\cos \theta \approx -1$), they fundamentally disagree.

  • Navigation analogy: If two roads meet at a small angle, their directions are similar.
    If they cross perpendicularly, their directions are independent.

Why It Matters

Angles between vectors provide:

  • A way to generalize geometry beyond 2D/3D.
  • A measure of similarity in high-dimensional data.
  • The foundation for orthogonality, projections, and decomposition of spaces.
  • A tool for optimization: in gradient descent, for example, the angle between the gradient and step direction determines how effectively we reduce error.

Without the ability to measure angles, we could not connect algebraic manipulations with geometric intuition or practical applications.

Try It Yourself

  1. Compute the angle between (2, 1) and (1, –1). Interpret the result.
  2. Find two vectors in 3D that form a 60° angle. Verify using the cosine formula.
  3. Consider word vectors for "cat" and "dog" in a machine learning model. Why might cosine similarity be a better measure of similarity than Euclidean distance?
  4. Challenge: In $\mathbb{R}^3$, find a vector orthogonal to both (1, 2, 3) and (3, 2, 1). What angle does it make with each of them?

By experimenting with these problems, you will see how angles provide the missing link between algebraic formulas and geometric meaning in linear algebra.

8. Projections and Decompositions

In earlier sections, we saw how the dot product measures alignment and how the cosine formula gives us angles between vectors. The next natural step is to use these tools to project one vector onto another. Projection is a way to "shadow" one vector onto the direction of another, splitting vectors into meaningful parts: one along a given direction and one perpendicular to it. This is the essence of decomposition, and it is everywhere in linear algebra, geometry, physics, and data science.

Scalar Projection

The scalar projection of a vector $u$ onto a vector $v$ measures how much of $u$ lies in the direction of $v$. It is given by:

$$ \text{proj}_{\text{scalar}}(u \text{ onto } v) = \frac{u \cdot v}{|v|}. $$

  • If this value is positive, $u$ has a component pointing in the same direction as $v$.
  • If it is negative, $u$ points partly in the opposite direction.
  • If it is zero, $u$ is completely perpendicular to $v$.

Example:
$u = (3, 4)$, $v = (1, 0)$.
Dot product: $(3 \times 1 + 4 \times 0) = 3$.
$|v| = 1$.
So the scalar projection is $3$. This tells us $u$ has a "shadow" of length $3$ on the $x$-axis.

Vector Projection

The vector projection gives the actual arrow in the direction of $v$ that corresponds to this scalar amount:

$$ \text{proj}_{\text{vector}}(u \text{ onto } v) = \frac{u \cdot v}{|v|^2} , v. $$

This formula normalizes $v$ into a unit vector, then scales it by the scalar projection.
The result is a new vector lying along $v$, capturing exactly the "parallel" part of $u$.

Example:
$u = (3, 4)$, $v = (1, 2)$

  • Dot product: $3 \times 1 + 4 \times 2 = 3 + 8 = 11$
  • Norm squared of $v$: $(1^2 + 2^2) = 5$
  • Coefficient: $11 / 5 = 2.2$
  • Projection vector: $2.2 \cdot (1, 2) = (2.2, 4.4)$

So the part of $(3, 4)$ in the direction of $(1, 2)$ is $(2.2, 4.4)$.

Perpendicular Component

Once we have the projection, we can find the perpendicular component (often called the rejection) simply by subtracting:

$$ u_{\perp} = u - \text{proj}_{\text{vector}}(u \text{ onto } v). $$

This gives the part of $u$ that is entirely orthogonal to $v$.

Example continued:
$u_{\perp} = (3, 4) - (2.2, 4.4) = (0.8, -0.4)$

Check:
$(0.8, -0.4) \cdot (1, 2) = 0.8 \times 1 + (-0.4) \times 2 = 0.8 - 0.8 = 0$.
Indeed, orthogonal.

Geometric Picture

Projection is like dropping a perpendicular from one vector onto another. Imagine shining a light perpendicular to v: the shadow of u on the line spanned by v is the projection. This visualization explains why projections split vectors naturally into two pieces:

  • Parallel part: Along the line of v.
  • Perpendicular part: Orthogonal to v, forming a right angle.

Together, these two parts reconstruct the original vector exactly.

Decomposition of Vectors

Every vector $u$ can be decomposed relative to another vector $v$ into two parts:

$$ u = \text{proj}{\text{vector}}(u \text{ onto } v) + \big(u - \text{proj}{\text{vector}}(u \text{ onto } v)\big). $$

This decomposition is unique and geometrically meaningful.
It generalizes to subspaces: we can project onto entire planes or higher-dimensional spans, splitting a vector into a "within-subspace" part and a "perpendicular-to-subspace" part.

Applications

  1. Physics (Work and Forces): Work is the projection of force onto displacement. Only the part of the force in the direction of motion contributes. Example: Pushing on a sled partly sideways wastes effort-the sideways component projects to zero.

  2. Geometry and Engineering: Projections are used in CAD (computer-aided design) to flatten 3D objects onto 2D surfaces, like blueprints or shadows.

  3. Computer Graphics: Rendering 3D scenes onto a 2D screen is fundamentally a projection process.

  4. Data Science: Projecting high-dimensional data onto a lower-dimensional subspace (like the first two principal components in PCA) makes patterns visible while preserving as much information as possible.

  5. Signal Processing: Decomposition into projections onto sine and cosine waves forms the basis of Fourier analysis, which powers audio, image, and video compression.

Everyday Analogies

  • Flashlight shadow: Imagine shining a flashlight so that a stick casts a shadow on the floor. The shadow is the projection of the stick onto the floor plane.
  • Team effort: If two people pull a box, the effective progress in one person's direction is the projection of the other's pull onto that direction.
  • Grades analogy: If your performance is a mix of effort and distraction, the projection onto "effort" shows how much of your work aligns with real progress.

Algebraic Properties

  • Projections are linear: proj(u + w) = proj(u) + proj(w).
  • The perpendicular part is always orthogonal to the direction of projection.
  • The decomposition is unique: no other pair of parallel and perpendicular vectors will reconstruct u.
  • The projection operator onto a unit vector v̂ satisfies: proj(u) = (v̂ v̂ᵀ)u, showing how projection can be expressed in matrix form.

Why It Matters

Projection is not just a geometric trick; it is the core of many advanced topics:

  • Least squares regression is finding the projection of a data vector onto the span of predictor vectors.
  • Orthogonal decompositions like Gram–Schmidt and QR factorization rely on projections to build orthogonal bases.
  • Optimization methods often involve projecting guesses back onto feasible sets.
  • Machine learning uses projections constantly to reduce dimensions, compare vectors, and align features.

Without projection, we could not cleanly separate influence along directions or reduce complexity in structured ways.

Try It Yourself

  1. Project (2, 3) onto (1, 0). What does the perpendicular component look like?
  2. Project (3, 1) onto (2, 2). Verify the perpendicular part is orthogonal.
  3. Decompose (5, 5, 0) into parallel and perpendicular parts relative to (1, 0, 0).
  4. Challenge: Write the projection matrix for projecting onto (1, 2). Apply it to (3, 4). Does it match the formula?

Through these exercises, you will see that projection is more than an operation-it is a lens through which we decompose, interpret, and simplify vectors and spaces.

9. Cauchy–Schwarz and Triangle Inequalities

Linear algebra is not only about operations with vectors-it also involves understanding the fundamental relationships between them. Two of the most important results in this regard are the Cauchy–Schwarz inequality and the triangle inequality. These are cornerstones of vector spaces because they establish precise boundaries for lengths, angles, and inner products. Without them, the geometry of linear algebra would fall apart.

The Cauchy–Schwarz Inequality

For any two vectors $u$ and $v$ in $\mathbb{R}^n$, the Cauchy–Schwarz inequality states:

$$ |u \cdot v| \leq |u| , |v|. $$

This means that the absolute value of the dot product of two vectors is always less than or equal to the product of their lengths.

Equality holds if and only if u and v are linearly dependent (i.e., one is a scalar multiple of the other).

Why It Is True

Recall the geometric formula for the dot product:

$$ u \cdot v = |u| , |v| \cos(\theta). $$

Since $-1 \leq \cos(\theta) \leq 1$, the magnitude of the dot product cannot exceed $|u| , |v|$.
This is exactly the inequality.

Example

Let $u = (3, 4)$ and $v = (-4, 3)$.

  • Dot product: $(3 \times -4) + (4 \times 3) = -12 + 12 = 0$
  • Norms: $|u| = 5$, $|v| = 5$
  • Product of norms: $25$
  • $|u \cdot v| = 0 \leq 25$, which satisfies the inequality

Equality does not hold since they are not multiples - they are perpendicular.

Intuition

The inequality tells us that two vectors can never "overlap" more strongly than the product of their magnitudes. If they align perfectly, the overlap is maximum (equality). If they're perpendicular, the overlap is zero.

Think of it as: "the shadow of one vector on another can never be longer than the vector itself."

The Triangle Inequality

For any vectors $u$ and $v$, the triangle inequality states:

$$ |u + v| \leq |u| + |v|. $$

This mirrors the geometric fact that in a triangle, any side is at most as long as the sum of the other two sides.

Example

Let $u = (1, 2)$ and $v = (3, 4)$.

  • $|u + v| = |(4, 6)| = \sqrt{16 + 36} = \sqrt{52} \approx 7.21$
  • $|u| + |v| = \sqrt{5} + 5 \approx 2.24 + 5 = 7.24$

Indeed, $7.21 \leq 7.24$, very close in this case.

Equality Case

The triangle inequality becomes equality when the vectors point in exactly the same direction (or are scalar multiples with nonnegative coefficients). For example, (1, 1) and (2, 2) produce equality because adding them gives a vector whose length equals the sum of their lengths.

Everyday Analogies

  • Cauchy–Schwarz: Imagine comparing two people's study habits across multiple subjects. Each vector represents hours spent in each subject. The dot product represents how much their habits "align." Cauchy–Schwarz says the alignment can never exceed the product of their individual efforts.
  • Triangle inequality: Think of walking in a city. If you want to get from home to the store and then from the store to the park, the total distance is at least as long as going straight from home to the park. There is no shortcut longer than the direct route.

Extensions

  • These inequalities hold in all inner product spaces, not just ℝⁿ. This means they apply to functions, sequences, and more abstract mathematical objects.
  • In Hilbert spaces (infinite-dimensional generalizations), they remain just as essential.

Why They Matter

  1. They guarantee that the dot product and norm are well-behaved and geometrically meaningful.
  2. They ensure that the norm satisfies the requirements of a distance measure: nonnegativity, symmetry, and triangle inequality.
  3. They underpin the validity of projections, orthogonality, and least squares methods.
  4. They are essential in proving convergence of algorithms, error bounds, and stability in numerical linear algebra.

Without these inequalities, we could not trust that the geometry of vector spaces behaves consistently.

Try It Yourself

  1. Verify Cauchy–Schwarz for (2, –1, 3) and (–1, 4, 0). Compute both sides.
  2. Try the triangle inequality for (–3, 4) and (5, –12). Does equality hold?
  3. Find two vectors where Cauchy–Schwarz is an equality. Explain why.
  4. Challenge: Prove the triangle inequality in $\mathbb{R}^2$ using only the Pythagorean theorem and algebra, without relying on dot products.

Working through these problems will show you why these inequalities are not abstract curiosities but the structural glue of linear algebra's geometry.

10. Orthonormal sets in $\mathbb{R}^2$ and $\mathbb{R}^3$

Up to now, we've discussed vectors, their lengths, angles, and how to project one onto another. A natural culmination of these ideas is the concept of orthonormal sets. These are collections of vectors that are not only orthogonal (mutually perpendicular) but also normalized (each of length 1). Orthonormal sets form the cleanest, most efficient coordinate systems in linear algebra. They are the mathematical equivalent of having rulers at right angles, perfectly calibrated to unit length.

Orthogonal and Normalized

Let's break the term "orthonormal" into two parts:

  • Orthogonal: Two vectors $u$ and $v$ are orthogonal if $u \cdot v = 0$.
    In $\mathbb{R}^2$, this means the vectors meet at a right angle.
    In $\mathbb{R}^3$, it means they form perpendicular directions.

  • Normalized: A vector $v$ is normalized if its length is $1$, i.e., $|v| = 1$.
    Such vectors are called unit vectors.

When we combine both conditions, we get orthonormal vectors: vectors that are both perpendicular to each other and have unit length.

Orthonormal Sets in $\mathbb{R}^2$

In two dimensions, an orthonormal set typically consists of two vectors.
A classic example is:

$e_1 = (1, 0), \quad e_2 = (0, 1)$

  • Dot product: $e_1 \cdot e_2 = (1 \times 0 + 0 \times 1) = 0 ;;\Rightarrow;;$ orthogonal
  • Lengths: $|e_1| = 1$, $|e_2| = 1 ;;\Rightarrow;;$ normalized

Thus, ${e_1, e_2}$ is an orthonormal set.
In fact, this is the standard basis for $\mathbb{R}^2$.
Any vector $(x, y)$ can be written as $x e_1 + y e_2$.
This is the simplest coordinate system.

Orthonormal Sets in $\mathbb{R}^3$

In three dimensions, an orthonormal set usually has three vectors.
The standard basis is:

$e_1 = (1, 0, 0), \quad e_2 = (0, 1, 0), \quad e_3 = (0, 0, 1)$

  • Each pair has dot product zero, so they are orthogonal
  • Each has length $1$, so they are normalized
  • Together, they span all of $\mathbb{R}^3$

Geometrically, they correspond to the $x$-, $y$-, and $z$-axes in 3D space.
Any vector $(x, y, z)$ can be written as a linear combination $x e_1 + y e_2 + z e_3$.

Beyond the Standard Basis

The standard basis is not the only orthonormal set. For example:

$u = \left(\tfrac{1}{\sqrt{2}}, \tfrac{1}{\sqrt{2}}\right), \quad v = \left(-\tfrac{1}{\sqrt{2}}, \tfrac{1}{\sqrt{2}}\right)$

  • Dot product: $(\tfrac{1}{\sqrt{2}})(-\tfrac{1}{\sqrt{2}}) + (\tfrac{1}{\sqrt{2}})(\tfrac{1}{\sqrt{2}}) = -\tfrac{1}{2} + \tfrac{1}{2} = 0$
  • Lengths: $\sqrt{(\tfrac{1}{\sqrt{2}})^2 + (\tfrac{1}{\sqrt{2}})^2} = \sqrt{\tfrac{1}{2} + \tfrac{1}{2}} = 1$

So ${u, v}$ is also orthonormal in $\mathbb{R}^2$.
These vectors are rotated $45^\circ$ relative to the standard axes.

Similarly, in $\mathbb{R}^3$, you can construct rotated orthonormal sets (such as unit vectors along diagonals), as long as the conditions of perpendicularity and unit length hold.

Properties of Orthonormal Sets

  1. Simplified coordinates: If ${v_1, \ldots, v_k}$ is an orthonormal set, then for any vector $u$ in their span, the coefficients are easy to compute:
    $$ c_i = u \cdot v_i $$
    This is much simpler than solving systems of equations.

  2. Pythagorean theorem generalized: If vectors are orthonormal, the squared length of their sum is the sum of the squares of their coefficients.
    For example, if $u = a v_1 + b v_2$, then
    $$ |u|^2 = a^2 + b^2 $$

  3. Projection is easy: Projecting onto an orthonormal set is straightforward — just take dot products.

  4. Matrices become nice: When vectors form the columns of a matrix, orthonormality makes that matrix an orthogonal matrix, which has special properties: its transpose equals its inverse, and it preserves lengths and angles.

Importance in $\mathbb{R}^2$ and $\mathbb{R}^3$

  • In geometry, orthonormal bases correspond to coordinate axes.
  • In physics, they represent independent directions of motion or force.
  • In computer graphics, orthonormal sets define camera axes and object rotations.
  • In engineering, they simplify stress, strain, and rotation analysis.

Even though $\mathbb{R}^2$ and $\mathbb{R}^3$ are relatively simple, the same ideas extend naturally to higher dimensions, where visualization is impossible but the algebra is identical.

Everyday Analogies

  • Navigating a city: Imagine two perpendicular streets, each marked in meters. Walking 3 units east and 4 units north gives coordinates (3, 4). That's an orthonormal system.
  • Furniture assembly: When you're told to align one part "straight up" and another "straight across," you're working with orthonormal directions.
  • Digital screens: Computer monitors use pixel grids aligned horizontally and vertically, a practical realization of orthonormality.

Why Orthonormal Sets Matter

Orthonormality is the gold standard for building bases in linear algebra:

  • It makes calculations fast and simple.
  • It ensures numerical stability in computations (important in algorithms and simulations).
  • It underpins key decompositions like QR factorization, singular value decomposition (SVD), and spectral theorems.
  • It provides the cleanest way to think about space: orthogonal, independent directions scaled to unit length.

Whenever possible, mathematicians and engineers prefer orthonormal bases over arbitrary ones.

Try It Yourself

  1. Verify that (3/5, 4/5) and (–4/5, 3/5) form an orthonormal set in $\mathbb{R}^2$.
  2. Construct three orthonormal vectors in $\mathbb{R}^3$ that are not the standard basis. Hint: start with (1/√2, 1/√2, 0) and build perpendiculars.
  3. For u = (2, 1), compute its coordinates relative to the orthonormal set {(1/√2, 1/√2), (–1/√2, 1/√2)}.
  4. Challenge: Prove that if {v₁, …, vₖ} is orthonormal, then the matrix with these as columns is orthogonal, i.e., QᵀQ = I.

Through these exercises, you will see how orthonormal sets make every aspect of linear algebra-from projections to decompositions-simpler, cleaner, and more powerful.

Closing

Lengths, angles revealed,
projections trace hidden lines,
clarity takes shape.

Chapter 2. Matrices and basic operations

Opening

Rows and columns meet,
woven grids of silent rules,
machines of order.

11. Matrices as Tables and as Machines

The next stage in our journey is to move from vectors to matrices. A matrix may look like just a rectangular array of numbers, but in linear algebra it plays two distinct and equally important roles:

  1. As a table of numbers, storing data, coefficients, or geometric patterns in a compact form.
  2. As a machine that transforms vectors into other vectors, capturing the essence of linear transformations.

Both views are valid, and learning to switch between them is crucial to building intuition.

Matrices as Tables

At the most basic level, a matrix is a grid of numbers arranged into rows and columns.

  • A $2 \times 2$ matrix has 2 rows and 2 columns:

    $$ A = \begin{bmatrix} a_{11} & a_{12} \ a_{21} & a_{22} \end{bmatrix} $$

  • A $3 \times 2$ matrix has 3 rows and 2 columns:

    $$ B = \begin{bmatrix} b_{11} & b_{12} \ b_{21} & b_{22} \ b_{31} & b_{32} \end{bmatrix} $$

Each entry $a_{ij}$ or $b_{ij}$ tells us the number in the i-th row and j-th column. The rows of a matrix can represent constraints, equations, or observations; the columns can represent features, variables, or directions.

In this sense, matrices are data containers, organizing information efficiently. That's why matrices show up in spreadsheets, statistics, computer graphics, and scientific computing.

Matrices as Machines

The deeper view of a matrix is as a function from vectors to vectors. If x is a column vector, then multiplying A·x produces a new vector.

For example:

$$ A = \begin{bmatrix} 2 & 0 \ 1 & 3 \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} 4 \ 5 \end{bmatrix}. $$

Multiplying:

$$ A\mathbf{x} = \begin{bmatrix} 2×4 + 0×5 \ 1×4 + 3×5 \end{bmatrix} = \begin{bmatrix} 8 \ 19 \end{bmatrix}. $$

Here, the matrix is acting as a machine that takes input (4, 5) and outputs (8, 19). The "machine rules" are encoded in the rows of A.

Column View of Matrix Multiplication

Another way to see it: multiplying A·x is the same as taking a linear combination of A's columns.

If

$$ A = \begin{bmatrix} a_1 & a_2 \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} x_1 \ x_2 \end{bmatrix}, $$

then:

$$ A\mathbf{x} = x_1 a_1 + x_2 a_2. $$

So the vector x tells the machine "how much" of each column to mix together. This column view is critical-it connects matrices to span, dimension, and basis ideas we saw earlier.

The Duality of Tables and Machines

  • As a table, a matrix is a static object: numbers written in rows and columns.
  • As a machine, the same numbers become instructions for transforming vectors.

This duality is not just conceptual-it's the key to understanding why linear algebra is so powerful. A dataset, once stored as a table, can be interpreted as a transformation. Likewise, a transformation, once understood, can be encoded as a table.

Examples in Practice

  1. Physics: A stress–strain matrix is a table of coefficients. But it also acts as a machine that transforms applied forces into deformations.
  2. Computer Graphics: A 2D rotation matrix is a machine that spins vectors, but it can be stored in a simple 2×2 table.
  3. Economics: Input–output models use matrices as tables of production coefficients. Applying them to demand vectors transforms them into resource requirements.

Geometric Intuition

Every 2×2 or 3×3 matrix corresponds to some linear transformation in the plane or space. Examples:

  • Scaling: $\begin{bmatrix} 2 & 0 \ 0 & 2 \end{bmatrix}$ doubles lengths.
  • Reflection: $\begin{bmatrix} 1 & 0 \ 0 & -1 \end{bmatrix}$ flips across the x-axis.
  • Rotation: $\begin{bmatrix} \cos θ & -\sin θ \ \sin θ & \cos θ \end{bmatrix}$ rotates vectors by θ.

These are not just tables of numbers-they are precise, reusable machines.

Why This Matters

This section sets the stage for all matrix theory:

  • Thinking of matrices as tables helps in data interpretation and organization.
  • Thinking of matrices as machines helps in understanding linear transformations, eigenvalues, and decompositions.
  • Most importantly, learning to switch between the two perspectives makes linear algebra both concrete and abstract-bridging computation with geometry.

Try It Yourself

  1. Write a 2×3 matrix and identify its rows and columns. What might they represent in a real-world dataset?
  2. Multiply $\begin{bmatrix} 1 & 2 \ 3 & 4 \end{bmatrix}$ by $\begin{bmatrix} 2 \ –1 \end{bmatrix}$. Interpret the result using both the row and column views.
  3. Construct a matrix that scales vectors by 2 along the x-axis and reflects them across the y-axis. Test it on (1, 1).
  4. Challenge: Show how the same 3×3 rotation matrix can be viewed as a data table of cosines/sines and as a machine that turns input vectors.

By mastering both perspectives, you'll see matrices not just as numbers but as dynamic objects that encode and execute transformations.

12. Matrix Shapes, Indexing, and Block Views

Matrices come in many shapes and sizes, and the way we label their entries matters. This section is about learning how to read and write matrices carefully, how to work with rows and columns, and how to use block structure to simplify problems. These seemingly simple ideas are what allow us to manipulate large systems with precision and efficiency.

Shapes of Matrices

The shape of a matrix is given by its number of rows and columns:

  • A m×n matrix has m rows and n columns.
  • Rows run horizontally, columns run vertically.
  • Square matrices have m = n; rectangular matrices have m ≠ n.

Examples:

  • A 2×3 matrix:

    $$ \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix} $$

  • A 3×2 matrix:

    $$ \begin{bmatrix} 7 & 8 \ 9 & 10 \ 11 & 12 \end{bmatrix} $$

Shape matters because it determines whether certain operations (like multiplication) are possible.

Indexing: The Language of Entries

Each entry in a matrix has two indices: one for its row, one for its column.

  • $a_{ij}$ = entry in row i, column j.
  • The first index always refers to the row, the second to the column.

For example, in

$$ A = \begin{bmatrix} 1 & 4 & 7 \ 2 & 5 & 8 \ 3 & 6 & 9 \end{bmatrix}, $$

we have:

  • $a_{11} = 1$, $a_{23} = 8$, $a_{32} = 6$.

Indexing is the grammar of matrix language. Without it, we can't specify positions or write formulas clearly.

Rows and Columns as Vectors

Every row and every column of a matrix is itself a vector.

  • The i-th row is written as $A_{i,*}$.
  • The j-th column is written as $A_{*,j}$.

Example: From the matrix above,

  • First row: (1, 4, 7).
  • Second column: (4, 5, 6).

This duality is powerful: rows often represent constraints or equations, while columns represent directions or features. Later, when we interpret matrix–vector products, we'll see that multiplying A·x means combining columns, while multiplying yᵀ·A means combining rows.

Submatrices

Sometimes we want just part of a matrix. A submatrix is formed by selecting certain rows and columns.

Example: From

$$ B = \begin{bmatrix} 2 & 4 & 6 \ 1 & 3 & 5 \ 7 & 8 & 9 \end{bmatrix}, $$

the submatrix of the first two rows and last two columns is:

$$ \begin{bmatrix} 4 & 6 \ 3 & 5 \end{bmatrix}. $$

Submatrices allow us to zoom in and isolate parts of a problem.

Block Matrices: Dividing to Conquer

Large matrices can often be broken into blocks, which are smaller submatrices arranged inside. This is like dividing a spreadsheet into quadrants.

For example:

$$ C = \begin{bmatrix} A_{11} & A_{12} \ A_{21} & A_{22} \end{bmatrix}, $$

where each $A_{ij}$ is itself a smaller matrix.

This structure is useful in:

  • Computation: Algorithms often process blocks instead of individual entries.
  • Theory: Many proofs and factorizations rely on viewing a matrix in blocks (e.g., LU, QR, Schur decomposition).
  • Applications: Partitioning data tables into logical sections.

Example: Splitting a 4×4 matrix into four 2×2 blocks helps us treat it as a "matrix of matrices."

Special Shapes

Some shapes of matrices are so common they deserve names:

  • Row vector: 1×n matrix.
  • Column vector: n×1 matrix.
  • Diagonal matrix: Nonzero entries only on the diagonal.
  • Identity matrix: Square diagonal matrix with 1's on the diagonal.
  • Zero matrix: All entries are 0.

Recognizing these shapes saves time and clarifies reasoning.

Everyday Analogies

  • Spreadsheets: A matrix is like a grid of cells, each with a row and column label. Indexing lets you specify exactly which cell you mean.
  • Maps: Cities on a map can be located by coordinates (row, column). The same logic applies to entries in a matrix.
  • Lego blocks: Just as large Lego structures are built from smaller blocks, large matrices are often analyzed by splitting into submatrices.

Why It Matters

Careful attention to matrix shapes, indexing, and block views ensures:

  1. Precision: We can describe positions unambiguously.
  2. Structure awareness: Recognizing patterns (diagonal, triangular, block) leads to more efficient computations.
  3. Scalability: Block partitioning is the foundation of modern numerical linear algebra libraries, where matrices are too large to handle entry by entry.
  4. Geometry: Rows and columns as vectors connect matrix structure to span, basis, and dimension.

These basic tools prepare us for multiplication, transformations, and factorization.

Try It Yourself

  1. Write a 3×4 matrix and label the entry in row 2, column 3.

  2. Extract a 2×2 submatrix from the corners of a 4×4 matrix of your choice.

  3. Break a 6×6 matrix into four 3×3 blocks. How would you represent it compactly?

  4. Challenge: Given

    $$ D = \begin{bmatrix} 1 & 2 & 3 & 4 \ 5 & 6 & 7 & 8 \ 9 & 10 & 11 & 12 \end{bmatrix}, $$

    write it as a block matrix with a 2×2 block in the top-left, a 2×2 block in the top-right, and a 1×4 block in the bottom row.

By practicing with shapes, indexing, and blocks, you'll develop the ability to navigate matrices not just as raw grids of numbers but as structured objects ready for deeper algebraic and geometric insights.

13. Matrix Addition and Scalar Multiplication

Before exploring matrix–vector and matrix–matrix multiplication, it is essential to understand the simplest operations we can perform with matrices: addition and scalar multiplication. These operations extend the rules we learned for vectors, but now applied to entire grids of numbers. Although straightforward, they are the foundation for more complex algebraic manipulations and help establish the idea of matrices as elements of a vector space.

Matrix Addition: Entry by Entry

If two matrices $A$ and $B$ have the same shape (same number of rows and columns), we can add them by adding corresponding entries.

Formally: If

$$ A = [a_{ij}], \quad B = [b_{ij}], $$

then

$$ A + B = [a_{ij} + b_{ij}]. $$

Example:

$$ \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix} + \begin{bmatrix} 7 & 8 & 9 \ 10 & 11 & 12 \end{bmatrix}

\begin{bmatrix} 8 & 10 & 12 \ 14 & 16 & 18 \end{bmatrix}. $$

Key point: Addition is only defined if the matrices are the same shape. A 2×3 matrix cannot be added to a 3×2 matrix.

Scalar Multiplication: Scaling Every Entry

A scalar multiplies every entry of a matrix.

Formally: For scalar $c$ and matrix $A = [a_{ij}]$,

$$ cA = [c \cdot a_{ij}]. $$

Example:

$$ 3 \cdot \begin{bmatrix} 2 & -1 \ 0 & 4 \end{bmatrix}

\begin{bmatrix} 6 & -3 \ 0 & 12 \end{bmatrix}. $$

This mirrors vector scaling: stretching or shrinking the whole matrix by a constant factor.

Properties of Addition and Scalar Multiplication

These two operations satisfy familiar algebraic properties that make the set of all m×n matrices into a vector space:

  1. Commutativity: $A + B = B + A$.
  2. Associativity: $(A + B) + C = A + (B + C)$.
  3. Additive identity: $A + 0 = A$, where 0 is the zero matrix.
  4. Additive inverse: For every $A$, there exists $-A$ such that $A + (-A) = 0$.
  5. Distributivity: $c(A + B) = cA + cB$.
  6. Compatibility: $(c + d)A = cA + dA$.
  7. Scalar associativity: $(cd)A = c(dA)$.
  8. Unit scalar: $1A = A$.

These guarantee that working with matrices feels like working with numbers and vectors, only in a higher-level setting.

Matrix Arithmetic as Table Operations

From the table view, addition and scalar multiplication are just simple bookkeeping: line up two tables of the same shape and add entry by entry; multiply the whole table by a constant.

Example: Imagine two spreadsheets of monthly expenses. Adding them gives combined totals. Multiplying by 12 converts a monthly table into a yearly estimate.

Matrix Arithmetic as Machine Operations

From the machine view, these operations adjust the behavior of linear transformations:

  • Adding matrices corresponds to adding their effects when applied to vectors.
  • Scaling a matrix scales the effect of the transformation.

Example: Let $A$ rotate vectors slightly, and $B$ stretch vectors. The matrix $A + B$ represents a transformation that applies both influences together. Scaling by 2 doubles the effect of the transformation.

Special Case: Zero and Identity

  • Zero matrix: All entries are 0. Adding it to any matrix changes nothing.
  • Scalar multiples of the identity: $cI$ scales every vector by c when applied. For example, $2I$ doubles every vector's length.

These act as neutral or scaling elements in matrix arithmetic.

Geometric Intuition

  1. In $\mathbb{R}^2$ or $\mathbb{R}^3$, adding transformation matrices is like superimposing geometric effects: e.g., one matrix shears, another rotates, their sum mixes both.
  2. Scaling a transformation makes its action stronger or weaker. Doubling a shear makes it twice as pronounced.

This shows that even before multiplication, addition and scaling already have geometric meaning.

Everyday Analogies

  • Recipes: Adding two recipes (matrices) ingredient by ingredient gives a combined shopping list. Multiplying a recipe by 3 scales it for 3 times as many people.
  • Financial planning: Adding two budget tables gives a combined budget. Multiplying by 12 scales monthly costs to yearly totals.
  • Mixing effects: Think of audio signals represented by matrices. Adding them overlays sounds; scaling adjusts volume.

Why It Matters

Though simple, these operations:

  • Define matrices as elements of vector spaces.
  • Lay the groundwork for linear combinations of matrices, critical in eigenvalue problems, optimization, and control theory.
  • Enable modular problem-solving: break big transformations into smaller ones and recombine them.
  • Appear everywhere in practice, from combining datasets to scaling transformations.

Without addition and scalar multiplication, we could not treat matrices systematically as algebraic objects.

Try It Yourself

  1. Add

$$ \begin{bmatrix} 2 & 0 \ 1 & 3 \end{bmatrix} \quad \text{and} \quad \begin{bmatrix} -2 & 5 \ 4 & -3 \end{bmatrix}. $$

  1. Multiply

$$ \begin{bmatrix} 1 & -1 & 2 \ 0 & 3 & 4 \end{bmatrix} $$

by –2.

  1. Show that (A + B) + C = A + (B + C) with explicit 2×2 matrices.

  2. Challenge: Construct two 3×3 matrices A and B such that A + B = 0. What does that tell you about B?

By practicing these fundamentals, you will see that even the most basic operations on matrices already build the algebraic backbone for deeper results like matrix multiplication, transformations, and factorization.

14. Matrix–Vector Product (Linear Combinations of Columns)

We now arrive at one of the most important operations in all of linear algebra: the matrix–vector product. This operation takes a matrix $A$ and a vector x, and produces a new vector. While the computation is straightforward, its interpretations are deep: it can be seen as combining rows, as combining columns, or as applying a linear transformation. This is the operation that connects matrices to the geometry of vector spaces.

The Algebraic Rule

Suppose $A$ is an $m \times n$ matrix, and x is a vector in $\mathbb{R}^n$. The product $A\mathbf{x}$ is a vector in $\mathbb{R}^m$, defined as:

$$ A = \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \ a_{21} & a_{22} & \cdots & a_{2n} \ \vdots & \vdots & \ddots & \vdots \ a_{m1} & a_{m2} & \cdots & a_{mn} \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} x_1 \ x_2 \ \vdots \ x_n \end{bmatrix}. $$

Then:

$$ A\mathbf{x} = \begin{bmatrix} a_{11}x_1 + a_{12}x_2 + \cdots + a_{1n}x_n \ a_{21}x_1 + a_{22}x_2 + \cdots + a_{2n}x_n \ \vdots \ a_{m1}x_1 + a_{m2}x_2 + \cdots + a_{mn}x_n \end{bmatrix}. $$

Each entry of the output is a dot product between one row of $A$ and the vector x.

Row View: Dot Products

From the row perspective, $A\mathbf{x}$ is computed row by row:

  • Take each row of $A$.
  • Dot it with x.
  • That result becomes one entry of the output.

Example:

$$ A = \begin{bmatrix} 2 & 1 \ 3 & 4 \ -1 & 2 \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} 5 \ -1 \end{bmatrix}. $$

  • First row dot x: $2(5) + 1(-1) = 9$.
  • Second row dot x: $3(5) + 4(-1) = 11$.
  • Third row dot x: $(-1)(5) + 2(-1) = -7$.

So:

$$ A\mathbf{x} = \begin{bmatrix} 9 \ 11 \ -7 \end{bmatrix}. $$

Column View: Linear Combinations

From the column perspective, $A\mathbf{x}$ is a linear combination of the columns of A.

If

$$ A = \begin{bmatrix} | & | & & | \ a_1 & a_2 & \cdots & a_n \ | & | & & | \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} x_1 \ x_2 \ \vdots \ x_n \end{bmatrix}, $$

then:

$$ A\mathbf{x} = x_1 a_1 + x_2 a_2 + \cdots + x_n a_n. $$

That is: multiply each column of $A$ by the corresponding entry in x, then add them up.

This interpretation connects directly to the idea of span: the set of all vectors $A\mathbf{x}$ as x varies is exactly the span of the columns of $A$.

The Machine View: Linear Transformations

The machine view ties everything together: multiplying a vector by a matrix means applying the linear transformation represented by the matrix.

  • If $A$ is a 2×2 rotation matrix, then $A\mathbf{x}$ rotates the vector x.
  • If $A$ is a scaling matrix, then $A\mathbf{x}$ stretches or shrinks x.
  • If $A$ is a projection matrix, then $A\mathbf{x}$ projects x onto a line or plane.

Thus, the algebraic definition encodes geometric and functional meaning.

Examples of Geometric Action

  1. Scaling:

$$ A = \begin{bmatrix} 2 & 0 \ 0 & 2 \end{bmatrix}. $$

Then $A\mathbf{x}$ doubles the length of any vector x.

  1. Reflection:

$$ A = \begin{bmatrix} 1 & 0 \ 0 & -1 \end{bmatrix}. $$

This flips vectors across the x-axis.

  1. Rotation by θ:

$$ A = \begin{bmatrix} \cosθ & -\sinθ \ \sinθ & \cosθ \end{bmatrix}. $$

This rotates vectors counterclockwise by θ in the plane.

Everyday Analogies

  • Mixing ingredients: The vector x is a recipe, and the columns of $A$ are the ingredients. The product $A\mathbf{x}$ is the final mixture.
  • Weighted averages: A student's final grade is a matrix–vector product: weights (the vector) multiplied by scores (the matrix columns).
  • Signal processing: Combining input signals with weights produces a new output, just like multiplying a matrix of signals by a weight vector.

Why It Matters

The matrix–vector product is the building block of everything in linear algebra:

  1. It defines the action of a matrix as a linear map.
  2. It connects directly to span and dimension (columns generate all possible outputs).
  3. It underpins solving linear systems, eigenvalue problems, and decompositions.
  4. It is the engine of computation in applied mathematics, from computer graphics to machine learning (e.g., neural networks compute billions of matrix–vector products).

Try It Yourself

  1. Compute

$$ \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix} \begin{bmatrix} 2 \ 0 \ 1 \end{bmatrix}. $$

  1. Express the result of the above product as a linear combination of the columns of the matrix.

  2. Construct a 2×2 matrix that reflects vectors across the line $y = x$. Test it on (1, 0) and (0, 1).

  3. Challenge: For a 3×3 matrix, show that the set of all possible $A\mathbf{x}$ (as x varies) is exactly the column space of $A$.

By mastering both the computational rules and the interpretations of the matrix–vector product, you will gain the most important insight in linear algebra: matrices are not just tables-they are engines that transform space.

15. Matrix–Matrix Product (Composition of Linear Steps)

Having understood how a matrix acts on a vector, the next natural step is to understand how one matrix can act on another. This leads us to the matrix–matrix product, a rule for combining two matrices into a single new matrix. Though the arithmetic looks complicated at first, the underlying idea is elegant: multiplying two matrices represents composing two linear transformations.

The Algebraic Rule

Suppose $A$ is an $m \times n$ matrix and $B$ is an $n \times p$ matrix. Their product $C = AB$ is an $m \times p$ matrix defined by:

$$ c_{ij} = \sum_{k=1}^n a_{ik} b_{kj}. $$

That is: each entry of $C$ is the dot product of the i-th row of $A$ with the j-th column of $B$.

Example: A 2×3 times a 3×2

$$ A = \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix}, \quad B = \begin{bmatrix} 7 & 8 \ 9 & 10 \ 11 & 12 \end{bmatrix}. $$

Product: $C = AB$ will be 2×2.

  • $c_{11} = 1\cdot 7 + 2\cdot 9 + 3\cdot 11 = 58$.
  • $c_{12} = 1\cdot 8 + 2\cdot 10 + 3\cdot 12 = 64$.
  • $c_{21} = 4\cdot 7 + 5\cdot 9 + 6\cdot 11 = 139$.
  • $c_{22} = 4\cdot 8 + 5\cdot 10 + 6\cdot 12 = 154$.

So:

$$ C = \begin{bmatrix} 58 & 64 \ 139 & 154 \end{bmatrix}. $$

Column View: Linear Combinations of Columns

From the column perspective, $AB$ is computed by applying $A$ to each column of $B$.

If $B = [b_1 ; b_2 ; \cdots ; b_p]$, then:

$$ AB = [A b_1 ; A b_2 ; \cdots ; A b_p]. $$

That is: multiply $A$ by each column of $B$. This is often the simplest way to think of the product.

Row View: Linear Combinations of Rows

From the row perspective, each row of $AB$ is formed by combining rows of $B$ using coefficients from a row of $A$. This dual view is less common but equally useful, especially in proofs and algorithms.

The Machine View: Composition of Transformations

The most important interpretation is the machine view: multiplying matrices corresponds to composing transformations.

  • If $A$ maps $\mathbb{R}^n \to \mathbb{R}^m$ and $B$ maps $\mathbb{R}^p \to \mathbb{R}^n$, then $AB$ maps $\mathbb{R}^p \to \mathbb{R}^m$.
  • In words: do $B$ first, then $A$.

Example:

  • Let $B$ rotate vectors by 90°.
  • Let $A$ scale vectors by 2.
  • Then $AB$ rotates and then scales-both steps combined into a single transformation.

Geometric Examples

  1. Scaling then rotation:

$$ A = \begin{bmatrix} 2 & 0 \ 0 & 2 \end{bmatrix}, \quad B = \begin{bmatrix} 0 & -1 \ 1 & 0 \end{bmatrix}. $$

Then $AB$ scales vectors by 2 after rotating them 90°.

  1. Projection then reflection: If $B$ projects onto the x-axis and $A$ reflects across the y-axis, then $AB$ represents "project then reflect."

Properties of Matrix Multiplication

  1. Associative: $(AB)C = A(BC)$.
  2. Distributive: $A(B + C) = AB + AC$.
  3. Not commutative: In general, $AB \neq BA$. Order matters!
  4. Identity: $AI = IA = A$.

These properties highlight that while multiplication is structured, it is not symmetric. The order encodes the order of operations in transformations.

Everyday Analogies

  • Cooking steps: If $B$ is "chop vegetables" and $A$ is "cook vegetables," then $AB$ is "cook after chopping." Doing it the other way (BA) would make no sense!
  • Assembly line: Each machine (matrix) performs an operation on the input. Chaining them corresponds to multiplying the matrices.
  • Maps and routes: Going from home to the station (B), then from station to office (A) equals the combined route home→office (AB).

Why It Matters

Matrix multiplication is the core of linear algebra because:

  1. It encodes function composition in algebraic form.
  2. It provides a way to capture multiple transformations in a single matrix.
  3. It underpins algorithms in computer graphics, robotics, statistics, and machine learning.
  4. It reveals deeper structure, like commutativity failing, which reflects real-world order of operations.

Almost every application of linear algebra-solving equations, computing eigenvalues, training neural networks-relies on efficient matrix multiplication.

Try It Yourself

  1. Compute

$$ \begin{bmatrix} 1 & 0 \ 2 & 3 \end{bmatrix} \begin{bmatrix} 4 & 5 \ 6 & 7 \end{bmatrix}. $$

  1. Show that $AB \neq BA$ for the matrices

$$ A = \begin{bmatrix} 0 & 1 \ 0 & 0 \end{bmatrix}, \quad B = \begin{bmatrix} 0 & 0 \ 1 & 0 \end{bmatrix}. $$

  1. Construct two 2×2 matrices where $AB = BA$. Why does commutativity happen here?

  2. Challenge: If $A$ is a projection and $B$ is a rotation, compute $AB$ and $BA$. Do they represent the same geometric operation?

Through these perspectives, the matrix–matrix product shifts from being a mechanical formula to being a language for combining linear steps-each product telling the story of "do this, then that."

16. Identity, Inverse, and Transpose

With addition, scalar multiplication, and matrix multiplication in place, we now introduce three special operations and objects that form the backbone of matrix algebra: the identity matrix, the inverse of a matrix, and the transpose of a matrix. Each captures a fundamental principle-neutrality, reversibility, and symmetry-and together they provide the algebraic structure that makes linear algebra so powerful.

The Identity Matrix

The identity matrix is the matrix equivalent of the number 1 in multiplication.

  • Definition: The identity matrix $I_n$ is the $n \times n$ matrix with 1's on the diagonal and 0's everywhere else.

Example (3×3):

$$ I_3 = \begin{bmatrix} 1 & 0 & 0 \ 0 & 1 & 0 \ 0 & 0 & 1 \end{bmatrix}. $$

  • Property: For any $n \times n$ matrix $A$,

    $$ AI_n = I_nA = A. $$

  • Machine view: $I$ does nothing-it maps every vector to itself.

The Inverse of a Matrix

The inverse is the matrix equivalent of the reciprocal of a number.

  • Definition: For a square matrix $A$, its inverse $A^{-1}$ is the matrix such that

    $$ AA^{-1} = A^{-1}A = I. $$

  • Not all matrices have inverses. A matrix is invertible if and only if it is square and its determinant is nonzero.

Example:

$$ A = \begin{bmatrix} 2 & 1 \ 1 & 1 \end{bmatrix}, \quad A^{-1} = \begin{bmatrix} 1 & -1 \ -1 & 2 \end{bmatrix}. $$

Check:

$$ AA^{-1} = \begin{bmatrix} 2 & 1 \ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & -1 \ -1 & 2 \end{bmatrix}

\begin{bmatrix} 1 & 0 \ 0 & 1 \end{bmatrix} = I. $$

  • Machine view: Applying $A$ transforms a vector. Applying $A^{-1}$ undoes that transformation, restoring the original input.

Non-Invertible Matrices

Some matrices cannot be inverted. These are called singular.

  • Example:

    $$ B = \begin{bmatrix} 2 & 4 \ 1 & 2 \end{bmatrix}. $$

    Here, the second column is a multiple of the first. The transformation squashes vectors into a line, losing information-so it cannot be reversed.

This ties invertibility to geometry: a transformation that collapses dimensions cannot be undone.

The Transpose of a Matrix

The transpose reflects a matrix across its diagonal.

  • Definition: For $A = [a_{ij}]$,

    $$ A^T = [a_{ji}]. $$

  • In words: rows become columns, columns become rows.

Example:

$$ A = \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix}, \quad A^T = \begin{bmatrix} 1 & 4 \ 2 & 5 \ 3 & 6 \end{bmatrix}. $$

  • Properties:

    • $(A^T)^T = A$.
    • $(A + B)^T = A^T + B^T$.
    • $(cA)^T = cA^T$.
    • $(AB)^T = B^T A^T$ (note the reversed order!).

Symmetric and Orthogonal Matrices

Two important classes emerge from the transpose:

  • Symmetric matrices: $A = A^T$. Example:

    $$ \begin{bmatrix} 2 & 3 \ 3 & 5 \end{bmatrix}. $$

    These have beautiful properties: real eigenvalues and orthogonal eigenvectors.

  • Orthogonal matrices: $Q^TQ = I$. Their columns form an orthonormal set, and they represent pure rotations/reflections.

Everyday Analogies

  • Identity: A mirror that doesn't distort your reflection-it leaves everything unchanged.
  • Inverse: A "reverse recipe"-if one step mixes, the inverse unmixed (where possible).
  • Transpose: Reorganizing a spreadsheet by flipping rows and columns.

Why It Matters

  1. The identity guarantees a neutral element for multiplication.
  2. The inverse provides a way to solve equations $A\mathbf{x} = \mathbf{b}$ via $\mathbf{x} = A^{-1}\mathbf{b}$.
  3. The transpose ties matrices to geometry, inner products, and symmetry.
  4. Together, they form the algebraic foundation for deeper topics: determinants, eigenvalues, factorizations, and numerical methods.

Without these tools, matrix algebra would lack structure and reversibility.

Try It Yourself

  1. Compute the transpose of

$$ \begin{bmatrix} 1 & 0 & 2 \ -3 & 4 & 5 \end{bmatrix}. $$

  1. Verify that $(AB)^T = B^TA^T$ for

$$ A = \begin{bmatrix} 1 & 2 \ 0 & 3 \end{bmatrix}, \quad B = \begin{bmatrix} 4 & 0 \ 5 & 6 \end{bmatrix}. $$

  1. Find the inverse of

$$ \begin{bmatrix} 3 & 2 \ 1 & 1 \end{bmatrix}. $$

  1. Challenge: Show that if $Q$ is orthogonal, then $Q^{-1} = Q^T$. Interpret this geometrically as saying "rotations can be undone by transposing."

Through these exercises, you'll see how identity, inverse, and transpose anchor the structure of linear algebra, providing neutrality, reversibility, and symmetry in every calculation.

17. Symmetric, Diagonal, Triangular, and Permutation Matrices

Not all matrices are created equal-some have special shapes or patterns that give them unique properties. These structured matrices are the workhorses of linear algebra: they simplify computation, reveal geometry, and form the building blocks for algorithms. In this section, we study four especially important classes: symmetric, diagonal, triangular, and permutation matrices.

Symmetric Matrices

A matrix is symmetric if it equals its transpose:

$$ A = A^T. $$

Example:

$$ \begin{bmatrix} 2 & 3 & 4 \ 3 & 5 & 6 \ 4 & 6 & 9 \end{bmatrix}. $$

  • Geometric meaning: Symmetric matrices represent linear transformations that have no "handedness." They often arise in physics (energy, covariance, stiffness).
  • Algebraic fact: Symmetric matrices have real eigenvalues and an orthonormal basis of eigenvectors. This property underpins the spectral theorem, one of the pillars of linear algebra.

Diagonal Matrices

A matrix is diagonal if all non-diagonal entries are zero.

$$ D = \begin{bmatrix} d_1 & 0 & 0 \ 0 & d_2 & 0 \ 0 & 0 & d_3 \end{bmatrix}. $$

  • Multiplying by $D$ scales each coordinate separately.

  • Computations with diagonals are lightning fast:

    • Adding: add diagonal entries.
    • Multiplying: multiply diagonal entries.
    • Inverting: invert each diagonal entry (if nonzero).

Example:

$$ \begin{bmatrix} 2 & 0 \ 0 & 3 \end{bmatrix} \begin{bmatrix} x \ y \end{bmatrix}

\begin{bmatrix} 2x \ 3y \end{bmatrix}. $$

This is why diagonalization is so valuable: turning a general matrix into a diagonal one simplifies everything.

Triangular Matrices

A matrix is upper triangular if all entries below the main diagonal are zero, and lower triangular if all entries above the diagonal are zero.

  • Upper triangular example:

    $$ \begin{bmatrix} 1 & 2 & 3 \ 0 & 4 & 5 \ 0 & 0 & 6 \end{bmatrix}. $$

  • Lower triangular example:

    $$ \begin{bmatrix} 7 & 0 & 0 \ 8 & 9 & 0 \ 10 & 11 & 12 \end{bmatrix}. $$

Why they matter:

  • Determinant = product of diagonal entries.
  • Easy to solve systems by substitution (forward or backward).
  • Every square matrix can be factored into triangular matrices (LU decomposition).

Permutation Matrices

A permutation matrix is obtained by permuting the rows (or columns) of an identity matrix.

Example:

$$ P = \begin{bmatrix} 0 & 1 & 0 \ 1 & 0 & 0 \ 0 & 0 & 1 \end{bmatrix}. $$

Multiplying by $P$:

  • On the left, permutes the rows of a matrix.
  • On the right, permutes the columns of a matrix.

Permutation matrices are used in pivoting strategies in elimination, ensuring numerical stability in solving systems. They are also orthogonal: $P^{-1} = P^T$.

Connections Between Them

  • A diagonal matrix is a special case of triangular (both upper and lower).
  • Symmetric matrices often become diagonal under orthogonal transformations.
  • Permutation matrices help reorder triangular or diagonal matrices without breaking their structure.

Together, these classes show that structure leads to simplicity-many computational algorithms exploit these patterns for speed and stability.

Everyday Analogies

  • Symmetric: A perfectly balanced seesaw-forces are mirrored on both sides.
  • Diagonal: Independent volume knobs for each channel of a stereo system-no cross-interference.
  • Triangular: Step-by-step instructions where each step depends only on earlier steps, never later ones.
  • Permutation: Shuffling cards-same elements, different order.

Why It Matters

  1. Symmetric matrices guarantee stable and interpretable eigen-decompositions.
  2. Diagonal matrices make computation effortless.
  3. Triangular matrices are the backbone of elimination and factorization methods.
  4. Permutation matrices preserve structure while reordering, critical for algorithms.

Almost every advanced method in numerical linear algebra relies on reducing general matrices into one of these structured forms.

Try It Yourself

  1. Verify that

$$ \begin{bmatrix} 1 & 2 \ 2 & 5 \end{bmatrix} $$

is symmetric. Find its transpose.

  1. Compute the determinant of

$$ \begin{bmatrix} 3 & 0 & 0 \ 0 & 4 & 0 \ 0 & 0 & 5 \end{bmatrix}. $$

  1. Solve

$$ \begin{bmatrix} 2 & 3 & 1 \ 0 & 5 & 2 \ 0 & 0 & 4 \end{bmatrix} \mathbf{x} = \begin{bmatrix} 1 \ 2 \ 3 \end{bmatrix} $$

using back substitution.

  1. Construct a 4×4 permutation matrix that swaps the first and last rows. Apply it to a 4×1 vector of your choice.

By exploring these four structured families, you'll start to see that not all matrices are messy-many have order hidden in their arrangement, and exploiting that order is the key to both theoretical understanding and efficient computation.

18. Trace and Basic Matrix Properties

So far we have studied shapes, multiplication rules, and special classes of matrices. In this section we introduce a simple but surprisingly powerful quantity: the trace of a matrix. Along with it, we review a set of basic matrix properties that provide shortcuts, invariants, and insights into how matrices behave.

Definition of the Trace

For a square matrix $A = [a_{ij}]$ of size $n \times n$, the trace is the sum of the diagonal entries:

$$ \text{tr}(A) = a_{11} + a_{22} + \cdots + a_{nn}. $$

Example:

$$ A = \begin{bmatrix} 2 & 5 & 7 \ 0 & 3 & 1 \ 4 & 6 & 8 \end{bmatrix}, \quad \text{tr}(A) = 2 + 3 + 8 = 13. $$

The trace extracts a single number summarizing the "diagonal content" of a matrix.

Properties of the Trace

The trace is linear and interacts nicely with multiplication and transposition:

  1. Linearity:

    • $\text{tr}(A + B) = \text{tr}(A) + \text{tr}(B)$.
    • $\text{tr}(cA) = c \cdot \text{tr}(A)$.
  2. Cyclic Property:

    • $\text{tr}(AB) = \text{tr}(BA)$, as long as the products are defined.
    • More generally, $\text{tr}(ABC) = \text{tr}(BCA) = \text{tr}(CAB)$.
    • But in general, $\text{tr}(AB) \neq \text{tr}(A)\text{tr}(B)$.
  3. Transpose Invariance:

    • $\text{tr}(A^T) = \text{tr}(A)$.
  4. Similarity Invariance:

    • If $B = P^{-1}AP$, then $\text{tr}(B) = \text{tr}(A)$.
    • This means the trace is a similarity invariant, depending only on the linear transformation, not the basis.

Trace and Eigenvalues

One of the most important connections is between the trace and eigenvalues:

$$ \text{tr}(A) = \lambda_1 + \lambda_2 + \cdots + \lambda_n, $$

where $\lambda_i$ are the eigenvalues of $A$ (counting multiplicity).

This links the simple diagonal sum to the deep spectral properties of the matrix.

Example:

$$ A = \begin{bmatrix} 1 & 0 \ 0 & 3 \end{bmatrix}, \quad \text{tr}(A) = 4, \quad \lambda_1 = 1, ; \lambda_2 = 3, \quad \lambda_1 + \lambda_2 = 4. $$

Other Basic Matrix Properties

Alongside the trace, here are some important algebraic facts that every student of linear algebra must know:

  1. Determinant vs. Trace:

    • For 2×2 matrices, $A = \begin{bmatrix} a & b \ c & d \end{bmatrix}$, $\text{tr}(A) = a + d$, $\det(A) = ad - bc$.
    • Together, trace and determinant encode the eigenvalues: roots of $x^2 - \text{tr}(A)x + \det(A) = 0$.
  2. Norms and Inner Products:

    • The Frobenius norm is defined using the trace: $|A|_F = \sqrt{\text{tr}(A^TA)}$.
  3. Orthogonal Invariance:

    • For any orthogonal matrix $Q$, $\text{tr}(Q^TAQ) = \text{tr}(A)$.

Geometric and Practical Meaning

  • The trace of a transformation can be seen as the sum of its action along the coordinate axes.
  • In physics, the trace of the stress tensor measures pressure.
  • In probability, the trace of a covariance matrix is the total variance of a system.
  • In statistics and machine learning, the trace is often used as a measure of overall "size" or complexity of a model.

Everyday Analogies

  • Grades on report card: The trace is like summing the "main subjects" (diagonal entries) without looking at electives (off-diagonal entries).
  • Company budget: The diagonal could represent department totals, and the trace is the grand total.
  • Lighting system: Imagine each diagonal entry is a light switch brightness for each room; the trace is the sum total brightness in the building.

Why It Matters

The trace is deceptively simple but incredibly powerful:

  1. It connects directly to eigenvalues, forming a bridge between raw matrix entries and spectral theory.
  2. It is invariant under similarity, making it a reliable measure of a transformation independent of basis.
  3. It shows up in optimization, physics, statistics, and quantum mechanics.
  4. It simplifies computations: many proofs in linear algebra reduce to trace properties.

Try It Yourself

  1. Compute the trace of

$$ \begin{bmatrix} 4 & 2 & 0 \ -1 & 3 & 5 \ 7 & 6 & 1 \end{bmatrix}. $$

  1. Verify that $\text{tr}(AB) = \text{tr}(BA)$ for

$$ A = \begin{bmatrix} 1 & 2 \ 0 & 3 \end{bmatrix}, \quad B = \begin{bmatrix} 4 & 0 \ 5 & 6 \end{bmatrix}. $$

  1. For the 2×2 matrix

$$ \begin{bmatrix} 2 & 1 \ 1 & 2 \end{bmatrix}, $$

compute its eigenvalues and check that their sum equals the trace.

  1. Challenge: Show that the total variance of a dataset with covariance matrix $\Sigma$ is equal to $\text{tr}(\Sigma)$.

Mastering the trace and its properties will prepare you for the next leap: understanding how matrices interact with volume, orientation, and determinants.

19. Affine Transforms and Homogeneous Coordinates

Up to now, matrices have been used to describe linear transformations: scaling, rotating, reflecting, projecting. But real-world geometry often involves more than just linear effects-it includes translations (shifts) as well. A pure linear map cannot move the origin, so to handle translations (and combinations of them with rotations, scalings, and shears), we extend our toolkit to affine transformations. The secret weapon that makes this work is the idea of homogeneous coordinates.

What is an Affine Transformation?

An affine transformation is any map of the form:

$$ f(\mathbf{x}) = A\mathbf{x} + \mathbf{b}, $$

where $A$ is a matrix (linear part) and $\mathbf{b}$ is a vector (translation part).

  • $A$ handles scaling, rotation, reflection, shear, or projection.
  • $\mathbf{b}$ shifts everything by a constant amount.

Examples in 2D:

  1. Rotate by 90° and then shift right by 2.
  2. Stretch vertically by 3 and shift upward by 1.

Affine maps preserve parallel lines and ratios of distances along lines, but not necessarily angles or lengths.

Why Linear Maps Alone Aren't Enough

If we only use a 2×2 matrix in 2D or 3×3 in 3D, the origin always stays fixed. That's a limitation: real-world movements (like moving a shape from one place to another) require shifting the origin too. To capture both linear and translational effects uniformly, we need a clever trick.

Homogeneous Coordinates

The trick is to add one extra coordinate.

  • In 2D, a point $(x, y)$ becomes $(x, y, 1)$.
  • In 3D, a point $(x, y, z)$ becomes $(x, y, z, 1)$.

This new representation is called homogeneous coordinates. It allows us to fold translations into matrix multiplication.

Affine Transform as a Matrix in Homogeneous Form

In 2D:

$$ \begin{bmatrix} a & b & t_x \ c & d & t_y \ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \ y \ 1 \end{bmatrix}

\begin{bmatrix} ax + by + t_x \ cx + dy + t_y \ 1 \end{bmatrix}. $$

Here,

  • The 2×2 block $\begin{bmatrix} a & b \ c & d \end{bmatrix}$ is the linear part.
  • The last column $\begin{bmatrix} t_x \ t_y \end{bmatrix}$ is the translation.

So with one unified matrix, we can handle both linear transformations and shifts.

Examples in 2D

  1. Translation by (2, 3):

$$ \begin{bmatrix} 1 & 0 & 2 \ 0 & 1 & 3 \ 0 & 0 & 1 \end{bmatrix}. $$

  1. Scaling by 2 in x and 3 in y, then shifting by (–1, 4):

$$ \begin{bmatrix} 2 & 0 & -1 \ 0 & 3 & 4 \ 0 & 0 & 1 \end{bmatrix}. $$

  1. Rotation by 90° and shift right by 5:

$$ \begin{bmatrix} 0 & -1 & 5 \ 1 & 0 & 0 \ 0 & 0 & 1 \end{bmatrix}. $$

Homogeneous Coordinates in 3D

In 3D, affine transformations use 4×4 matrices. The upper-left 3×3 block handles rotation, scaling, or shear; the last column encodes translation.

Example: translation by (2, –1, 4):

$$ \begin{bmatrix} 1 & 0 & 0 & 2 \ 0 & 1 & 0 & -1 \ 0 & 0 & 1 & 4 \ 0 & 0 & 0 & 1 \end{bmatrix}. $$

This formulation is universal in computer graphics and robotics.

Everyday Analogies

  • Photography: Moving a camera involves not only rotating it (linear part) but also translating it in space.
  • Navigation: Walking north (linear step) and then shifting east (translation).
  • Graphics software: Scaling an image larger and then dragging it to a new position-exactly affine transformations in action.

Why It Matters

  1. Unified representation: Using homogeneous coordinates, we can treat translations as matrices, enabling consistent matrix multiplication for all transformations.
  2. Practicality: This approach underpins 3D graphics pipelines, animation, CAD, robotics, and computer vision.
  3. Composability: Multiple affine transformations can be combined into a single homogeneous matrix by multiplying them.
  4. Geometry preserved: Affine maps preserve straight lines and parallelism, essential in engineering and design.

Try It Yourself

  1. Write the homogeneous matrix that reflects across the x-axis and then shifts up by 3. Apply it to $(2, 1)$.
  2. Construct a 4×4 homogeneous matrix that rotates around the z-axis by 90° and translates by (1, 2, 0).
  3. Show that multiplying two 3×3 homogeneous matrices in 2D yields another valid affine transform.
  4. Challenge: Prove that affine maps preserve parallel lines by applying a general affine matrix to two parallel lines and checking their slopes.

Mastering affine transformations and homogeneous coordinates bridges the gap between pure linear algebra and real-world geometry, giving you the mathematical foundation behind computer graphics, robotics, and spatial modeling.

20. Computing with Matrices (Cost Counts and Simple Speedups)

Thus far, we have studied what matrices are and what they represent. But in practice, working with matrices also means thinking about computation-how much work operations take, how algorithms can be sped up, and why structure matters. This section introduces the basic ideas of computational cost in matrix operations, simple strategies for efficiency, and why these considerations are crucial in modern applications.

Counting Operations: The Cost Model

The simplest way to measure the cost of a matrix operation is to count the basic arithmetic operations (additions and multiplications).

  • Matrix–vector product: For an $m \times n$ matrix and an $n \times 1$ vector:

    • Each of the $m$ output entries requires $n$ multiplications and $n-1$ additions.
    • Total cost ≈ $2mn$ operations.
  • Matrix–matrix product: For an $m \times n$ matrix times an $n \times p$ matrix:

    • Each of the $mp$ entries requires $n$ multiplications and $n-1$ additions.
    • Total cost ≈ $2mnp$ operations.
  • Gaussian elimination (solving $Ax=b$): For an $n \times n$ system:

    • Roughly $\tfrac{2}{3}n^3$ operations.

These counts show how quickly costs grow with dimension. Doubling $n$ makes the work 8 times larger for elimination.

Why Cost Counts Matter

  1. Scalability: Small problems (2×2 or 3×3) are trivial, but modern datasets involve matrices with millions of rows. Knowing the cost is essential.
  2. Feasibility: Some exact algorithms become impossible for very large matrices. Approximation methods are used instead.
  3. Optimization: Engineers and scientists design specialized algorithms to reduce costs by exploiting structure (sparsity, symmetry, triangular form).

Simple Speedups with Structure

  • Diagonal Matrices: Multiplying by a diagonal matrix costs only $n$ operations (scale each component).
  • Triangular Matrices: Solving triangular systems requires only $\tfrac{1}{2}n^2$ operations (substitution), far cheaper than general elimination.
  • Sparse Matrices: If most entries are zero, we skip multiplications by zero. For large sparse systems, cost scales with the number of nonzeros, not $n^2$.
  • Block Matrices: Breaking matrices into blocks allows algorithms to reuse optimized small-matrix routines (common in BLAS libraries).

Memory Considerations

Cost is not only arithmetic: storage also matters.

  • A dense $n \times n$ matrix requires $n^2$ entries of memory.
  • Sparse storage formats (like CSR, COO) record only nonzero entries and their positions, saving massive space.
  • Memory access speed can dominate arithmetic cost in large computations.

Parallelism and Hardware

Modern computing leverages hardware for speed:

  • Vectorization (SIMD): Perform many multiplications at once.
  • Parallelization: Split work across many CPU cores.
  • GPUs: Specialize in massive parallel matrix–vector and matrix–matrix operations (critical in deep learning).

This is why linear algebra libraries (BLAS, LAPACK, cuBLAS) are indispensable: they squeeze performance from hardware.

Everyday Analogies

  • Cooking: Preparing one dish is easy. Preparing 100 dishes means thinking about batch size, oven space, and parallel steps.
  • Budgeting: Adding two small budgets by hand is fine; merging thousands of spreadsheets requires software and structure.
  • Travel: Driving across town is quick. Driving cross-country requires fuel planning, route optimization, and rest stops-scale changes everything.

Why It Matters

  1. Efficiency: Understanding cost lets us choose the right algorithm for the job.
  2. Algorithm design: Structured matrices (diagonal, sparse, orthogonal) make computations much faster and more stable.
  3. Applications: Every field that uses matrices-graphics, optimization, statistics, AI-relies on efficient computation.
  4. Foundations: Later topics like LU/QR/SVD factorization are motivated by balancing cost and stability.

Try It Yourself

  1. Compute the number of operations required for multiplying a 1000×500 matrix with a 500×200 matrix. Compare with multiplying a 1000×1000 dense matrix by a vector.
  2. Show how solving a 3×3 triangular system is faster than Gaussian elimination. Count the exact multiplications and additions.
  3. Construct a sparse 5×5 matrix with only 7 nonzero entries. Estimate the cost of multiplying it by a vector versus a dense 5×5 matrix.
  4. Challenge: Suppose you need to store a 1,000,000×1,000,000 dense matrix. Estimate how much memory (in bytes) it would take if each entry is 8 bytes. Could it fit on a laptop? Why do sparse formats save the day?

By learning to count costs and exploit structure, you prepare yourself not only to understand matrices abstractly but also to use them effectively in real-world, large-scale problems. This balance between theory and computation is at the heart of modern linear algebra.

Closing

Patterns intertwine,
transformations gently fold,
structure in the square.

Chapter 3. Linear Systems and Elimination

21. From Equations to Matrices

Linear algebra often begins with systems of equations-collections of unknowns linked by linear relationships. While these systems can be solved directly using substitution or elimination, they quickly become messy when there are many variables. The key insight of linear algebra is that all systems of linear equations can be captured compactly by matrices and vectors. This section explains how we move from equations written out in words and symbols to the matrix form that powers computation.

A Simple Example

Consider this system of two equations in two unknowns:

$$ \begin{cases}
2x + y = 5 \
3x - y = 4
\end{cases} $$

At first glance, this is just algebra: two equations, two unknowns. But notice the structure: each equation is a sum of multiples of the variables, set equal to a constant. This pattern-linear combinations of unknowns equal to a result-is exactly what matrices capture.

Writing in Coefficient Table Form

Extract the coefficients of each variable from the system:

  • First equation: coefficients are $2$ for $x$, $1$ for $y$.
  • Second equation: coefficients are $3$ for $x$, $-1$ for $y$.

Arrange these coefficients in a rectangular array:

$$ A = \begin{bmatrix}
2 & 1 \
3 & -1
\end{bmatrix}. $$

This matrix $A$ is called the coefficient matrix.

Next, write the unknowns as a vector:

$$ \mathbf{x} = \begin{bmatrix} x \ y \end{bmatrix}. $$

Finally, write the right-hand side constants as another vector:

$$ \mathbf{b} = \begin{bmatrix} 5 \ 4 \end{bmatrix}. $$

Now the entire system can be written in a single line:

$$ A\mathbf{x} = \mathbf{b}. $$

Why This is Powerful

This compact form hides no information; it is equivalent to the original equations. But it gives us enormous advantages:

  1. Clarity: We see the structure clearly-the system is "matrix times vector equals vector."
  2. Scalability: Whether we have 2 equations or 2000, the same notation applies.
  3. Tools: All the machinery of matrix operations (elimination, inverses, decompositions) now becomes available.
  4. Geometry: The matrix equation $A\mathbf{x} = \mathbf{b}$ means: combine the columns of $A$ (scaled by entries of x) to land on b.

A Larger Example

System of three equations in three unknowns:

$$ \begin{cases}
x + 2y - z = 2 \
2x - y + 3z = 1 \
3x + y + 2z = 4
\end{cases} $$

  • Coefficient matrix:

    $$ A = \begin{bmatrix}
    1 & 2 & -1 \
    2 & -1 & 3 \
    3 & 1 & 2
    \end{bmatrix}. $$

  • Unknown vector:

    $$ \mathbf{x} = \begin{bmatrix} x \ y \ z \end{bmatrix}. $$

  • Constant vector:

    $$ \mathbf{b} = \begin{bmatrix} 2 \ 1 \ 4 \end{bmatrix}. $$

Matrix form:

$$ A\mathbf{x} = \mathbf{b}. $$

This single equation captures three equations and three unknowns in one object.

Row vs. Column View

  • Row view: Each row of $A$ dotted with x gives one equation.
  • Column view: The entire system means b is a linear combination of the columns of $A$.

For the 2×2 case earlier:

$$ A\mathbf{x} = \begin{bmatrix} 2 & 1 \ 3 & -1 \end{bmatrix}
\begin{bmatrix} x \ y \end{bmatrix}
= x \begin{bmatrix} 2 \ 3 \end{bmatrix} + y \begin{bmatrix} 1 \ -1 \end{bmatrix}. $$

So solving the system means finding scalars $x, y$ that combine the columns of $A$ to reach $\mathbf{b}$.

Augmented Matrix Form

Sometimes we want to save space further. We can put the coefficients and constants side by side in an augmented matrix:

$$ [A | \mathbf{b}] =
\begin{bmatrix}
2 & 1 & | & 5 \
3 & -1 & | & 4
\end{bmatrix}. $$

This form is especially useful for elimination methods, where we manipulate rows without writing variables at each step.

Everyday Analogies

  • Recipes: A recipe tells you how many units of each ingredient (coefficients) produce the dish (constant result). Writing it as a matrix is like organizing all recipes into a clean table.
  • Schedules: Each row of a timetable (equation) corresponds to one condition. Putting it into matrix form organizes it into one big grid.
  • Construction: The coefficients are like "how many bricks per wall," while the vector x is "number of walls built." The product gives total bricks, and the system sets the required totals.

Why It Matters

This step-rewriting equations as matrix form-is the gateway into linear algebra. Once you can do it, you no longer think of systems of equations as isolated lines on paper, but as a unified object that can be studied with general tools. It opens the door to:

  • Gaussian elimination,
  • rank and null space,
  • determinants,
  • eigenvalues,
  • optimization methods.

Every major idea flows from this compact representation.

Try It Yourself

  1. Write the system

    $$ \begin{cases}
    4x - y = 7 \
    -2x + 3y = 5
    \end{cases} $$

    in matrix form.

  2. For the system

    $$ \begin{cases}
    x + y + z = 6 \
    2x - y + z = 3 \
    x - y - z = -2
    \end{cases} $$

    build the coefficient matrix, unknown vector, and constant vector.

  3. Express the augmented matrix for the above system.

  4. Challenge: Interpret the system in column view. What does it mean geometrically to express $(6, 3, -2)$ as a linear combination of the columns of the coefficient matrix?

By practicing these rewrites, you will see that linear algebra is not about juggling many equations-it is about seeing structure in one compact equation. This step transforms scattered equations into the language of matrices, where the real power begins.

22. Row Operations

Once a system of linear equations has been expressed as a matrix, the next step is to simplify that matrix into a form where the solutions become clear. The main tool for this simplification is the set of elementary row operations. These operations allow us to manipulate the rows of a matrix in systematic ways that preserve the solution set of the corresponding system of equations.

The Three Types of Row Operations

There are exactly three types of legal row operations, each with a clear algebraic meaning:

  1. Row Swapping ($R_i \leftrightarrow R_j$): Exchange two rows. This corresponds to reordering equations in a system. Since the order of equations doesn't change the solutions, this operation is always valid.

    Example:

    $$ \begin{bmatrix}
    2 & 1 & | & 5 \
    3 & -1 & | & 4
    \end{bmatrix}
    \quad \longrightarrow \quad
    \begin{bmatrix}
    3 & -1 & | & 4 \
    2 & 1 & | & 5
    \end{bmatrix}. $$

  2. Row Scaling ($R_i \to cR_i, ; c \neq 0$): Multiply all entries in a row by a nonzero constant. This is like multiplying both sides of an equation by the same number, which doesn't change its truth.

    Example:

    $$ \begin{bmatrix}
    2 & 1 & | & 5 \
    3 & -1 & | & 4
    \end{bmatrix}
    \quad \longrightarrow \quad
    \begin{bmatrix}
    1 & \tfrac{1}{2} & | & \tfrac{5}{2} \
    3 & -1 & | & 4
    \end{bmatrix}. $$

  3. Row Replacement ($R_i \to R_i + cR_j$): Add a multiple of one row to another. This corresponds to replacing one equation with a linear combination of itself and another, a fundamental elimination step.

    Example:

    $$ \begin{bmatrix}
    2 & 1 & | & 5 \
    3 & -1 & | & 4
    \end{bmatrix}
    \quad \overset{R_2 \to R_2 - \tfrac{3}{2}R_1}{\longrightarrow} \quad
    \begin{bmatrix}
    2 & 1 & | & 5 \
    0 & -\tfrac{5}{2} & | & -\tfrac{7}{2}
    \end{bmatrix}. $$

Why These Are the Only Allowed Operations

These three operations are the backbone of elimination because they do not alter the solution set of the system. Each is equivalent to applying an invertible transformation:

  • Row swaps are reversible (swap back).
  • Row scalings by $c$ can be undone by scaling by $1/c$.
  • Row replacements can be undone by adding the opposite multiple.

Thus, each operation is invertible, and the transformed system is always equivalent to the original.

Row Operations as Matrices

Each elementary row operation can itself be represented by multiplying on the left with a special matrix called an elementary matrix.

For example:

  • Swapping rows 1 and 2 in a 2×2 system is done by

    $$ E = \begin{bmatrix} 0 & 1 \ 1 & 0 \end{bmatrix}. $$

  • Scaling row 1 by 3 in a 2×2 system is done by

    $$ E = \begin{bmatrix} 3 & 0 \ 0 & 1 \end{bmatrix}. $$

This perspective is crucial later for factorization methods like LU decomposition, where elimination is expressed as a product of elementary matrices.

Step-by-Step Example

System:

$$ \begin{cases}
x + 2y = 4 \
3x + 4y = 10
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 2 & | & 4 \
3 & 4 & | & 10
\end{bmatrix}. $$

  1. Eliminate the $3x$ under the first pivot: $R_2 \to R_2 - 3R_1$.

    $$ \begin{bmatrix}
    1 & 2 & | & 4 \
    0 & -2 & | & -2
    \end{bmatrix}. $$

  2. Scale the second row: $R_2 \to -\tfrac{1}{2}R_2$.

    $$ \begin{bmatrix}
    1 & 2 & | & 4 \
    0 & 1 & | & 1
    \end{bmatrix}. $$

  3. Eliminate above the pivot: $R_1 \to R_1 - 2R_2$.

    $$ \begin{bmatrix}
    1 & 0 & | & 2 \
    0 & 1 & | & 1
    \end{bmatrix}. $$

Solution: $x = 2, ; y = 1$.

Geometry of Row Operations

Row operations do not alter the solution space:

  • Swapping rows reorders equations but keeps the same lines or planes.
  • Scaling rows rescales equations but leaves their geometric set unchanged.
  • Adding rows corresponds to combining constraints, but the shared intersection (solution set) is preserved.

Thus, row operations act like "reshaping the system" while leaving the intersection intact.

Everyday Analogies

  • Cooking recipe: Scaling a row is like doubling all ingredients in one recipe-it doesn't change the proportions.
  • Task list: Swapping two rows is just reordering tasks; nothing about the tasks themselves changes.
  • Budgeting: Adding one department's budget equation to another is just reorganizing financial records, not altering totals.

Why It Matters

Row operations are the essential moves in solving linear systems by hand or computer. They:

  1. Make elimination systematic.
  2. Preserve solution sets while simplifying structure.
  3. Lay the groundwork for echelon forms, rank, and factorization.
  4. Provide the mechanical steps that computers automate in Gaussian elimination.

Try It Yourself

  1. Apply row operations to reduce

    $$ \begin{bmatrix}
    2 & 1 & | & 7 \
    1 & -1 & | & 1
    \end{bmatrix} $$

    to a form where the solution is obvious.

  2. Show explicitly why swapping two equations in a system doesn't change its solutions.

  3. Construct the elementary matrix for "add –2 times row 1 to row 3" in a 3×3 system.

  4. Challenge: Prove that any elementary row operation corresponds to multiplication by an invertible matrix.

Mastering these operations equips you with the mechanical and conceptual foundation for the next stage: systematically reducing matrices to row-echelon form.

23. Row-Echelon and Reduced Row-Echelon Forms

After introducing row operations, the natural question is: what are we trying to achieve by performing them? The answer is to transform a matrix into a standardized, simplified form where the solutions to the corresponding system of equations can be read off directly. Two such standardized forms are central in linear algebra: row-echelon form (REF) and reduced row-echelon form (RREF).

Row-Echelon Form (REF)

A matrix is in row-echelon form if:

  1. All nonzero rows are above any rows of all zeros.
  2. In each nonzero row, the first nonzero entry (called the leading entry or pivot) is to the right of the leading entry of the row above it.
  3. All entries below a pivot are zero.

Example of REF:

$$ \begin{bmatrix}
1 & 2 & 3 & | & 4 \
0 & 1 & -1 & | & 2 \
0 & 0 & 5 & | & -3 \
0 & 0 & 0 & | & 0
\end{bmatrix}. $$

Here, the pivots are the first 1 in row 1, the 1 in row 2, and the 5 in row 3. Each pivot is to the right of the one above it, and all entries below pivots are zero.

Reduced Row-Echelon Form (RREF)

A matrix is in reduced row-echelon form if, in addition to the rules of REF:

  1. Each pivot is equal to 1.
  2. Each pivot is the only nonzero entry in its column (everything above and below pivots is zero).

Example of RREF:

$$ \begin{bmatrix}
1 & 0 & 0 & | & 3 \
0 & 1 & 0 & | & -2 \
0 & 0 & 1 & | & 1
\end{bmatrix}. $$

This form is so simplified that solutions can be read directly: here, $x=3$, $y=-2$, $z=1$.

Relationship Between REF and RREF

  • REF is easier to reach-it only requires eliminating entries below pivots.
  • RREF requires going further-clearing entries above pivots and scaling pivots to 1.
  • Every matrix can be reduced to REF (many possible versions), but RREF is unique: no matter how you proceed, if you carry out all row operations fully, you end with the same RREF.

Example: Step-by-Step to RREF

System:

$$ \begin{cases}
x + 2y + z = 4 \
2x + 5y + z = 7 \
3x + 6y + 2z = 10
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 2 & 1 & | & 4 \
2 & 5 & 1 & | & 7 \
3 & 6 & 2 & | & 10
\end{bmatrix}. $$

  1. Eliminate below first pivot (the 1 in row 1, col 1):

    • $R_2 \to R_2 - 2R_1$
    • $R_3 \to R_3 - 3R_1$

    $$ \begin{bmatrix}
    1 & 2 & 1 & | & 4 \
    0 & 1 & -1 & | & -1 \
    0 & 0 & -1 & | & -2
    \end{bmatrix}. $$

    This is now in REF.

  2. Scale pivots and eliminate above them:

    • $R_3 \to -R_3$ to make pivot 1.
    • $R_2 \to R_2 + R_3$.
    • $R_1 \to R_1 - R_2 - R_3$.

    Final:

    $$ \begin{bmatrix}
    1 & 0 & 0 & | & 2 \
    0 & 1 & 0 & | & 1 \
    0 & 0 & 1 & | & 2
    \end{bmatrix}. $$

Solution: $x=2, y=1, z=2$.

Geometry of REF and RREF

  • REF corresponds to simplifying the system step by step, making it "triangular" so variables can be solved one after another.
  • RREF corresponds to a system that is fully disentangled-each variable isolated, with its value or free-variable relationship explicitly visible.

Everyday Analogies

  • Filing papers: REF is like stacking documents in neat piles, but still grouped. RREF is like sorting every document individually into labeled folders.
  • Solving a puzzle: REF gives you partial progress (pieces are grouped), while RREF finishes the puzzle so each piece is in its exact place.
  • Cooking: REF is like preparing ingredients into rough categories (vegetables chopped, meat trimmed). RREF is the final stage where every dish is cooked and plated, fully ready.

Why It Matters

  1. REF is the foundation of Gaussian elimination, the workhorse algorithm for solving systems.
  2. RREF gives complete clarity: unique representation of solution sets, revealing free and pivot variables.
  3. RREF underlies algorithms in computer algebra systems, symbolic solvers, and educational tools.
  4. Understanding these forms builds intuition for rank, null space, and solution structure.

Try It Yourself

  1. Reduce

    $$ \begin{bmatrix}
    2 & 4 & | & 6 \
    1 & 3 & | & 5
    \end{bmatrix} $$

    to REF, then RREF.

  2. Find the RREF of

    $$ \begin{bmatrix}
    1 & 1 & 1 & | & 3 \
    2 & 3 & 4 & | & 8 \
    1 & 2 & 3 & | & 5
    \end{bmatrix}. $$

  3. Explain why two different elimination sequences can lead to different REF but the same RREF.

  4. Challenge: Prove that every matrix has a unique RREF by considering the effect of row operations systematically.

Reaching row-echelon and reduced row-echelon forms transforms messy systems into structured ones, turning algebraic clutter into an organized path to solutions.

24. Pivots, Free Variables, and Leading Ones

When reducing a matrix to row-echelon or reduced row-echelon form, certain positions in the matrix take on a special importance. These are the pivots-the leading nonzero entries in each row. Around them, the entire solution structure of a linear system is organized. Understanding pivots, the variables they anchor, and the freedom that arises from non-pivot columns is essential to solving linear equations systematically.

What is a Pivot?

In row-echelon form, a pivot is the first nonzero entry in a row, moving from left to right. After scaling in reduced row-echelon form, each pivot is set to exactly 1.

Example:

$$ \begin{bmatrix}
1 & 2 & 0 & | & 5 \
0 & 1 & 3 & | & -2 \
0 & 0 & 0 & | & 0
\end{bmatrix} $$

  • Pivot in row 1: the 1 in column 1.
  • Pivot in row 2: the 1 in column 2.
  • Column 3 has no pivot.

Columns with pivots are pivot columns. Columns without pivots correspond to free variables.

Pivot Variables vs. Free Variables

  • Pivot variables: Variables that align with pivot columns. They are determined by the equations.
  • Free variables: Variables that align with non-pivot columns. They are unconstrained and can take arbitrary values.

Example:

$$ \begin{bmatrix}
1 & 0 & 2 & | & 3 \
0 & 1 & -1 & | & 4
\end{bmatrix}. $$

This corresponds to:

$$ x_1 + 2x_3 = 3, \quad x_2 - x_3 = 4. $$

Here:

  • $x_1$ and $x_2$ are pivot variables (from pivot columns 1 and 2).
  • $x_3$ is a free variable.

Thus, $x_1$ and $x_2$ depend on $x_3$:

$$ x_1 = 3 - 2x_3, \quad x_2 = 4 + x_3, \quad x_3 \text{ free}. $$

The solution set is infinite, described by the freedom in $x_3$.

Geometric Meaning

  • Pivot variables represent coordinates that are "pinned down."
  • Free variables correspond to directions along which the solution can extend infinitely.

In 2D:

  • If there is one pivot variable and one free variable, solutions form a line. In 3D:
  • Two pivots, one free → solutions form a line.
  • One pivot, two free → solutions form a plane.

Thus, the number of free variables determines the dimension of the solution set.

Rank and Free Variables

The number of pivot columns equals the rank of the matrix.

If the coefficient matrix $A$ is $m \times n$:

  • Rank = number of pivots.
  • Number of free variables = $n - \text{rank}(A)$.

This is the rank–nullity connection in action:

$$ \text{number of variables} = \text{rank} + \text{nullity}. $$

Step-by-Step Example

System:

$$ \begin{cases}
x + 2y + z = 4 \
2x + 5y + z = 7
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 2 & 1 & | & 4 \
2 & 5 & 1 & | & 7
\end{bmatrix}. $$

Reduce:

  • $R_2 \to R_2 - 2R_1$ →

    $$ \begin{bmatrix}
    1 & 2 & 1 & | & 4 \
    0 & 1 & -1 & | & -1
    \end{bmatrix}. $$

Now:

  • Pivot columns: 1 and 2 → variables $x, y$.
  • Free column: 3 → variable $z$.

Solution:

$$ x = 4 - 2y - z, \quad y = -1 + z, \quad z \text{ free}. $$

Substitute:

$$ (x, y, z) = (6 - 3z, ; -1 + z, ; z). $$

Solutions form a line in 3D parameterized by $z$.

Why Leading Ones Matter

In RREF, each pivot is scaled to 1, making it easy to isolate pivot variables. Without leading ones, equations may still be correct but harder to interpret.

For example:

$$ \begin{bmatrix}
2 & 0 & | & 6 \
0 & -3 & | & 9
\end{bmatrix} $$

becomes

$$ \begin{bmatrix}
1 & 0 & | & 3 \
0 & 1 & | & -3
\end{bmatrix}. $$

The solutions are immediately visible: $x=3, y=-3$.

Everyday Analogies

  • Team roles: Pivot variables are assigned jobs, while free variables can choose freely, shaping the group's flexibility.
  • Recipe ingredients: Pivots are required ingredients with fixed proportions, free variables are optional additions.
  • Construction plans: Pivot columns are load-bearing beams, free columns are spaces that can be filled in flexibly.

Why It Matters

  1. Identifying pivots shows which variables are determined and which are free.
  2. The number of pivots defines rank, a central concept in linear algebra.
  3. Free variables determine whether the system has a unique solution, infinitely many, or none.
  4. Leading ones in RREF give immediate transparency to the solution set.

Try It Yourself

  1. Reduce

    $$ \begin{bmatrix}
    1 & 3 & 1 & | & 5 \
    2 & 6 & 2 & | & 10
    \end{bmatrix} $$

    and identify pivot and free variables.

  2. For the system

    $$ x + y + z = 2, \quad 2x + 3y + 5z = 7, $$

    write the RREF and express the solution with free variables.

  3. Compute the rank and number of free variables of a 3×5 matrix with two pivot columns.

  4. Challenge: Show that if the number of pivots equals the number of variables, the system has either no solution or a unique solution, but never infinitely many.

Understanding pivots and free variables provides the key to classifying solution sets: unique, infinite, or none. This classification lies at the heart of solving linear systems.

25. Solving Consistent Systems

A system of linear equations is called consistent if it has at least one solution. Consistency is the first property to check when working with a system, because before worrying about uniqueness or parametrization, we must know whether a solution exists at all. This section explains how to recognize consistent systems, how to solve them using row-reduction, and how to describe their solutions in terms of pivots and free variables.

What Consistency Means

Given a system $A\mathbf{x} = \mathbf{b}$:

  • Consistent: At least one solution $\mathbf{x}$ satisfies the system.
  • Inconsistent: No solution exists.

Consistency depends on the relationship between the vector $\mathbf{b}$ and the column space of $A$:

$$ \mathbf{b} \in \text{Col}(A) \quad \iff \quad \text{system is consistent}. $$

If $\mathbf{b}$ cannot be written as a linear combination of the columns of $A$, the system has no solution.

Checking Consistency with Row Reduction

To test consistency, reduce the augmented matrix $[A | \mathbf{b}]$ to row-echelon form.

  • If you find a row of the form:

    $$ [0 ;; 0 ;; \dots ;; 0 ;|; c], \quad c \neq 0, $$

    then the system is inconsistent (contradiction: 0 = c).

  • If no such contradiction appears, the system is consistent.

Example 1: Consistent System with Unique Solution

System:

$$ \begin{cases}
x + y = 2 \
x - y = 0
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 1 & | & 2 \
1 & -1 & | & 0
\end{bmatrix}. $$

Row reduce:

  • $R_2 \to R_2 - R_1$:

    $$ \begin{bmatrix}
    1 & 1 & | & 2 \
    0 & -2 & | & -2
    \end{bmatrix}. $$

  • $R_2 \to -\tfrac{1}{2}R_2$:

    $$ \begin{bmatrix}
    1 & 1 & | & 2 \
    0 & 1 & | & 1
    \end{bmatrix}. $$

  • $R_1 \to R_1 - R_2$:

    $$ \begin{bmatrix}
    1 & 0 & | & 1 \
    0 & 1 & | & 1
    \end{bmatrix}. $$

Solution: $x = 1, ; y = 1$. Unique solution.

Example 2: Consistent System with Infinitely Many Solutions

System:

$$ \begin{cases}
x + y + z = 3 \
2x + 2y + 2z = 6
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 1 & 1 & | & 3 \
2 & 2 & 2 & | & 6
\end{bmatrix}. $$

Row reduce:

  • $R_2 \to R_2 - 2R_1$:

    $$ \begin{bmatrix}
    1 & 1 & 1 & | & 3 \
    0 & 0 & 0 & | & 0
    \end{bmatrix}. $$

No contradiction, so consistent. Solution:

$$ x = 3 - y - z, \quad y \text{ free}, \quad z \text{ free}. $$

The solution set is a plane in $\mathbb{R}^3$.

Example 3: Inconsistent System (for contrast)

System:

$$ \begin{cases}
x + y = 1 \
x + y = 2
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 1 & | & 1 \
1 & 1 & | & 2
\end{bmatrix}. $$

Row reduce:

  • $R_2 \to R_2 - R_1$:

    $$ \begin{bmatrix}
    1 & 1 & | & 1 \
    0 & 0 & | & 1
    \end{bmatrix}. $$

Contradiction: $0 = 1$. Inconsistent, no solution.

Geometric Interpretation of Consistency

  • In 2D:

    • Two lines intersect at a point → consistent, unique solution.
    • Two lines overlap → consistent, infinitely many solutions.
    • Two lines are parallel and distinct → inconsistent, no solution.
  • In 3D:

    • Three planes intersect at a point → unique solution.
    • Planes intersect along a line or coincide → infinitely many solutions.
    • Planes fail to meet (like a triangular "gap") → no solution.

Pivot Structure and Solutions

  • Unique solution: Every variable is a pivot variable (no free variables).
  • Infinitely many solutions: At least one free variable exists, but no contradiction.
  • No solution: Contradictory row appears in augmented matrix.

Everyday Analogies

  • Meeting point: If everyone agrees on the same café (unique solution), the plan is consistent. If they agree on any café along a certain street (infinite solutions), it's still consistent. If they give completely different addresses, there's no consistent plan.
  • Recipes: If the ingredients match exactly one way, unique solution. If they can vary while still yielding the dish, infinite solutions. If the instructions contradict, no dish is possible.

Why It Matters

  1. Consistency is the first checkpoint in solving systems.
  2. The classification into unique, infinite, or none underpins all of linear algebra.
  3. Understanding consistency ties algebra (row operations) to geometry (intersections of lines, planes, hyperplanes).
  4. These ideas scale: in data science and engineering, checking whether equations are consistent is equivalent to asking if a model fits observed data.

Try It Yourself

  1. Reduce the augmented matrix

    $$ \begin{bmatrix}
    1 & 2 & 1 & | & 5 \
    2 & 4 & 2 & | & 10 \
    3 & 6 & 3 & | & 15
    \end{bmatrix} $$

    and determine if the system is consistent.

  2. Classify the system as having unique, infinite, or no solutions:

    $$ \begin{cases}
    x + y + z = 2 \
    x - y + z = 0 \
    2x + 0y + 2z = 3
    \end{cases} $$

  3. Explain geometrically what it means when the augmented matrix has a contradictory row.

  4. Challenge: Show algebraically that a system is consistent if and only if $\mathbf{b}$ lies in the span of the columns of $A$.

Consistent systems mark the balance point between algebraic rules and geometric reality: they are where equations and space meet in harmony.

26. Detecting Inconsistency

Not every system of linear equations has a solution. Some are inconsistent, meaning the equations contradict one another and no vector $\mathbf{x}$ can satisfy them all at once. Detecting such inconsistency early is crucial: it saves wasted effort trying to solve an impossible system and reveals important geometric and algebraic properties.

What Inconsistency Looks Like Algebraically

Consider the system:

$$ \begin{cases}
x + y = 1 \
x + y = 3
\end{cases} $$

Clearly, the two equations cannot both be true. In augmented matrix form:

$$ \begin{bmatrix}
1 & 1 & | & 1 \
1 & 1 & | & 3
\end{bmatrix}. $$

Row reduction gives:

$$ \begin{bmatrix}
1 & 1 & | & 1 \
0 & 0 & | & 2
\end{bmatrix}. $$

The bottom row says $0 = 2$, a contradiction. This is the hallmark of inconsistency: a row of zeros in the coefficient part, with a nonzero constant in the augmented part.

General Rule for Detection

A system $A\mathbf{x} = \mathbf{b}$ is inconsistent if, after row reduction, the augmented matrix contains a row of the form:

$$ [0 ;; 0 ;; \dots ;; 0 ;|; c], \quad c \neq 0. $$

This indicates that all variables vanish from the equation, leaving an impossible statement like $0 = c$.

Example 1: Parallel Lines in 2D

$$ \begin{cases}
x + y = 2 \
2x + 2y = 5
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 1 & | & 2 \
2 & 2 & | & 5
\end{bmatrix}. $$

Row reduce:

  • $R_2 \to R_2 - 2R_1$:

$$ \begin{bmatrix}
1 & 1 & | & 2 \
0 & 0 & | & 1
\end{bmatrix}. $$

Contradiction: no solution. Geometrically, the two equations are parallel lines that never intersect.

Example 2: Contradictory Planes in 3D

$$ \begin{cases}
x + y + z = 1 \
2x + 2y + 2z = 2 \
x + y + z = 3
\end{cases} $$

The first and third equations already conflict: the same plane equation is forced to equal two different constants.

Augmented matrix reduces to:

$$ \begin{bmatrix}
1 & 1 & 1 & | & 1 \
0 & 0 & 0 & | & 0 \
0 & 0 & 0 & | & 2
\end{bmatrix}. $$

Contradiction: no solution. The "planes" fail to intersect in common.

Geometry of Inconsistency

  • In 2D: Inconsistent systems correspond to parallel lines with different intercepts.
  • In 3D: They correspond to planes that are parallel but offset, or planes arranged in a way that leaves a "gap" (no shared intersection).
  • In higher dimensions: Inconsistency means the target vector $\mathbf{b}$ lies outside the column space of $A$.

Rank Test for Consistency

Another way to detect inconsistency is using ranks.

  • Let $\text{rank}(A)$ be the number of pivots in the coefficient matrix.
  • Let $\text{rank}([A|\mathbf{b}])$ be the number of pivots in the augmented matrix.

Rule:

  • If $\text{rank}(A) = \text{rank}([A|\mathbf{b}])$, the system is consistent.
  • If $\text{rank}(A) < \text{rank}([A|\mathbf{b}])$, the system is inconsistent.

This rank condition is fundamental and works in any dimension.

Everyday Analogies

  • Meeting schedules: If one friend says "meet at 2pm" and another says "meet at 2pm and 3pm simultaneously," the instructions contradict-no meeting possible.
  • Construction blueprints: If two architects specify identical walls but with different lengths, the building plan is impossible.
  • Cooking instructions: If one step requires "boil pasta until firm" and another says "the same pasta must already be raw," the recipe cannot be carried out.

Why It Matters

  1. Inconsistency reveals overdetermined or contradictory data in real problems (physics, engineering, statistics).
  2. The ability to detect inconsistency quickly through row reduction or rank saves computation.
  3. It connects geometry (non-intersecting spaces) with algebra (contradictory rows).
  4. It prepares the way for least-squares methods, where inconsistent systems are approximated instead of solved exactly.

Try It Yourself

  1. Reduce the augmented matrix

$$ \begin{bmatrix}
1 & -1 & | & 2 \
2 & -2 & | & 5
\end{bmatrix} $$

and decide if the system is consistent.

  1. Show geometrically why the system

$$ x + y = 0, \quad x + y = 1 $$

is inconsistent.

  1. Use the rank test to check consistency of

$$ \begin{cases}
x + y + z = 2 \
2x + 2y + 2z = 4 \
3x + 3y + 3z = 5
\end{cases} $$

  1. Challenge: Explain why $\text{rank}(A) < \text{rank}([A|\mathbf{b}])$ implies inconsistency, using the concept of the column space.

Detecting inconsistency is not just about spotting contradictions-it connects algebra, geometry, and linear transformations, showing exactly when a system cannot possibly fit together.

27. Gaussian Elimination by Hand

Gaussian elimination is the systematic procedure for solving systems of linear equations by using row operations to simplify the augmented matrix. The goal is to transform the system into row-echelon form (REF) and then use back substitution to find the solutions. This method is the backbone of linear algebra computations and is the foundation of most computer algorithms for solving linear systems.

The Big Idea

  1. Represent the system as an augmented matrix.
  2. Use row operations to eliminate variables step by step, moving left to right, top to bottom.
  3. Stop when the matrix is in REF.
  4. Solve the triangular system by back substitution.

Step-by-Step Recipe

Suppose we have $n$ equations with $n$ unknowns.

  1. Choose a pivot in the first column (a nonzero entry). If needed, swap rows to bring a nonzero entry to the top.
  2. Eliminate below the pivot by subtracting multiples of the pivot row from lower rows so that all entries below the pivot become zero.
  3. Move to the next row and next column, pick the next pivot, and repeat elimination.
  4. Continue until all pivots are in stair-step form (REF).
  5. Use back substitution to solve for the unknowns starting from the bottom row.

Example 1: A 2×2 System

System:

$$ \begin{cases}
x + 2y = 5 \
3x + 4y = 11
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 2 & | & 5 \
3 & 4 & | & 11
\end{bmatrix}. $$

  1. Pivot at (1,1) = 1.

  2. Eliminate below: $R_2 \to R_2 - 3R_1$.

    $$ \begin{bmatrix}
    1 & 2 & | & 5 \
    0 & -2 & | & -4
    \end{bmatrix}. $$

  3. Back substitution: From row 2: $-2y = -4 \implies y = 2$. Substitute into row 1: $x + 2(2) = 5 \implies x = 1$.

Solution: $(x, y) = (1, 2)$.

Example 2: A 3×3 System

System:

$$ \begin{cases}
x + y + z = 6 \
2x + 3y + z = 14 \
x - y + 2z = 2
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 1 & 1 & | & 6 \
2 & 3 & 1 & | & 14 \
1 & -1 & 2 & | & 2
\end{bmatrix}. $$

Step 1: Pivot at (1,1). Eliminate below:

  • $R_2 \to R_2 - 2R_1$.
  • $R_3 \to R_3 - R_1$.

$$ \begin{bmatrix}
1 & 1 & 1 & | & 6 \
0 & 1 & -1 & | & 2 \
0 & -2 & 1 & | & -4
\end{bmatrix}. $$

Step 2: Pivot at (2,2). Eliminate below: $R_3 \to R_3 + 2R_2$.

$$ \begin{bmatrix}
1 & 1 & 1 & | & 6 \
0 & 1 & -1 & | & 2 \
0 & 0 & -1 & | & 0
\end{bmatrix}. $$

Step 3: Pivot at (3,3). Scale row: $R_3 \to -R_3$.

$$ \begin{bmatrix}
1 & 1 & 1 & | & 6 \
0 & 1 & -1 & | & 2 \
0 & 0 & 1 & | & 0
\end{bmatrix}. $$

Back substitution:

  • From row 3: $z = 0$.
  • From row 2: $y - z = 2 \implies y = 2$.
  • From row 1: $x + y + z = 6 \implies x = 4$.

Solution: $(x, y, z) = (4, 2, 0)$.

Why Gaussian Elimination Always Works

  • Each step reduces the number of variables in the lower equations.
  • Pivoting ensures stability (swap rows to avoid dividing by zero).
  • The algorithm either produces a triangular system (solvable by substitution) or reveals inconsistency (contradictory row).

Geometric Interpretation

  • Elimination corresponds to progressively restricting the solution set:

    • First equation → a plane in $\mathbb{R}^3$.
    • Add second equation → intersection becomes a line.
    • Add third equation → intersection becomes a point (unique solution) or vanishes (inconsistent).

Everyday Analogies

  • Cleaning a desk: Start with a mess (equations mixed together), then eliminate clutter one step at a time until everything is sorted neatly into piles.
  • Cooking: Elimination is like reducing a sauce-boiling away the excess until only the essence remains.
  • Detective work: Each equation eliminates possibilities, narrowing down suspects until only the guilty party (the solution) remains.

Why It Matters

  1. Gaussian elimination is the foundation for solving systems by hand and by computer.
  2. It reveals whether a system is consistent and if solutions are unique or infinite.
  3. It is the starting point for advanced methods like LU decomposition, QR factorization, and numerical solvers.
  4. It shows the interplay between algebra (row operations) and geometry (intersections of subspaces).

Try It Yourself

  1. Solve the system

    $$ \begin{cases}
    2x + y = 7 \
    4x + 3y = 15
    \end{cases} $$

    using Gaussian elimination.

  2. Reduce

    $$ \begin{bmatrix}
    1 & 2 & -1 & | & 3 \
    3 & 8 & 1 & | & 12 \
    2 & 6 & 3 & | & 11
    \end{bmatrix} $$

    to REF and solve.

  3. Practice with a system that has infinitely many solutions:

    $$ x + y + z = 4, \quad 2x + 2y + 2z = 8. $$

  4. Challenge: Explain why Gaussian elimination always terminates in at most $n$ pivot steps for an $n \times n$ system.

Gaussian elimination transforms the complexity of many equations into an orderly process, making the hidden structure of solutions visible step by step.

28. Back Substitution and Solution Sets

Once Gaussian elimination reduces a system to row-echelon form (REF), the next step is to actually solve for the unknowns. This process is called back substitution: we begin with the bottom equation (which involves the fewest variables) and work our way upward, solving step by step. Back substitution is what converts the structured triangular system into explicit solutions.

The Structure of Row-Echelon Form

A system in REF looks like this:

$$ \begin{bmatrix}

  • & * & * & * & | & * \
    0 & * & * & * & | & * \
    0 & 0 & * & * & | & * \
    0 & 0 & 0 & * & | & *
    \end{bmatrix} $$

  • Each row corresponds to an equation with fewer variables than the row above.

  • The bottom equation has only one or two variables.

  • This triangular form makes it possible to solve "from the bottom up."

Step-by-Step Example: Unique Solution

System after elimination:

$$ \begin{bmatrix}
1 & 2 & -1 & | & 3 \
0 & 1 & 2 & | & 4 \
0 & 0 & 1 & | & 2
\end{bmatrix}. $$

This corresponds to:

$$ \begin{cases}
x + 2y - z = 3 \
y + 2z = 4 \
z = 2
\end{cases} $$

  1. From the last equation: $z = 2$.
  2. Substitute into the second: $y + 2(2) = 4 \implies y = 0$.
  3. Substitute into the first: $x + 2(0) - 2 = 3 \implies x = 5$.

Solution: $(x, y, z) = (5, 0, 2)$.

Infinite Solutions with Free Variables

Not all systems reduce to unique solutions. If there are free variables (non-pivot columns), back substitution expresses pivot variables in terms of free ones.

Example:

$$ \begin{bmatrix}
1 & 2 & 1 & | & 4 \
0 & 1 & -1 & | & 1 \
0 & 0 & 0 & | & 0
\end{bmatrix}. $$

Equations:

$$ \begin{cases}
x + 2y + z = 4 \
y - z = 1
\end{cases} $$

  1. From row 2: $y = 1 + z$.
  2. From row 1: $x + 2(1 + z) + z = 4 \implies x = 2 - 3z$.

Solution set:

$$ (x, y, z) = (2 - 3t, ; 1 + t, ; t), \quad t \in \mathbb{R}. $$

Here $z = t$ is the free variable. The solutions form a line in 3D.

General Solution Structure

For a consistent system:

  1. Unique solution → every variable is a pivot variable (no free variables).
  2. Infinitely many solutions → some free variables remain. The solution set is parametrized by these variables and forms a line, plane, or higher-dimensional subspace.
  3. No solution → contradiction discovered earlier, so back substitution is impossible.

Geometric Meaning

  • Unique solution → a single intersection point of lines/planes.
  • Infinite solutions → overlapping subspaces (e.g., two planes intersecting in a line).
  • Back substitution describes the exact shape of this intersection.

Example: Parametric Vector Form

For the infinite-solution example above:

$$ (x, y, z) = (2, 1, 0) + t(-3, 1, 1). $$

This expresses the solution set as a base point plus a direction vector, making the geometry clear.

Everyday Analogies

  • Stacked tasks: Back substitution is like solving a sequence of tasks where each depends on the result of the one below it.
  • Domino effect: Once the last domino falls (the last variable solved), the rest fall in sequence.
  • Filling out a form: Each field depends on earlier answers; once the final field is fixed, the others can be determined in order.

Why It Matters

  1. Back substitution turns row-echelon form into concrete answers.
  2. It distinguishes unique vs. infinite solutions.
  3. It provides a systematic method usable by hand for small systems and forms the basis of computer algorithms for large ones.
  4. It reveals the structure of solution sets-whether a point, line, plane, or higher-dimensional object.

Try It Yourself

  1. Solve by back substitution:

$$ \begin{bmatrix}
1 & -1 & 2 & | & 3 \
0 & 1 & 3 & | & 5 \
0 & 0 & 1 & | & 2
\end{bmatrix}. $$

  1. Reduce and solve:

$$ x + y + z = 2, \quad 2x + 2y + 2z = 4. $$

  1. Express the solution set of the above system in parametric vector form.

  2. Challenge: For a 4×4 system with two free variables, explain why the solution set forms a plane in $\mathbb{R}^4$.

Back substitution completes the elimination process, translating triangular structure into explicit solutions, and shows how algebra and geometry meet in the classification of solution sets.

29. Rank and Its First Meaning

The concept of rank lies at the heart of linear algebra. It connects the algebra of solving systems, the geometry of subspaces, and the structure of matrices into one unifying idea. Rank measures the amount of independent information in a matrix: how many rows or columns carry unique directions instead of being repetitions or combinations of others.

Definition of Rank

The rank of a matrix $A$ is the number of pivots in its row-echelon form. Equivalently, it is:

  • The dimension of the column space (number of independent columns).
  • The dimension of the row space (number of independent rows).

All these definitions agree.

First Encounter with Rank: Pivot Counting

When solving a system with Gaussian elimination:

  • Every pivot corresponds to one determined variable.
  • The number of pivots = the rank.
  • The number of free variables = total variables – rank.

Example:

$$ \begin{bmatrix}
1 & 2 & 1 & | & 4 \
0 & 1 & -1 & | & 2 \
0 & 0 & 0 & | & 0
\end{bmatrix}. $$

Here, there are 2 pivots. So:

  • Rank = 2.
  • With 3 variables total, there is 1 free variable.

Rank in Terms of Independence

A set of vectors is linearly independent if none can be expressed as a combination of the others.

  • The rank of a matrix tells us how many independent rows or columns it has.
  • If some columns are combinations of others, they do not increase the rank.

Example:

$$ \begin{bmatrix}
1 & 2 & 3 \
2 & 4 & 6 \
3 & 6 & 9
\end{bmatrix}. $$

Here, each row is a multiple of the first. Rank = 1, since only one independent row/column direction exists.

Rank and Solutions of Systems

Consider $A\mathbf{x} = \mathbf{b}$.

  • If $\text{rank}(A) = \text{rank}([A|\mathbf{b}])$, the system is consistent.
  • If not, inconsistent.
  • If rank = number of variables, the system has a unique solution.
  • If rank < number of variables, there are infinitely many solutions.

Thus, rank classifies solution sets.

Rank and Geometry

Rank tells us the dimension of the subspace spanned by rows or columns.

  • Rank 1: all information lies along a line.
  • Rank 2: lies in a plane.
  • Rank 3: fills 3D space.

Example:

  • In $\mathbb{R}^3$, a matrix of rank 2 has columns spanning a plane through the origin.
  • A matrix of rank 1 has all columns on a single line.

Rank and Row vs. Column View

It is a remarkable fact that the number of independent rows = number of independent columns. This is not obvious at first glance, but it is always true. So we can define rank either by rows or by columns-it makes no difference.

Everyday Analogies

  • Library books: If three books say the same thing in different words, only one adds new knowledge. The others are redundant. Rank = number of genuinely independent books.
  • Recipes: If you have five recipes but four are just scaled versions of the first, you really only have one distinct recipe. Rank = 1.
  • Work team: If every team member repeats what another says, the effective number of independent voices is low. Rank measures how many unique contributions exist.

Why It Matters

  1. Rank is the bridge between algebra and geometry: pivots ↔ dimension.
  2. It classifies solutions to systems of equations.
  3. It measures redundancy in data (important in statistics, machine learning, signal processing).
  4. It prepares the way for advanced concepts like nullity, rank–nullity theorem, and singular value decomposition.

Try It Yourself

  1. Find the rank of

    $$ \begin{bmatrix}
    1 & 2 & 3 \
    2 & 4 & 5 \
    3 & 6 & 8
    \end{bmatrix}. $$

  2. Solve the system

    $$ x + y + z = 2, \quad 2x + 2y + 2z = 4, $$

    and identify the rank of the coefficient matrix.

  3. In $\mathbb{R}^3$, what is the geometric meaning of a 3×3 matrix of rank 2?

  4. Challenge: Prove that the row rank always equals the column rank by considering the echelon form of the matrix.

Rank is the first truly unifying concept in linear algebra: it tells us how much independent structure a matrix contains and sets the stage for understanding spaces, dimensions, and transformations.

30. LU Factorization

Gaussian elimination not only solves systems but also reveals a deeper structure: many matrices can be factored into simpler pieces. One of the most useful is the LU factorization, where a matrix $A$ is written as the product of a lower-triangular matrix $L$ and an upper-triangular matrix $U$. This factorization captures all the elimination steps in a compact form and allows systems to be solved efficiently.

What is LU Factorization?

If $A$ is an $n \times n$ matrix, then

$$ A = LU, $$

where:

  • $L$ is lower-triangular (entries below diagonal may be nonzero, diagonal entries = 1).
  • $U$ is upper-triangular (entries above diagonal may be nonzero).

This means:

  • $U$ stores the result of elimination (the triangular system).
  • $L$ records the multipliers used during elimination.

Example: 2×2 Case

Take

$$ A = \begin{bmatrix}
2 & 3 \
4 & 7
\end{bmatrix}. $$

Elimination: $R_2 \to R_2 - 2R_1$.

  • Multiplier = 2 (used to eliminate entry 4).

  • Resulting $U$:

    $$ U = \begin{bmatrix}
    2 & 3 \
    0 & 1
    \end{bmatrix}. $$

  • $L$:

    $$ L = \begin{bmatrix}
    1 & 0 \
    2 & 1
    \end{bmatrix}. $$

Check:

$$ LU = \begin{bmatrix}
1 & 0 \
2 & 1
\end{bmatrix}
\begin{bmatrix}
2 & 3 \
0 & 1
\end{bmatrix}
= \begin{bmatrix}
2 & 3 \
4 & 7
\end{bmatrix} = A. $$

Example: 3×3 Case

$$ A = \begin{bmatrix}
2 & 1 & 1 \
4 & -6 & 0 \
-2 & 7 & 2
\end{bmatrix}. $$

Step 1: Eliminate below pivot (row 1).

  • Multiplier $m_{21} = 4/2 = 2$.
  • Multiplier $m_{31} = -2/2 = -1$.

Step 2: Eliminate below pivot in column 2.

  • After substitutions, multipliers and pivots are collected.

Result:

$$ L = \begin{bmatrix}
1 & 0 & 0 \
2 & 1 & 0 \
-1 & -1 & 1
\end{bmatrix}, \quad
U = \begin{bmatrix}
2 & 1 & 1 \
0 & -8 & -2 \
0 & 0 & 1
\end{bmatrix}. $$

Thus $A = LU$.

Solving Systems with LU

Suppose $Ax = b$. If $A = LU$:

  1. Solve $Ly = b$ by forward substitution (since $L$ is lower-triangular).
  2. Solve $Ux = y$ by back substitution (since $U$ is upper-triangular).

This two-step process is much faster than elimination from scratch each time, especially if solving multiple systems with the same $A$ but different $b$.

Pivoting and Permutations

Sometimes elimination requires row swaps (to avoid division by zero or instability). Then factorization is written as:

$$ PA = LU, $$

where $P$ is a permutation matrix recording the row swaps. This is the practical form used in numerical computing.

Applications of LU Factorization

  1. Efficient solving: Multiple right-hand sides $Ax = b$. Compute $LU$ once, reuse for each $b$.
  2. Determinants: $\det(A) = \det(L)\det(U)$. Since diagonals of $L$ are 1, this reduces to the product of the diagonal of $U$.
  3. Matrix inverse: By solving $Ax = e_i$ for each column $e_i$, we can compute $A^{-1}$ efficiently with LU.
  4. Numerical methods: LU is central in scientific computing, engineering simulations, and optimization.

Geometric Meaning

LU decomposition separates the elimination process into:

  • $L$: shear transformations (adding multiples of rows).
  • $U$: scaling and alignment into triangular form.

Together, they represent the same linear transformation as $A$, but decomposed into simpler building blocks.

Everyday Analogies

  • Recipe preparation: $L$ is the prep work (chopping, mixing), while $U$ is the final cooking (arranging in order). Together, they produce the finished dish.
  • Assembly line: $L$ records the sequence of adjustments, $U$ the final structured product.
  • Team project: $L$ shows who contributed what during the work process, $U$ is the neatly organized final report.

Why It Matters

  1. LU factorization compresses elimination into a reusable format.
  2. It is a cornerstone of numerical linear algebra and used in almost every solver.
  3. It links computation (efficient algorithms) with theory (factorization of transformations).
  4. It introduces the broader idea that matrices can be broken into simple, interpretable parts.

Try It Yourself

  1. Factor

    $$ A = \begin{bmatrix}
    1 & 2 \
    3 & 8
    \end{bmatrix} $$

    into $LU$.

  2. Solve

    $$ \begin{bmatrix}
    2 & 1 \
    6 & 3
    \end{bmatrix}
    \begin{bmatrix}
    x \ y
    \end{bmatrix} =
    \begin{bmatrix}
    5 \ 15
    \end{bmatrix} $$

    using LU decomposition.

  3. Compute $\det(A)$ for

    $$ A = \begin{bmatrix}
    2 & 1 & 1 \
    4 & -6 & 0 \
    -2 & 7 & 2
    \end{bmatrix} $$

    by using its LU factorization.

  4. Challenge: Prove that if $A$ is invertible, then it has an LU factorization (possibly after row swaps).

LU factorization organizes elimination into a powerful tool: compact, efficient, and deeply tied to both the theory and practice of linear algebra.

Closing

Paths diverge or merge,
pivots mark the way forward,
truth distilled in rows.

Chapter 4. Vector spaces and subspaces

Opening

Endless skies expand,
spaces within spaces grow,
freedom takes its shape.

31. Axioms of Vector Spaces

Up to now, we have worked with vectors in $\mathbb{R}^2$, $\mathbb{R}^3$, and higher-dimensional Euclidean spaces. But the true power of linear algebra comes from abstracting away from coordinates. A vector space is not tied to arrows in physical space-it is any collection of objects that behave like vectors, provided they satisfy certain rules. These rules are called the axioms of vector spaces.

The Idea of a Vector Space

A vector space is a set $V$ equipped with two operations:

  1. Vector addition: Combine two vectors in $V$ to get another vector in $V$.
  2. Scalar multiplication: Multiply a vector in $V$ by a scalar (a number from a field, usually $\mathbb{R}$ or $\mathbb{C}$).

The magic is that as long as certain rules (axioms) hold, the objects in $V$ can be treated as vectors. They need not be arrows or coordinate lists-they could be polynomials, functions, matrices, or sequences.

The Eight Axioms

Let $u, v, w \in V$ (vectors) and $a, b \in \mathbb{R}$ (scalars). The axioms are:

  1. Closure under addition: $u + v \in V$.
  2. Commutativity of addition: $u + v = v + u$.
  3. Associativity of addition: $(u + v) + w = u + (v + w)$.
  4. Existence of additive identity: There exists a zero vector $0 \in V$ such that $v + 0 = v$.
  5. Existence of additive inverses: For every $v$, there is $-v$ such that $v + (-v) = 0$.
  6. Closure under scalar multiplication: $a v \in V$.
  7. Distributivity of scalar multiplication over vector addition: $a(u + v) = au + av$.
  8. Distributivity of scalar multiplication over scalar addition: $(a + b)v = av + bv$.
  9. Associativity of scalar multiplication: $a(bv) = (ab)v$.
  10. Existence of multiplicative identity: $1 \cdot v = v$.

(These are sometimes listed as eight, with some grouped together, but the essence is the same.)

Examples of Vector Spaces

  1. Euclidean spaces: $\mathbb{R}^n$ with standard addition and scalar multiplication.
  2. Polynomials: The set of all polynomials with real coefficients, $\mathbb{R}[x]$.
  3. Functions: The set of all continuous functions on $[0,1]$, with addition of functions and scalar multiplication.
  4. Matrices: The set of all $m \times n$ matrices with real entries.
  5. Sequences: The set of all infinite real sequences $(a_1, a_2, \dots)$.

All of these satisfy the vector space axioms.

Non-Examples

  1. The set of natural numbers $\mathbb{N}$ is not a vector space (no additive inverses).
  2. The set of positive real numbers $\mathbb{R}^+$ is not a vector space (not closed under scalar multiplication with negative numbers).
  3. The set of polynomials of degree exactly 2 is not a vector space (not closed under addition: $x^2 + x^2 = 2x^2$ is still degree 2, but $x^2 - x^2 = 0$, which is degree 0, not allowed).

These examples show why the axioms are essential: without them, the structure breaks.

The Zero Vector

Every vector space must contain a zero vector. This is not optional. It is the "do nothing" element for addition. In $\mathbb{R}^n$, this is $(0,0,\dots,0)$. In polynomials, it is the zero polynomial. In function spaces, it is the function $f(x) = 0$.

Additive Inverses

For every vector $v$, we require $-v$. This ensures that equations like $u+v=w$ can always be rearranged to $u=w-v$. Without additive inverses, solving linear equations would not work.

Scalars and Fields

Scalars come from a field: usually the real numbers $\mathbb{R}$ or the complex numbers $\mathbb{C}$. The choice of scalars matters:

  • Over $\mathbb{R}$, a polynomial space is different from over $\mathbb{C}$.
  • Over finite fields (like integers modulo $p$), vector spaces exist in discrete mathematics and coding theory.

Geometric Interpretation

  • The axioms guarantee that vectors can be added and scaled in predictable ways.
  • Closure ensures the space is "self-contained."
  • Additive inverses ensure symmetry: every direction can be reversed.
  • Distributivity ensures consistency between scaling and addition.

Together, these rules make vector spaces stable and reliable mathematical objects.

Everyday Analogies

  • Language: Words form sentences by rules of grammar. Vector spaces are sets where addition and scaling follow strict grammar-like rules.
  • Music: Notes combine (addition) and change pitch (scaling). A musical space is meaningful only if these operations stay within the system.
  • Construction: Bricks and mortar can be combined (addition) and scaled (larger or smaller structures), but only when rules of stability are followed.

Why It Matters

  1. Vector spaces unify many areas of math under a single framework.
  2. They generalize $\mathbb{R}^n$ to functions, polynomials, and beyond.
  3. The axioms guarantee that all the tools of linear algebra-span, basis, dimension, linear maps-apply.
  4. Recognizing vector spaces in disguise is a major step in advanced math and physics.

Try It Yourself

  1. Verify that the set of all 2×2 matrices is a vector space under matrix addition and scalar multiplication.
  2. Show that the set of polynomials of degree at most 3 is a vector space, but the set of polynomials of degree exactly 3 is not.
  3. Check whether the set of all even functions $f(-x) = f(x)$ is a vector space.
  4. Challenge: Consider the set of all differentiable functions $f$ on $[0,1]$. Show that this set forms a vector space under the usual operations.

The axioms of vector spaces provide the foundation on which the rest of linear algebra is built. Everything that follows-subspaces, independence, basis, dimension-grows naturally from this formal framework.

32. Subspaces, Column Space, and Null Space

Once the idea of a vector space is in place, the next step is to recognize smaller vector spaces that live inside bigger ones. These are called subspaces. Subspaces are central in linear algebra because they reveal the internal structure of matrices and linear systems. Two special subspaces-the column space and the null space-play particularly important roles.

What Is a Subspace?

A subspace $W$ of a vector space $V$ is a subset of $V$ that is itself a vector space under the same operations. To qualify as a subspace, $W$ must satisfy:

  1. The zero vector $0$ is in $W$.
  2. If $u, v \in W$, then $u+v \in W$ (closed under addition).
  3. If $u \in W$ and $c$ is a scalar, then $cu \in W$ (closed under scalar multiplication).

That's it-no further checking of all ten vector space axioms is needed, because those are inherited from $V$.

Simple Examples of Subspaces

  • In $\mathbb{R}^3$:

    • A line through the origin is a 1-dimensional subspace.
    • A plane through the origin is a 2-dimensional subspace.
    • The whole space itself is a subspace.
    • The trivial subspace ${0}$ contains only the zero vector.
  • In the space of polynomials:

    • All polynomials of degree ≤ 3 form a subspace.
    • All polynomials with zero constant term form a subspace.
  • In function spaces:

    • All continuous functions on $[0,1]$ form a subspace of all functions on $[0,1]$.
    • All solutions to a linear differential equation form a subspace.

The Column Space of a Matrix

Given a matrix $A$, the column space is the set of all linear combinations of its columns. Formally,

$$ C(A) = { A\mathbf{x} : \mathbf{x} \in \mathbb{R}^n }. $$

  • The column space lives inside $\mathbb{R}^m$ if $A$ is $m \times n$.
  • It represents all possible outputs of the linear transformation defined by $A$.
  • Its dimension is equal to the rank of $A$.

Example:

$$ A = \begin{bmatrix}
1 & 2 \
2 & 4 \
3 & 6
\end{bmatrix}. $$

The second column is just twice the first. So the column space is all multiples of $\begin{bmatrix}1 \ 2 \ 3\end{bmatrix}$, which is a line in $\mathbb{R}^3$. Rank = 1.

The Null Space of a Matrix

The null space (or kernel) of a matrix $A$ is the set of all vectors $\mathbf{x}$ such that

$$ A\mathbf{x} = 0. $$

  • It lives in $\mathbb{R}^n$ if $A$ is $m \times n$.
  • It represents the "invisible" directions that collapse to zero under the transformation.
  • Its dimension is the nullity of $A$.

Example:

$$ A = \begin{bmatrix}
1 & 2 & 3 \
4 & 5 & 6
\end{bmatrix}. $$

Solve $A\mathbf{x} = 0$. This yields a null space spanned by one vector, meaning it is a line through the origin in $\mathbb{R}^3$.

Column Space vs. Null Space

  • Column space: describes outputs ($y$-values that can be reached).
  • Null space: describes hidden inputs (directions that vanish).

Together, they capture the full behavior of a matrix.

Geometric Interpretation

  • In $\mathbb{R}^3$, the column space could be a plane or a line inside 3D space.
  • The null space is orthogonal (in a precise sense) to the row space, which we'll study later.
  • Understanding both spaces gives a complete picture of how the matrix transforms vectors.

Everyday Analogies

  • Column space as achievements: Think of the matrix as a machine. The column space is the set of all things the machine can produce.
  • Null space as wasted effort: Any input vector in the null space produces nothing at all-like pressing buttons on a broken remote control.
  • Teamwork analogy: If each team member contributes along independent directions, the column space is large. If some repeat others' work, redundancy reduces the column space.

Why It Matters

  1. Subspaces are the natural habitat of linear algebra: almost everything happens inside them.
  2. The column space explains what systems $Ax=b$ are solvable.
  3. The null space explains why some systems have multiple solutions (free variables).
  4. These ideas extend to advanced topics like eigenvectors, SVD, and differential equations.

Try It Yourself

  1. Show that the set ${(x,y,0) : x,y \in \mathbb{R}}$ is a subspace of $\mathbb{R}^3$.

  2. For

    $$ A = \begin{bmatrix}
    1 & 2 & 3 \
    0 & 0 & 0 \
    1 & 2 & 3
    \end{bmatrix}, $$

    find the column space and its dimension.

  3. For the same $A$, compute the null space and its dimension.

  4. Challenge: Prove that the null space of $A$ is always a subspace of $\mathbb{R}^n$.

Subspaces-especially the column space and null space-are the first glimpse of the hidden geometry inside every matrix, showing us which directions survive and which vanish.

33. Span and Generating Sets

The idea of a span captures the simplest and most powerful way to build new vectors from old ones: by taking linear combinations. A span is not just a set of scattered points but a structured, complete collection of all combinations of a given set of vectors. Understanding span leads directly to the concepts of bases, dimension, and the structure of subspaces.

Definition of Span

Given vectors $v_1, v_2, \dots, v_k \in V$, the span of these vectors is

$$ \text{span}{v_1, v_2, \dots, v_k} = {a_1 v_1 + a_2 v_2 + \dots + a_k v_k : a_i \in \mathbb{R}}. $$

  • A span is the set of all possible linear combinations of the vectors.
  • It is always a subspace.
  • The given vectors are called a generating set.

Simple Examples

  1. In $\mathbb{R}^2$:

    • Span of $(1,0)$ = all multiples of the x-axis (a line).
    • Span of $(1,0)$ and $(0,1)$ = the entire plane $\mathbb{R}^2$.
    • Span of $(1,0)$ and $(2,0)$ = still the x-axis, since the second vector is redundant.
  2. In $\mathbb{R}^3$:

    • Span of a single vector = a line.
    • Span of two independent vectors = a plane through the origin.
    • Span of three independent vectors = the whole space $\mathbb{R}^3$.

Span as Coverage

  • If you think of vectors as "directions," the span is everything you can reach by walking in those directions, with any step lengths (scalars) allowed.
  • If you only have one direction, you can walk back and forth on a line.
  • With two independent directions, you can sweep out a plane.
  • With three independent directions in 3D, you can move anywhere.

Generating Sets

A set of vectors is a generating set (or spanning set) for a subspace if their span equals that subspace.

  • Example: ${(1,0), (0,1)}$ generates $\mathbb{R}^2$.
  • Example: ${(1,0,0), (0,1,0), (0,0,1)}$ generates $\mathbb{R}^3$.
  • Example: The columns of a matrix generate its column space.

Different generating sets can span the same space. Some may be redundant, others minimal. Later, the concept of a basis refines this idea.

Redundancy in Spanning Sets

  • If one vector is a linear combination of others, it does not enlarge the span.
  • Example: In $\mathbb{R}^2$, ${(1,0), (0,1), (1,1)}$ spans the same space as ${(1,0), (0,1)}$.
  • Eliminating redundancy leads to a more efficient generating set.

Span and Linear Systems

Consider the system $Ax=b$.

  • The question "Is there a solution?" is equivalent to "Is $b$ in the span of the columns of $A$?"
  • Thus, span provides the geometric language for solvability.

Everyday Analogies

  • Languages: If you have enough letters (generators), you can spell any word (vector). Redundant letters don't add power (extra copies of "A" don't help).
  • Recipes: Ingredients are like generators; the span is all dishes you can cook from them. Some ingredients are essential, others can be left out.
  • Travel directions: If you only know how to go north, you're stuck on a line. Add east, and you can reach anywhere on the map.

Why It Matters

  1. Span is the foundation for defining subspaces generated by vectors.
  2. It connects directly to solvability of linear equations.
  3. It introduces the notion of redundancy, preparing for bases and independence.
  4. It generalizes naturally to function spaces and abstract vector spaces.

Try It Yourself

  1. Find the span of ${(1,2), (2,4)}$ in $\mathbb{R}^2$.
  2. Show that the vectors $(1,0,1), (0,1,1), (1,1,2)$ span only a plane in $\mathbb{R}^3$.
  3. Decide whether $(1,2,3)$ is in the span of $(1,0,1)$ and $(0,1,2)$.
  4. Challenge: Prove that the set of all polynomials ${1, x, x^2, \dots}$ spans the space of all polynomials.

The concept of span transforms our perspective: instead of focusing on single vectors, we see the entire landscape of possibilities they generate.

34. Linear Independence and Dependence

Having introduced span and generating sets, the natural question arises: when are the vectors in a spanning set truly necessary, and when are some redundant? This leads to the idea of linear independence. It is the precise way to distinguish between essential vectors (those that add new directions) and dependent vectors (those that can be expressed in terms of others).

Definition of Linear Independence

A set of vectors ${v_1, v_2, \dots, v_k}$ is linearly independent if the only solution to

$$ a_1 v_1 + a_2 v_2 + \dots + a_k v_k = 0 $$

is

$$ a_1 = a_2 = \dots = a_k = 0. $$

If there exists a nontrivial solution (some $a_i \neq 0$), then the vectors are linearly dependent.

Intuition

  • Independent vectors point in genuinely different directions.
  • Dependent vectors overlap: at least one can be built from the others.
  • In terms of span: removing a dependent vector does not shrink the span, because it adds no new direction.

Simple Examples in $\mathbb{R}^2$

  1. $(1,0)$ and $(0,1)$ are independent.

    • Equation $a(1,0) + b(0,1) = (0,0)$ forces $a = b = 0$.
  2. $(1,0)$ and $(2,0)$ are dependent.

    • Equation $2(1,0) - (2,0) = (0,0)$ shows dependence.
  3. Any set of 3 vectors in $\mathbb{R}^2$ is dependent, since the dimension of the space is 2.

Examples in $\mathbb{R}^3$

  1. $(1,0,0), (0,1,0), (0,0,1)$ are independent.
  2. $(1,2,3), (2,4,6)$ are dependent, since the second is just 2× the first.
  3. $(1,0,1), (0,1,1), (1,1,2)$ are dependent: the third is the sum of the first two.

Detecting Independence with Matrices

Put the vectors as columns in a matrix. Perform row reduction:

  • If every column has a pivot → the set is independent.
  • If some column is free → the set is dependent.

Example:

$$ \begin{bmatrix}
1 & 2 & 3 \
0 & 1 & 4 \
0 & 0 & 0
\end{bmatrix}. $$

Here the third column has no pivot → the 3rd vector is dependent on the first two.

Relationship with Dimension

  • In $\mathbb{R}^n$, at most $n$ independent vectors exist.
  • If you have more than $n$, dependence is guaranteed.
  • A basis of a vector space is simply a maximal independent set that spans the space.

Geometric Interpretation

  • Independent vectors = different directions.
  • Dependent vectors = one vector lies in the span of others.
  • In 2D: two independent vectors span the plane.
  • In 3D: three independent vectors span the space.

Everyday Analogies

  • Ideas in a meeting: Independent ideas contribute new insights. Dependent ideas repeat what others already said.
  • Recipes: Having salt, sugar, and flour gives three distinct ingredients. But having sugar and "2× sugar" is not new-it's dependent.
  • Travel directions: North and east are independent. North and "2× north" are dependent.

Why It Matters

  1. Independence ensures a generating set is minimal and efficient.
  2. It determines whether a system of vectors is a basis.
  3. It connects directly to rank: rank = number of independent columns (or rows).
  4. It is crucial in geometry, data compression, and machine learning-where redundancy must be identified and removed.

Try It Yourself

  1. Test whether $(1,2)$ and $(2,4)$ are independent.
  2. Are the vectors $(1,0,0), (0,1,0), (1,1,0)$ independent in $\mathbb{R}^3$?
  3. Place the vectors $(1,0,1), (0,1,1), (1,1,2)$ into a matrix and row-reduce to check independence.
  4. Challenge: Prove that any set of $n+1$ vectors in $\mathbb{R}^n$ is linearly dependent.

Linear independence is the tool that separates essential directions from redundant ones. It is the key to defining bases, counting dimensions, and understanding the structure of all vector spaces.

35. Basis and Coordinates

The concepts of span and linear independence come together in the powerful idea of a basis. A basis gives us the minimal set of building blocks needed to generate an entire vector space, with no redundancy. Once a basis is chosen, every vector in the space can be described uniquely by a list of numbers called its coordinates.

What Is a Basis?

A basis of a vector space $V$ is a set of vectors ${v_1, v_2, \dots, v_k}$ that satisfies two properties:

  1. Spanning property: $\text{span}{v_1, \dots, v_k} = V$.
  2. Independence property: The vectors are linearly independent.

In short: a basis is a spanning set with no redundancy.

Example: Standard Bases

  1. In $\mathbb{R}^2$, the standard basis is ${(1,0), (0,1)}$.
  2. In $\mathbb{R}^3$, the standard basis is ${(1,0,0), (0,1,0), (0,0,1)}$.
  3. In $\mathbb{R}^n$, the standard basis is the collection of unit vectors, each with a 1 in one position and 0 elsewhere.

These are called standard because they are the default way of describing coordinates.

Uniqueness of Coordinates

One of the most important facts about bases is that they provide unique representations of vectors.

  • Given a basis ${v_1, \dots, v_k}$, any vector $x \in V$ can be written uniquely as:

    $$ x = a_1 v_1 + a_2 v_2 + \dots + a_k v_k. $$

  • The coefficients $(a_1, a_2, \dots, a_k)$ are the coordinates of $x$ relative to that basis.

This uniqueness distinguishes bases from arbitrary spanning sets, where redundancy allows multiple representations.

Example in $\mathbb{R}^2$

Let basis = ${(1,0), (0,1)}$.

  • Vector $(3,5) = 3(1,0) + 5(0,1)$.
  • Coordinates relative to this basis: $(3,5)$.

If we switch to a different basis, the coordinates change even though the vector itself does not.

Example with Non-Standard Basis

Basis = ${(1,1), (1,-1)}$ in $\mathbb{R}^2$. Find coordinates of $x = (2,0)$.

Solve $a(1,1) + b(1,-1) = (2,0)$. This gives system:

$$ a + b = 2, \quad a - b = 0. $$

So $a=1, b=1$. Coordinates relative to this basis: $(1,1)$.

Notice: coordinates depend on basis choice.

Basis of Function Spaces

  1. For polynomials of degree ≤ 2: basis = ${1, x, x^2}$.

    • Example: $2 + 3x + 5x^2$ has coordinates $(2,3,5)$.
  2. For continuous functions on $[0,1]$, one possible basis is the infinite set ${1, x, x^2, \dots}$.

This shows bases are not restricted to geometric vectors.

Dimension

The number of vectors in a basis is the dimension of the vector space.

  • $\mathbb{R}^2$ has dimension 2.
  • $\mathbb{R}^3$ has dimension 3.
  • The space of polynomials of degree ≤ 3 has dimension 4.

Dimension tells us how many independent directions exist in the space.

Change of Basis

  • Switching from one basis to another is like translating between languages.
  • The same vector looks different depending on which "dictionary" (basis) you use.
  • Change-of-basis matrices allow systematic translation between coordinate systems.

Geometric Interpretation

  • A basis is like setting up coordinate axes in a space.
  • In 2D, two independent vectors define a grid.
  • In 3D, three independent vectors define a full coordinate system.
  • Different bases = different grids overlaying the same space.

Everyday Analogies

  • Language: A basis is like an alphabet. Every word (vector) can be spelled uniquely from the letters (basis vectors).
  • Colors: RGB is a basis for color space. Any color can be described uniquely by mixing red, green, and blue.
  • Music: Musical notes form a basis. Every chord or melody is a combination of them.

Why It Matters

  1. Bases provide the simplest possible description of a vector space.
  2. They allow us to assign unique coordinates to vectors.
  3. They connect the abstract structure of a space with concrete numerical representations.
  4. The concept underlies almost all of linear algebra: dimension, transformations, eigenvectors, and more.

Try It Yourself

  1. Show that ${(1,2), (3,4)}$ is a basis of $\mathbb{R}^2$.
  2. Express $(4,5)$ in terms of basis ${(1,1), (1,-1)}$.
  3. Prove that no basis of $\mathbb{R}^3$ can have more than 3 vectors.
  4. Challenge: Show that the set ${1, \cos x, \sin x}$ is a basis for the space of all linear combinations of $1, \cos x, \sin x$.

A basis is the minimal, elegant foundation of a vector space, turning the infinite into the manageable by providing a finite set of independent building blocks.

36. Dimension

Dimension is one of the most profound and unifying ideas in linear algebra. It gives a single number that captures the "size" or "capacity" of a vector space: how many independent directions it has. Unlike length, width, or height in everyday geometry, dimension in linear algebra applies to spaces of any kind-geometric, algebraic, or even function spaces.

Definition

The dimension of a vector space $V$ is the number of vectors in any basis of $V$.

  • Since all bases of a vector space have the same number of elements, dimension is well-defined.

  • If $\dim V = n$, then:

    • Every set of more than $n$ vectors in $V$ is dependent.
    • Every set of exactly $n$ independent vectors forms a basis.

Examples in Familiar Spaces

  1. $\dim(\mathbb{R}^2) = 2$.

    • Basis: $(1,0), (0,1)$.
    • Two directions cover the whole plane.
  2. $\dim(\mathbb{R}^3) = 3$.

    • Basis: $(1,0,0), (0,1,0), (0,0,1)$.
    • Three independent directions span 3D space.
  3. The set of all polynomials of degree ≤ 2 has dimension 3.

    • Basis: ${1, x, x^2}$.
  4. The space of all $m \times n$ matrices has dimension $mn$.

    • Each entry is independent, and the standard basis consists of matrices with a single 1 and the rest 0.

Finite vs. Infinite Dimensions

  • Finite-dimensional spaces: $\mathbb{R}^n$, polynomials of degree ≤ $k$.

  • Infinite-dimensional spaces:

    • The space of all polynomials (no degree limit).
    • The space of all continuous functions.
    • These cannot be spanned by a finite set of vectors.

Dimension and Subspaces

  • Any subspace of $\mathbb{R}^n$ has dimension ≤ $n$.
  • A line through the origin in $\mathbb{R}^3$: dimension 1.
  • A plane through the origin in $\mathbb{R}^3$: dimension 2.
  • The whole space: dimension 3.
  • The trivial subspace ${0}$: dimension 0.

Dimension and Systems of Equations

When solving $A\mathbf{x} = \mathbf{b}$:

  • The dimension of the column space = rank = number of independent directions in the outputs.

  • The dimension of the null space = number of free variables.

  • By the rank–nullity theorem:

    $$ \dim(\text{column space}) + \dim(\text{null space}) = \text{number of variables}. $$

Geometric Meaning

  • Dimension counts the minimum number of coordinates needed to describe a vector.
  • In $\mathbb{R}^2$, you need 2 numbers.
  • In $\mathbb{R}^3$, you need 3 numbers.
  • In the polynomial space of degree ≤ 3, you need 4 coefficients.

Thus, dimension = length of coordinate list.

Everyday Analogies

  • Maps: A flat map needs 2 coordinates (latitude, longitude). A globe is 3D and needs 3. Adding altitude makes it 3D as well.
  • Languages: To describe meaning, you need enough independent words. Redundant words don't add dimension; new independent concepts do.
  • Recipes: To describe all possible flavors, you need a certain number of independent ingredients. More ingredients = higher-dimensional "flavor space."

Checking Dimension in Practice

  1. Place candidate vectors as columns of a matrix.
  2. Row reduce to echelon form.
  3. Count pivots. That number = dimension of the span of those vectors.

Why It Matters

  1. Dimension is the most fundamental measure of a vector space.
  2. It tells us how "large" or "complex" the space is.
  3. It sets absolute limits: in $\mathbb{R}^n$, no more than $n$ independent vectors exist.
  4. It underlies coordinate systems, bases, and transformations.
  5. It bridges geometry (lines, planes, volumes) with algebra (solutions, equations, matrices).

Try It Yourself

  1. What is the dimension of the span of $(1,2,3)$, $(2,4,6)$, $(0,0,0)$?
  2. Find the dimension of the subspace of $\mathbb{R}^3$ defined by $x+y+z=0$.
  3. Prove that the set of all $2 \times 2$ symmetric matrices has dimension 3.
  4. Challenge: Show that the space of polynomials of degree ≤ $k$ has dimension $k+1$.

Dimension is the measuring stick of linear algebra: it tells us how many independent pieces of information are needed to describe the whole space.

37. Rank–Nullity Theorem

The rank–nullity theorem is one of the central results of linear algebra. It gives a precise balance between two fundamental aspects of a matrix: the dimension of its column space (rank) and the dimension of its null space (nullity). It shows that no matter how complicated a matrix looks, the distribution of information between its "visible" outputs and its "hidden" null directions always obeys a strict law.

Statement of the Theorem

Let $A$ be an $m \times n$ matrix (mapping $\mathbb{R}^n \to \mathbb{R}^m$):

$$ \text{rank}(A) + \text{nullity}(A) = n $$

where:

  • rank(A) = dimension of the column space of $A$.
  • nullity(A) = dimension of the null space of $A$.
  • $n$ = number of columns of $A$, i.e., the number of variables.

Intuition

Think of a matrix as a machine that transforms input vectors into outputs:

  • Rank measures how many independent output directions survive.
  • Nullity measures how many input directions get "lost" (mapped to zero).
  • The theorem says: total inputs = useful directions (rank) + wasted directions (nullity).

This ensures nothing disappears mysteriously-every input direction is accounted for.

Example 1: Full Rank

$$ A = \begin{bmatrix}
1 & 0 \
0 & 1 \
\end{bmatrix}. $$

  • Rank = 2 (two independent columns).
  • Null space = ${0}$, so nullity = 0.
  • Rank + nullity = 2 = number of variables.

Example 2: Dependent Columns

$$ A = \begin{bmatrix}
1 & 2 \
2 & 4 \
3 & 6 \
\end{bmatrix}. $$

  • Second column is a multiple of the first. Rank = 1.
  • Null space contains all vectors $(x,y)$ with $y = -2x$. Nullity = 1.
  • Rank + nullity = 1 + 1 = 2 = number of variables.

Example 3: Larger System

$$ A = \begin{bmatrix}
1 & 0 & 1 \
0 & 1 & 1
\end{bmatrix}. $$

  • Columns: $(1,0), (0,1), (1,1)$.
  • Only two independent columns → Rank = 2.
  • Null space: solve $x + z = 0, y + z = 0 \Rightarrow (x,y,z) = (-t,-t,t)$. Nullity = 1.
  • Rank + nullity = 2 + 1 = 3 = number of variables.

Proof Sketch (Conceptual)

  1. Row reduce $A$ to echelon form.

  2. Pivots correspond to independent columns → count = rank.

  3. Free variables correspond to null space directions → count = nullity.

  4. Each column is either a pivot column or corresponds to a free variable, so:

    $$ \text{rank} + \text{nullity} = \text{number of columns}. $$

Geometric Meaning

  • In $\mathbb{R}^3$, if a transformation collapses all vectors onto a plane (rank = 2), then one direction disappears entirely (nullity = 1).
  • In $\mathbb{R}^4$, if a matrix has rank 2, then its null space has dimension 2, meaning half the input directions vanish.

The theorem guarantees the geometry of "surviving" and "vanishing" directions always adds up consistently.

Applications

  1. Solving systems $Ax = b$:

    • Rank determines consistency and structure of solutions.
    • Nullity tells how many free parameters exist in the solution.
  2. Data compression: Rank identifies independent features; nullity shows redundancy.

  3. Computer graphics: Rank–nullity explains how 3D coordinates collapse into 2D images: one dimension of depth is lost.

  4. Machine learning: Rank signals how much real information a dataset contains; nullity indicates degrees of freedom that add nothing new.

Everyday Analogies

  • Work team: Rank = number of independent workers contributing new ideas. Nullity = number of workers repeating what others already said. Total team members = contributors + redundant voices.
  • Travel: Rank = number of useful directions on a map; nullity = directions that lead nowhere.
  • Languages: Rank = unique words, nullity = synonyms. Total vocabulary size is always the sum.

Why It Matters

  1. The rank–nullity theorem connects the abstract ideas of rank and nullity into a single, elegant formula.
  2. It ensures conservation of dimension: no information magically appears or disappears.
  3. It is essential in understanding solutions of systems, dimensions of subspaces, and the structure of linear transformations.
  4. It prepares the ground for deeper results in algebra, topology, and differential equations.

Try It Yourself

  1. Verify rank–nullity for

    $$ A = \begin{bmatrix}
    1 & 2 & 3 \
    4 & 5 & 6
    \end{bmatrix}. $$

  2. For a $4 \times 5$ matrix of rank 3, what is its nullity?

  3. In $\mathbb{R}^3$, suppose a matrix maps all of space onto a line. What are its rank and nullity?

  4. Challenge: Prove rigorously that the row space and null space are orthogonal complements, and use this to derive rank–nullity again.

The rank–nullity theorem is the law of balance in linear algebra: every input dimension is accounted for, either as a surviving direction (rank) or as one that vanishes (nullity).

38. Coordinates Relative to a Basis

Once a basis for a vector space is chosen, every vector in that space can be described uniquely in terms of the basis. These descriptions are called coordinates. Coordinates transform abstract vectors into concrete lists of numbers, making computation possible. Changing the basis changes the coordinates, but the underlying vector remains the same.

The Core Idea

Given a vector space $V$ and a basis $B = {v_1, v_2, \dots, v_n}$, every vector $x \in V$ can be written uniquely as:

$$ x = a_1 v_1 + a_2 v_2 + \dots + a_n v_n. $$

The coefficients $(a_1, a_2, \dots, a_n)$ are the coordinates of $x$ with respect to the basis $B$.

This representation is unique because basis vectors are independent.

Example in $\mathbb{R}^2$

  1. Standard basis: $B = {(1,0), (0,1)}$.

    • Vector $x = (3,5)$.
    • Coordinates relative to $B$: $(3,5)$.
  2. Non-standard basis: $B = {(1,1), (1,-1)}$.

    • Write $x = (3,5)$ as $a(1,1) + b(1,-1)$.

    • Solve:

      $$ a+b = 3, \quad a-b = 5. $$

      Adding: $2a = 8 \implies a = 4$. Subtracting: $2b = -2 \implies b = -1$.

    • Coordinates relative to this basis: $(4, -1)$.

The same vector looks different depending on the chosen basis.

Example in $\mathbb{R}^3$

Let $B = {(1,0,0), (1,1,0), (1,1,1)}$. Find coordinates of $x = (2,3,4)$.

Solve $a(1,0,0) + b(1,1,0) + c(1,1,1) = (2,3,4)$. This gives system:

$$ a+b+c = 2, \quad b+c = 3, \quad c = 4. $$

From $c=4$, we get $b+c=3 \implies b=-1$. Then $a+b+c=2 \implies a-1+4=2 \implies a=-1$. Coordinates: $(-1, -1, 4)$.

Matrix Formulation

If $B = {v_1, \dots, v_n}$, form the basis matrix

$$ P = [v_1 \ v_2 \ \dots \ v_n]. $$

Then for a vector $x$, its coordinate vector $[x]_B$ satisfies

$$ P [x]_B = x. $$

Thus,

$$ [x]_B = P^{-1}x. $$

This shows coordinate transformation is simply matrix multiplication.

Changing Coordinates

Suppose a vector has coordinates $[x]_B$ relative to basis $B$. If we switch to another basis $C$, we use a change-of-basis matrix to convert coordinates:

$$ [x]_C = (P_C^{-1} P_B) [x]_B. $$

This process is fundamental in computer graphics, robotics, and data transformations.

Geometric Meaning

  • A basis defines a coordinate system: axes in the space.
  • Coordinates are the "addresses" of vectors relative to those axes.
  • Changing basis is like rotating or stretching the grid: the address changes, but the point does not.

Everyday Analogies

  • Maps: Latitude and longitude are coordinates relative to Earth's axis. If we change the map projection, the coordinates change, but the physical location stays the same.
  • Languages: Describing the same object in English or French yields different words (coordinates), but the object (vector) is unchanged.
  • Music: The same melody can be written in different keys (bases); the notes shift, but the tune remains.

Why It Matters

  1. Coordinates make abstract vectors computable.
  2. They allow us to represent functions, polynomials, and geometric objects numerically.
  3. Changing basis simplifies problems-e.g., diagonalization makes matrices easy to analyze.
  4. They connect the abstract (spaces, bases) with the concrete (numbers, matrices).

Try It Yourself

  1. Express $x=(4,2)$ relative to basis ${(1,1),(1,-1)}$.
  2. Find coordinates of $x=(2,1,3)$ relative to basis ${(1,0,1),(0,1,1),(1,1,0)}$.
  3. If basis $B$ is the standard basis and basis $C={(1,1),(1,-1)}$, compute the change-of-basis matrix from $B$ to $C$.
  4. Challenge: Show that if $P$ is invertible, its columns form a basis, and explain why this guarantees uniqueness of coordinates.

Coordinates relative to a basis are the bridge between geometry and algebra: they turn abstract spaces into numerical systems where computation, reasoning, and transformation become systematic and precise.

39. Change-of-Basis Matrices

Every vector space allows multiple choices of basis, and each basis provides a different way of describing the same vectors. The process of moving from one basis to another is called a change of basis. To perform this change systematically, we use a change-of-basis matrix. This matrix acts as a translator between coordinate systems: it converts the coordinates of a vector relative to one basis into coordinates relative to another.

Why Change Bases?

  1. Simplicity of computation: Some problems are easier in certain bases. For example, diagonalizing a matrix allows us to raise it to powers more easily.
  2. Geometry: Different bases can represent rotated or scaled coordinate systems.
  3. Applications: In physics, computer graphics, robotics, and data science, changing bases is equivalent to switching perspectives or reference frames.

The Basic Setup

Let $V$ be a vector space with two bases:

  • $B = {b_1, b_2, \dots, b_n}$
  • $C = {c_1, c_2, \dots, c_n}$

Suppose a vector $x \in V$ has coordinates $[x]_B$ relative to $B$, and $[x]_C$ relative to $C$.

We want a matrix $P_{B \to C}$ such that:

$$ [x]C = P{B \to C} [x]_B. $$

This matrix $P_{B \to C}$ is the change-of-basis matrix from $B$ to $C$.

Constructing the Change-of-Basis Matrix

  1. Write each vector in the basis $B$ in terms of the basis $C$.
  2. Place these coordinate vectors as the columns of a matrix.
  3. The resulting matrix converts coordinates from $B$ to $C$.

In matrix form:

$$ P_{B \to C} = \big[ [b_1]_C \ [b_2]_C \ \dots \ [b_n]_C \big]. $$

Example in $\mathbb{R}^2$

Let

  • $B = {(1,0), (0,1)}$ (standard basis).
  • $C = {(1,1), (1,-1)}$.

To build $P_{B \to C}$:

  • Express each vector of $B$ in terms of $C$.

Solve:

$$ (1,0) = a(1,1) + b(1,-1). $$

This gives system:

$$ a+b=1, \quad a-b=0. $$

Solution: $a=\tfrac{1}{2}, b=\tfrac{1}{2}$. So $(1,0) = \tfrac{1}{2}(1,1) + \tfrac{1}{2}(1,-1)$.

Next:

$$ (0,1) = a(1,1) + b(1,-1). $$

System:

$$ a+b=0, \quad a-b=1. $$

Solution: $a=\tfrac{1}{2}, b=-\tfrac{1}{2}$.

Thus:

$$ P_{B \to C} = \begin{bmatrix}
\tfrac{1}{2} & \tfrac{1}{2} \
\tfrac{1}{2} & -\tfrac{1}{2}
\end{bmatrix}. $$

So for any vector $x$,

$$ [x]C = P{B \to C}[x]_B. $$

Inverse Change of Basis

If $P_{B \to C}$ is the change-of-basis matrix from $B$ to $C$, then its inverse is the change-of-basis matrix in the opposite direction:

$$ P_{C \to B} = (P_{B \to C})^{-1}. $$

This makes sense: translating back and forth between languages should undo itself.

General Formula with Basis Matrices

Let

$$ P_B = [b_1 \ b_2 \ \dots \ b_n], \quad P_C = [c_1 \ c_2 \ \dots \ c_n], $$

the matrices whose columns are basis vectors written in standard coordinates.

Then the change-of-basis matrix from $B$ to $C$ is:

$$ P_{B \to C} = P_C^{-1} P_B. $$

This formula is extremely useful because it reduces the problem to matrix multiplication.

Geometric Interpretation

  • Changing basis is like rotating or stretching the grid lines of a coordinate system.
  • The vector itself (the point in space) does not move. What changes is its description in terms of the new grid.
  • The change-of-basis matrix is the tool that translates between these descriptions.

Applications

  1. Diagonalization: Expressing a matrix in a basis of its eigenvectors makes it diagonal, simplifying analysis.
  2. Computer graphics: Changing camera viewpoints requires change-of-basis matrices.
  3. Robotics: Coordinate transformations connect robot arms, joints, and workspace frames.
  4. Data science: PCA finds a new basis (principal components) where data is easier to analyze.

Everyday Analogies

  • Languages: The word "dog" in English corresponds to "chien" in French. The change-of-basis matrix is the bilingual dictionary.
  • Currencies: Converting from dollars to euros requires an exchange rate. The matrix is the exchange table.
  • Maps: Switching between Cartesian and polar coordinates is a change of basis-different coordinates, same location.

Why It Matters

  1. Provides a universal method to translate coordinates between bases.
  2. Makes abstract transformations concrete and computable.
  3. Forms the backbone of diagonalization, Jordan form, and the spectral theorem.
  4. Connects algebraic manipulations with geometry and real-world reference frames.

Try It Yourself

  1. Compute the change-of-basis matrix from the standard basis to ${(2,1),(1,1)}$ in $\mathbb{R}^2$.
  2. Find the change-of-basis matrix from basis ${(1,0,0),(0,1,0),(0,0,1)}$ to ${(1,1,0),(0,1,1),(1,0,1)}$ in $\mathbb{R}^3$.
  3. Show that applying $P_{B \to C}$ then $P_{C \to B}$ returns the original coordinates.
  4. Challenge: Derive the formula $P_{B \to C} = P_C^{-1} P_B$ starting from the definition of coordinates.

Change-of-basis matrices give us the precise mechanism for switching perspectives. They ensure that although bases change, vectors remain invariant, and computations remain consistent.

40. Affine Subspaces

So far, vector spaces and subspaces have always passed through the origin. But in many real-world situations, we deal with shifted versions of these spaces: planes not passing through the origin, lines offset from the zero vector, or solution sets to linear equations with nonzero constants. These structures are called affine subspaces. They extend the idea of subspaces by allowing "translation away from the origin."

Definition

An affine subspace of a vector space $V$ is a set of the form

$$ x_0 + W = {x_0 + w : w \in W}, $$

where:

  • $x_0 \in V$ is a fixed vector (the "base point" or "anchor"),
  • $W \subseteq V$ is a linear subspace.

Thus, an affine subspace is simply a subspace shifted by a vector.

Examples in $\mathbb{R}^2$

  1. A line through the origin: $\text{span}{(1,2)}$. This is a subspace.
  2. A line not through the origin: $(3,1) + \text{span}{(1,2)}$. This is an affine subspace.
  3. The entire plane: $\mathbb{R}^2$, which is both a subspace and an affine subspace.

Examples in $\mathbb{R}^3$

  1. Plane through the origin: $\text{span}{(1,0,0),(0,1,0)}$.
  2. Plane not through the origin: $(2,3,4) + \text{span}{(1,0,0),(0,1,0)}$.
  3. Line parallel to the z-axis but passing through $(1,1,5)$: $(1,1,5) + \text{span}{(0,0,1)}$.

Relation to Linear Systems

Affine subspaces naturally arise as solution sets of linear equations.

  1. Homogeneous system: $Ax = 0$.

    • Solution set is a subspace (the null space).
  2. Non-homogeneous system: $Ax = b$ with $b \neq 0$.

    • Solution set is affine.

    • If $x_p$ is one particular solution, then the general solution is:

      $$ x = x_p + N(A), $$

      where $N(A)$ is the null space.

Thus, the geometry of solving equations leads naturally to affine subspaces.

Affine Dimension

The dimension of an affine subspace is defined as the dimension of its direction subspace $W$.

  • A point: affine subspace of dimension 0.
  • A line: dimension 1.
  • A plane: dimension 2.
  • Higher analogs continue in $\mathbb{R}^n$.

Difference Between Subspaces and Affine Subspaces

  • Subspaces always contain the origin.
  • Affine subspaces may or may not pass through the origin.
  • Every subspace is an affine subspace (with base point $x_0 = 0$).

Geometric Intuition

Think of affine subspaces as "flat sheets" floating in space:

  • A line through the origin is a rope tied at the center.
  • A line parallel to it but offset is the same rope moved to the side.
  • Affine subspaces preserve shape and direction, but not position.

Everyday Analogies

  • Railway tracks: A railway line is straight (like a subspace), but it doesn't need to pass through the city center (origin).
  • Office floors: Each floor in a building is a plane parallel to the ground, offset vertically. The ground floor is like the subspace through the origin; higher floors are affine subspaces.
  • Schedules: A repeating pattern (like working hours 9–5) is the subspace. Starting the shift at 10 instead of 9 shifts it into an affine version.

Applications

  1. Linear equations: General solutions are affine subspaces.
  2. Optimization: Feasible regions in linear programming are affine subspaces (intersected with inequalities).
  3. Computer graphics: Affine transformations map affine subspaces to affine subspaces, preserving straightness and parallelism.
  4. Machine learning: Affine decision boundaries (like hyperplanes) separate data into classes.

Why It Matters

  1. Affine subspaces generalize subspaces, making linear algebra more flexible.
  2. They allow us to describe solution sets that don't include the origin.
  3. They provide the geometric foundation for affine geometry, computer graphics, and optimization.
  4. They serve as the bridge from pure linear algebra to applied modeling.

Try It Yourself

  1. Show that the set of solutions to

    $$ x+y+z=1 $$

    is an affine subspace of $\mathbb{R}^3$. Identify its dimension.

  2. Find the general solution to

    $$ x+2y=3 $$

    and describe it as an affine subspace.

  3. Prove that the intersection of two affine subspaces is either empty or another affine subspace.

  4. Challenge: Show that every affine subspace can be written uniquely as $x_0 + W$ with $W$ a subspace.

Affine subspaces are the natural setting for most real-world linear problems: they combine the strict structure of subspaces with the freedom of translation, capturing both direction and position.

Closing

Each basis a song,
dimension counts melodies,
the space breathes its form.

Chapter 5. Linear Transformation and Structure

Opening

Maps preserve the line,
reflections ripple outward,
motion kept in frame.

41. Linear Transformations

A linear transformation is the heart of linear algebra. It is the rule that connects two vector spaces in a way that respects their linear structure: addition and scalar multiplication. Instead of thinking of vectors as static objects, linear transformations let us study how vectors move, stretch, rotate, project, or reflect. They give linear algebra its dynamic power and are the bridge between abstract theory and concrete applications.

Definition

A function $T: V \to W$ between vector spaces is called a linear transformation if for all $u, v \in V$ and scalars $a, b \in \mathbb{R}$ (or another field),

$$ T(au + bv) = aT(u) + bT(v). $$

This single condition encodes two rules:

  1. Additivity: $T(u+v) = T(u) + T(v)$.
  2. Homogeneity: $T(av) = aT(v)$.

If both are satisfied, the transformation is linear.

Examples of Linear Transformations

  1. Scaling: $T(x) = 3x$ in $\mathbb{R}$. Every number is stretched threefold.

  2. Rotation in the plane: $T(x,y) = (x\cos\theta - y\sin\theta, , x\sin\theta + y\cos\theta)$.

  3. Projection: Projecting $(x,y,z)$ onto the $xy$-plane: $T(x,y,z) = (x,y,0)$.

  4. Differentiation: On the space of polynomials, $T(p(x)) = p'(x)$.

  5. Integration: On continuous functions, $T(f)(x) = \int_0^x f(t) , dt$.

All these are linear because they preserve addition and scaling.

Non-Examples

  • $T(x) = x^2$ is not linear, because $(x+y)^2 \neq x^2 + y^2$.
  • $T(x,y) = (x+1, y)$ is not linear, because it fails homogeneity: scaling doesn't preserve the "+1."

Nonlinear rules break the structure of vector spaces.

Matrix Representation

Every linear transformation from $\mathbb{R}^n$ to $\mathbb{R}^m$ can be represented by a matrix.

If $T: \mathbb{R}^n \to \mathbb{R}^m$, then there exists an $m \times n$ matrix $A$ such that:

$$ T(x) = Ax. $$

The columns of $A$ are simply $T(e_1), T(e_2), \dots, T(e_n)$, where $e_i$ are the standard basis vectors.

Example: Let $T(x,y) = (2x+y, x-y)$.

  • $T(e_1) = T(1,0) = (2,1)$.
  • $T(e_2) = T(0,1) = (1,-1)$. So

$$ A = \begin{bmatrix} 2 & 1 \ 1 & -1 \end{bmatrix}. $$

Then $T(x,y) = A \begin{bmatrix} x \ y \end{bmatrix}$.

Properties of Linear Transformations

  1. The image of the zero vector is always zero: $T(0) = 0$.
  2. The image of a line through the origin is again a line (or collapsed to a point).
  3. Composition of linear transformations is linear.
  4. Every linear transformation preserves the structure of subspaces.

Kernel and Image (Preview)

For $T: V \to W$:

  • The kernel (or null space) is all vectors mapped to zero: $\ker T = {v \in V : T(v) = 0}$.
  • The image (or range) is all outputs that can be achieved: $\text{im}(T) = {T(v) : v \in V}$. The rank–nullity theorem applies here:

$$ \dim(\ker T) + \dim(\text{im}(T)) = \dim(V). $$

Geometric Interpretation

Linear transformations reshape space:

  • Scaling stretches space uniformly in one direction.
  • Rotation spins space while preserving lengths.
  • Projection flattens space onto lower dimensions.
  • Reflection flips space across a line or plane.

The key feature: straight lines remain straight, and the origin stays fixed.

Everyday Analogies

  • Maps and coordinates: A GPS system transforms geographic positions (lat/long) into screen positions (x,y).
  • Shadows: Projecting a 3D object onto the ground is a linear transformation.
  • Economics: A matrix that takes production levels (inputs) and outputs profits is a linear transformation of data.
  • Music: An equalizer linearly adjusts different frequencies: the structure of the sound is preserved but reshaped.

Applications

  1. Computer graphics: Scaling, rotating, projecting 3D objects onto 2D screens.
  2. Robotics: Transformations between joint coordinates and workspace positions.
  3. Data science: Linear mappings represent dimensionality reduction and feature extraction.
  4. Differential equations: Solutions often involve linear operators acting on function spaces.
  5. Machine learning: Weight matrices in neural networks are stacked linear transformations, interspersed with nonlinearities.

Why It Matters

  1. Linear transformations generalize matrices to any vector space.
  2. They unify geometry, algebra, and applications under one concept.
  3. They provide the natural framework for studying eigenvalues, eigenvectors, and decompositions.
  4. They model countless real-world processes: physical, computational, and abstract.

Try It Yourself

  1. Prove that $T(x,

Truncated — view the full README on GitHub.

little-book-of/linear-algebra

A concise, beginner-friendly introduction to the core ideas of linear algebra.

Jupyter Notebook

2,003

29 commits

updated Mar 16, 2026

See the code

README

The Little Book of Linear Algebra

A concise, beginner-friendly introduction to the core ideas of Linear Algebra.

A clear, hands-on guide to the geometry and structure behind vectors and matrices.

Formats

Open In Colab

For old version (v1), here is the link

Build it yourself (Quarto)

We use Quarto to generate all outputs.

Preview locally:

quarto preview

Render outputs:

# All configured formats
quarto render

# Individual formats
quarto render --to html     # site into docs/
quarto render --to pdf      # docs/book.pdf
quarto render --to epub     # docs/book.epub
quarto render --to latex    # docs/book-latex/book.tex

The Book

Chapter 1. Vectors, scalars, and geometry

Opening

Arrows in the air,
directions whisper softly—
the plane comes alive.

1. Scalars, Vectors, and Coordinate Systems

When we begin learning linear algebra, everything starts with the simplest building blocks: scalars and vectors. A scalar is just a single number, like 3, –7, or π. It carries only magnitude and no direction. Scalars are what we use for counting, measuring length, or scaling other objects up and down. A vector, by contrast, is an ordered collection of numbers. You can picture it as an arrow pointing somewhere in space, or simply as a list like (2, 5) in 2D or (1, –3, 4) in 3D. Where scalars measure "how much," vectors measure both "how much" and "which way."

Coordinate Systems

To talk about vectors, we need a coordinate system. Imagine laying down two perpendicular axes on a sheet of paper: the x-axis (left to right) and the y-axis (up and down). Every point on the sheet can be described with two numbers: how far along the x-axis, and how far along the y-axis. This pair of numbers is a vector in 2D. Add a z-axis pointing up from the page, and you have 3D space. Each coordinate system gives us a way to describe vectors numerically, even though the underlying "space" is the same.

Visualizing Scalars vs. Vectors

  • A scalar is like a single tick mark on a ruler.
  • A vector is like an arrow that starts at the origin (0, 0, …) and ends at the point defined by its components. For example, the vector (3, 4) in 2D points from the origin to the point 3 units along the x-axis and 4 units along the y-axis.

Why Start Here?

Understanding the difference between scalars and vectors is the foundation for everything else in linear algebra. Every concept-matrices, linear transformations, eigenvalues-eventually reduces to how we manipulate vectors and scale them with scalars. Without this distinction, the rest of the subject would have no anchor.

Why It Matters

Nearly every field of science and engineering depends on this idea. Physics uses vectors for velocity, acceleration, and force. Computer graphics uses them to represent points, colors, and transformations. Data science treats entire datasets as high-dimensional vectors. By mastering scalars and vectors early, you unlock the language in which modern science and technology are written.

Try It Yourself

  1. Draw an x- and y-axis on a piece of paper. Plot the vector (2, 3).
  2. Now draw the vector (–1, 4). Compare their directions and lengths.
  3. Think: which of these two vectors points "more upward"? Which is "longer"?

These simple experiments already give you intuition for the operations you'll perform again and again in linear algebra.

2. Vector Notation, Components, and Arrows

Linear algebra gives us powerful ways to describe and manipulate vectors, but before we can do anything with them, we need a precise notation system. Notation is not just cosmetic-it tells us how to read, write, and think about vectors clearly and unambiguously. In this section, we'll explore how vectors are written, how their components are represented, and how we can interpret them visually as arrows.

Writing Vectors

Vectors are usually denoted by lowercase letters in bold (like $\mathbf{v}, \mathbf{w}, \mathbf{x}$)
or with an arrow overhead (like $\vec{v}$).

For instance, the vector $\mathbf{v} = (2, 5)$ is the same as $\vec{v} = (2, 5)$.

The style depends on context: mathematicians often use bold, physicists often use arrows.
In handwritten notes, people sometimes underline vectors (e.g., $\underline{v}$) to avoid confusion with scalars.

The important thing is to distinguish vectors from scalars at a glance.

Components of a Vector

A vector in two dimensions has two components, written as $(x, y)$.
In three dimensions, it has three components: $(x, y, z)$.
More generally, an $n$-dimensional vector has $n$ components: $(v_1, v_2, \ldots, v_n)$.
Each component tells us how far the vector extends along one axis of the coordinate system.

For example:

  • $\mathbf{v} = (3, 4)$ means the vector extends 3 units along the $x$-axis and 4 units along the $y$-axis.
  • $\mathbf{w} = (-2, 0, 5)$ means the vector extends $-2$ units along the $x$-axis, $0$ along the $y$-axis, and 5 along the $z$-axis.

We often refer to the $i$-th component of a vector $\mathbf{v}$ as $v_i$.
So, for $\mathbf{v} = (3, 4, 5)$, we have $v_1 = 3$, $v_2 = 4$, $v_3 = 5$.

Column vs. Row Vectors

Vectors can be written in two common ways:

  • As a row vector: $(v_1, v_2, v_3)$

  • As a column vector:

    $$ \begin{bmatrix} v_1 \ v_2 \ v_3 \end{bmatrix} $$

Both represent the same abstract object.
Row vectors are convenient for quick writing, while column vectors are essential when we start multiplying by matrices, because the dimensions must align.

Vectors as Arrows

The most intuitive way to picture a vector is as an arrow:

  • It starts at the origin (0, 0, …).
  • It ends at the point given by its components.

For example, the vector (2, 3) in 2D is drawn as an arrow from (0, 0) to (2, 3). The arrow has both direction (where it points) and magnitude (its length). This geometric picture makes abstract algebraic manipulations much easier to grasp.

Position Vectors vs. Free Vectors

There are two common interpretations of vectors:

  1. Position vector - a vector that points from the origin to a specific point in space. Example: (2, 3) is the position vector for the point (2, 3).
  2. Free vector - an arrow with length and direction, but not tied to a specific starting point. For instance, an arrow of length 5 pointing northeast can be drawn anywhere, but it still represents the same vector.

In linear algebra, we often treat vectors as free vectors, because their meaning does not depend on where they are drawn.

Example: Reading a Vector

Suppose u = (–3, 2).

  • The first component (–3) means move 3 units left along the x-axis.
  • The second component (2) means move 2 units up along the y-axis. So the arrow points to the point (–3, 2). Even without a diagram, the components tell us exactly what the arrow would look like.

Why It Matters

Clear notation is the backbone of linear algebra. Without it, equations quickly become unreadable, and intuition about direction and size is lost. The way we write vectors determines how easily we can connect the algebra (numbers and symbols) to the geometry (arrows and spaces). This dual perspective-symbolic and visual-is what makes linear algebra powerful and practical.

Try It Yourself

  1. Write down the vector (4, –1). Draw it on graph paper.
  2. Rewrite the same vector as a column vector.
  3. Translate the vector (4, –1) by moving its starting point to (2, 3) instead of the origin. Notice that the arrow looks the same-it just starts elsewhere.
  4. For a harder challenge: draw the 3D vector (2, –1, 3). Even if you can't draw perfectly in 3D, try to show each component along the x, y, and z axes.

By practicing both the notation and the arrow picture, you'll develop fluency in switching between abstract symbols and concrete visualizations. This skill will make every later concept in linear algebra far more intuitive.

3. Vector Addition and Scalar Multiplication

Once we know how to describe vectors with components and arrows, the next step is to learn how to combine them. Two fundamental operations form the backbone of linear algebra: adding vectors together and scaling vectors with numbers (scalars). These two moves, though simple, generate everything else we'll build later. With them, we can describe motion, forces, data transformations, and more.

Vector Addition in Coordinates

Suppose we have two vectors in 2D:
$\mathbf{u} = (u_1, u_2), \quad \mathbf{v} = (v_1, v_2)$.

Their sum is defined as:
$$ \mathbf{u} + \mathbf{v} = (u_1 + v_1, ; u_2 + v_2). $$

In words, you add corresponding components.
This works in higher dimensions too:

$$ (u_1, u_2, \ldots, u_n) + (v_1, v_2, \ldots, v_n) = (u_1 + v_1, ; u_2 + v_2, ; \ldots, ; u_n + v_n). $$

Example: $$ (2, 3) + (-1, 4) = (2 - 1, ; 3 + 4) = (1, 7). $$

Vector Addition as Geometry

The geometric picture is even more illuminating. If you draw vector u as an arrow, then place the tail of v at the head of u, the arrow from the start of u to the head of v is u + v. This is called the tip-to-tail rule. The parallelogram rule is another visualization: place u and v tail-to-tail, form a parallelogram, and the diagonal is their sum.

Example: u = (3, 1), v = (2, 2). Draw both from the origin. Their sum (5, 3) is exactly the diagonal of the parallelogram they span.

Scalar Multiplication in Coordinates

Scalars stretch or shrink vectors.
If $\mathbf{u} = (u_1, u_2, \ldots, u_n)$ and $c$ is a scalar, then:

$$ c \cdot \mathbf{u} = (c \cdot u_1, ; c \cdot u_2, ; \ldots, ; c \cdot u_n). $$

Example:

$$ 2 \cdot (3, 4) = (6, 8). $$

$$ (-1) \cdot (3, 4) = (-3, -4). $$

Multiplying by a positive scalar stretches or compresses the arrow while keeping the direction the same. Multiplying by a negative scalar flips the arrow to point the opposite way.

Scalar Multiplication as Geometry

Imagine the vector (1, 2). Draw it on graph paper: it goes right 1, up 2. Now double it: (2, 4). The arrow points in the same direction but is twice as long. Halve it: (0.5, 1). It's the same direction but shorter. Negate it: (–1, –2). Now the arrow points backward.

This geometric picture explains why we call these numbers "scalars": they scale the vector.

Combining Both: Linear Combinations

Vector addition and scalar multiplication are not just separate tricks-they combine to form the heart of linear algebra: linear combinations.

A linear combination of vectors $u$ and $v$ is any vector of the form
$a \cdot u + b \cdot v$, where $a$ and $b$ are scalars.

Example:
If $u = (1, 0)$ and $v = (0, 1)$, then
$3 \cdot u + 2 \cdot v = (3, 2)$.

This shows how any point on the grid can be reached by scaling and adding these two basic vectors.
That’s the essence of constructing spaces.

Algebraic Properties

Vector addition and scalar multiplication obey rules that mirror arithmetic with numbers:

  • Commutativity: $u + v = v + u$
  • Associativity: $(u + v) + w = u + (v + w)$
  • Distributivity over scalars: $c \cdot (u + v) = c \cdot u + c \cdot v$
  • Distributivity over numbers: $(a + b) \cdot u = a \cdot u + b \cdot u$

These rules are not trivial bookkeeping - they guarantee that linear algebra behaves predictably,
which is why it works as the language of science.

Everyday Analogies

  • Walking directions: If you walk 3 steps north and then 4 steps east, that's like adding (0, 3) + (4, 0) = (4, 3).
  • Forces in physics: If two people push on a box in different directions, the total force is the vector sum of their pushes.
  • Budget planning: Think of income and expenses as vectors of numbers. Combining them is just vector addition.

Why It Matters

With only these two operations-addition and scaling-you can already describe lines, planes, and entire spaces. Any system that grows by combining influences, like physics, economics, or machine learning, is built on these simple rules. Later, when we define matrix multiplication, dot products, and eigenvalues, they all reduce to repeated patterns of adding and scaling vectors.

Try It Yourself

  1. Add (2, 3) and (–1, 4). Draw the result on graph paper.
  2. Multiply (1, –2) by 3, and then add (0, 5). What is the final vector?
  3. For a deeper challenge: Let u = (1, 2) and v = (2, –1). Sketch all vectors of the form a·u + b·v for integer values of a, b between –2 and 2. Notice the grid of points you create-that's the span of these two vectors.

This simple practice shows you how combining two basic vectors through addition and scaling generates a whole structured space, the first glimpse of linear algebra's real power.

4. Linear Combinations and Span

After learning to add vectors and scale them, the natural next question is: what can we build from these two operations? The answer is the concept of linear combinations, which leads directly to one of the most fundamental ideas in linear algebra: the span of a set of vectors. These ideas tell us not only what individual vectors can do, but how groups of vectors can shape entire spaces.

What Is a Linear Combination?

A linear combination is any vector formed by multiplying vectors with scalars and then adding the results together.

Formally, given vectors $v_1, v_2, \ldots, v_k$ and scalars $a_1, a_2, \ldots, a_k$, a linear combination looks like:

$$ a_1 \cdot v_1 + a_2 \cdot v_2 + \cdots + a_k \cdot v_k. $$

This is nothing more than repeated addition and scaling, but the idea is powerful because it describes how vectors combine to generate new ones.

Example:
Let $u = (1, 0)$ and $v = (0, 1)$. Then any linear combination $a \cdot u + b \cdot v = (a, b)$.
This shows that every point in the 2D plane can be expressed as a linear combination of these two simple vectors.

Geometric Meaning

Linear combinations are about mixing directions and magnitudes. Each vector acts like a "directional ingredient," and the scalars control how much of each ingredient you use.

  • With one vector: You can only reach points on a single line through the origin.
  • With two non-parallel vectors in 2D: You can reach every point in the plane.
  • With three non-coplanar vectors in 3D: You can reach all of 3D space.

This progression shows that the power of linear combinations depends not just on the vectors themselves but on how they relate to each other.

The Span of a Set of Vectors

The span of a set of vectors is the collection of all possible linear combinations of them.
It answers the question: "What space do these vectors generate?"

Notation:

$$ \text{Span}{v_1, v_2, \ldots, v_k} = {a_1 v_1 + a_2 v_2 + \cdots + a_k v_k ;|; a_i \in \mathbb{R}}. $$

Examples:

  • $\text{Span}{(1, 0)}$ = all multiples of $(1, 0)$, which is the $x$-axis.
  • $\text{Span}{(1, 0), (0, 1)}$ = all of $\mathbb{R}^2$, the entire plane.
  • $\text{Span}{(1, 2), (2, 4)}$ = just the line through $(1, 2)$, because the second vector is a multiple of the first.

So the span depends heavily on whether the vectors add new directions or just duplicate what’s already there.

Parallel and Independent Vectors

If vectors point in the same or opposite directions (one is a scalar multiple of another), then their span is just a line. They don't add any new coverage of space. But if they point in different directions, they open up new dimensions. This leads to the critical idea of linear independence, which we'll explore later: vectors are independent if none of them is a linear combination of the others.

Visualizing Span in Different Dimensions

  • In 2D:

    • One vector spans a line.
    • Two independent vectors span the whole plane.
  • In 3D:

    • One vector spans a line.
    • Two independent vectors span a plane.
    • Three independent vectors span all of 3D space.
  • In higher dimensions: The same pattern continues. A set of k independent vectors spans a k-dimensional subspace inside the larger space.

Everyday Analogies

  • Color mixing: Red and blue paints can mix to make purple shades. Add yellow, and you can cover a broader spectrum. Similarly, vectors combine to produce new ones.
  • Cooking recipes: Ingredients (vectors) can be scaled up or down and combined in different amounts. The span is the full menu of dishes you can create with those ingredients.
  • Directions in navigation: If you can only walk north and south, your span is a line. Add east-west walking, and suddenly you can reach any location in the city grid.

Algebraic Properties

  • The span of vectors always includes the zero vector, because you can choose all scalars = 0.
  • The span is always a subspace, meaning it's closed under addition and scalar multiplication. If you add two vectors in the span, the result stays in the span.
  • The span grows when you add new independent vectors, but not if the new vector is just a combination of the old ones.

Why It Matters

Linear combinations and span are the foundation for almost everything else in linear algebra:

  • They define what it means for vectors to be independent or dependent.
  • They form the basis for solving linear systems (solutions are often described as spans).
  • They explain how dimensions arise in vector spaces.
  • They underpin practical methods like principal component analysis, where data is projected onto the span of a few important vectors.

In short, the span tells us the "reach" of a set of vectors, and linear combinations are the mechanism to explore that reach.

Try It Yourself

  1. Take vectors (1, 0) and (0, 1). Write down three different linear combinations and plot them. What shape do you notice?
  2. Try vectors (1, 2) and (2, 4). Write down three different linear combinations. Plot them. What's different from the previous case?
  3. In 3D, consider (1, 0, 0) and (0, 1, 0). Describe their span. Add (0, 0, 1). How does the span change?
  4. Challenge: Pick vectors (1, 2, 3) and (4, 5, 6). Do they span a plane or all of 3D space? How can you tell?

By experimenting with simple examples, you'll see clearly how the idea of span captures the richness or limitations of combining vectors.

5. Length (Norm) and Distance

So far, vectors have been arrows with direction and components. To compare them more meaningfully, we need ways to talk about how long they are and how far apart they are. These notions are formalized through the norm of a vector (its length) and the distance between vectors. These concepts tie together the algebra of components and the geometry of space.

The Length (Norm) of a Vector

The norm of a vector measures its magnitude, or how long the arrow is.
For a vector $v = (v_1, v_2, \ldots, v_n)$ in $n$-dimensional space, its norm is defined as:

$$ |v| = \sqrt{v_1^2 + v_2^2 + \cdots + v_n^2}. $$

This formula comes directly from the Pythagorean theorem: the length of the hypotenuse equals the square root of the sum of squares of the legs.
In 2D, this is the familiar distance formula between the origin and a point.

Examples:

  • For $v = (3, 4)$:
    $$ |v| = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = 5. $$

  • For $w = (1, -2, 2)$:
    $$ |w| = \sqrt{1^2 + (-2)^2 + 2^2} = \sqrt{1 + 4 + 4} = \sqrt{9} = 3. $$

Unit Vectors

A unit vector is a vector whose length is exactly 1.
These are important because they capture direction without scaling.
To create a unit vector from any nonzero vector, divide by its norm:

$$ u = \frac{v}{|v|}. $$

Example:
For $v = (3, 4)$, the unit vector is

$$ u = \left(\tfrac{3}{5}, \tfrac{4}{5}\right). $$

This points in the same direction as $(3, 4)$ but has length 1.

Unit vectors are like pure directions.
They're especially useful for projections, defining coordinate systems, and normalizing data.

Distance Between Vectors

The distance between two vectors $u$ and $v$ is defined as the length of their difference:

$$ \text{dist}(u, v) = |u - v|. $$

Example:
Let $u = (2, 1)$ and $v = (5, 5)$. Then

$$ u - v = (-3, -4). $$

Its norm is

$$ \sqrt{(-3)^2 + (-4)^2} = \sqrt{9 + 16} = 5. $$

So the distance is 5. This matches our intuition: the straight-line distance between points $(2, 1)$ and $(5, 5)$.

Geometric Interpretation

  • The norm tells you how far a point is from the origin.
  • The distance tells you how far two points are from each other.

Both are computed with the same formula-the square root of sums of squares-but applied in slightly different contexts.

Different Kinds of Norms

The formula above defines the Euclidean norm (or $\ell_2$ norm), the most common one.
But in linear algebra, other norms are also useful:

  • $\ell_1$ norm:
    $$ |v|_1 = |v_1| + |v_2| + \cdots + |v_n| $$
    (sum of absolute values).

  • $\ell_\infty$ norm:
    $$ |v|_\infty = \max(|v_1|, |v_2|, \ldots, |v_n|) $$
    (largest component).

These norms change the geometry of "length" and "distance." For example, in the ℓ₁ norm, the unit circle is shaped like a diamond; in the ℓ∞ norm, it looks like a square.

Everyday Analogies

  • Walking distance in a city: If streets are on a grid, the ℓ₁ norm (sum of absolute differences) is more natural than the Euclidean norm.
  • Climbing stairs: The Euclidean norm is like measuring the diagonal distance, but step by step you may actually walk an ℓ₁ distance.
  • Measuring error in data: Different norms capture different notions of "closeness" between predictions and reality. Euclidean distance punishes large errors heavily; ℓ₁ treats all errors equally.

Algebraic Properties

Norms and distances satisfy critical properties that make them consistent measures:

  • Non-negativity: $|v| \geq 0$, and $|v| = 0$ only if $v = 0$.
  • Homogeneity: $|c \cdot v| = |c| , |v|$ (scaling affects length predictably).
  • Triangle inequality: $|u + v| \leq |u| + |v|$ (the direct path is shortest).
  • Symmetry (for distance): $\text{dist}(u, v) = \text{dist}(v, u)$.

These properties are why norms and distances are robust tools across mathematics.

Why It Matters

Understanding length and distance is the first step toward geometry in higher dimensions. These notions:

  • Allow us to compare vectors quantitatively.
  • Form the basis of concepts like angles, orthogonality, and projections.
  • Underpin optimization problems (e.g., "find the closest vector" is central to machine learning).
  • Define the geometry of spaces, which changes dramatically depending on which norm you use.

Try It Yourself

  1. Compute the norm of (6, 8). Then divide by the norm to find its unit vector.
  2. Find the distance between (1, 1, 1) and (4, 5, 6).
  3. Compare the Euclidean and Manhattan (ℓ₁) distances between (0, 0) and (3, 4). Which one matches your intuition if you were walking along a city grid?
  4. Challenge: For vectors u = (2, –1, 3) and v = (–2, 0, 1), compute ‖u – v‖. Then explain what this distance means geometrically.

By working through these examples, you'll see how norms and distances make abstract vectors feel as real as points and arrows you can measure in everyday life.

6. Dot Product (Algebraic and Geometric Views)

The dot product is one of the most fundamental operations in linear algebra. It looks like a simple formula, but it unlocks the ability to measure angles, detect orthogonality, project one vector onto another, and compute energy or work in physics. Understanding it requires seeing both the algebraic view (a formula on components) and the geometric view (a way to compare directions).

Algebraic Definition

For two vectors of the same dimension, $u = (u_1, u_2, \ldots, u_n)$ and $v = (v_1, v_2, \ldots, v_n)$, the dot product is defined as:

$$ u \cdot v = u_1 v_1 + u_2 v_2 + \cdots + u_n v_n. $$

This is simply multiplying corresponding components and summing the results.

Examples:

  • $(2, 3) \cdot (4, 5) = (2 \times 4) + (3 \times 5) = 8 + 15 = 23$
  • $(1, -2, 3) \cdot (0, 4, -1) = (1 \times 0) + (-2 \times 4) + (3 \times -1) = 0 - 8 - 3 = -11$

Notice that the dot product is always a scalar, not a vector.

Geometric Definition

The dot product can also be defined in terms of vector length and angle:

$$ u \cdot v = |u| , |v| \cos(\theta), $$

where $\theta$ is the angle between $u$ and $v$ ($0^\circ \leq \theta \leq 180^\circ$).

This formula tells us:

  • If the angle is acute (less than $90^\circ$), $\cos(\theta) > 0$, so the dot product is positive.
  • If the angle is right (exactly $90^\circ$), $\cos(\theta) = 0$, so the dot product is 0.
  • If the angle is obtuse (greater than $90^\circ$), $\cos(\theta) < 0$, so the dot product is negative.

Thus, the sign of the dot product encodes directional alignment.

Connecting the Two Definitions

At first glance, the algebraic sum of products and the geometric length–angle formula seem unrelated. But they are equivalent. To see why, consider the law of cosines applied to a triangle formed by u, v, and u – v. Expanding both sides leads directly to the equivalence between the two formulas. This dual interpretation is what makes the dot product so powerful: it is both a computation rule and a geometric measurement.

Orthogonality

Two vectors are orthogonal (perpendicular) if and only if their dot product is zero:

$$ u \cdot v = 0 ;;\Longleftrightarrow;; \theta = 90^\circ. $$

This gives us an algebraic way to check for perpendicularity without drawing diagrams.

Example:
$(2, 1) \cdot (-1, 2) = (2 \times -1) + (1 \times 2) = -2 + 2 = 0$,
so the vectors are orthogonal.

Projections

The dot product also provides a way to project one vector onto another.
The scalar projection of $u$ onto $v$ is:

$$ \text{proj}_{\text{scalar}}(u \text{ onto } v) = \frac{u \cdot v}{|v|}. $$

The vector projection is then:

$$ \text{proj}_{\text{vector}}(u \text{ onto } v) = \frac{u \cdot v}{|v|^2} , v. $$

This allows us to decompose vectors into "parallel" and "perpendicular" components, which is central in geometry, physics, and data analysis.

Examples

  1. Compute $u = (3, 4)$ and $v = (4, 3)$.

    • Dot product: $(3 \times 4) + (4 \times 3) = 12 + 12 = 24$.
    • Norms: $|u| = 5$, $|v| = 5$.
    • $\cos(\theta) = \tfrac{24}{5 \times 5} = \tfrac{24}{25} \approx 0.96$, so $\theta \approx 16^\circ$.
      These vectors are nearly parallel.
  2. Compute $u = (1, 2, -1)$ and $v = (2, -1, 1)$.

    • Dot product: $(1 \times 2) + (2 \times -1) + (-1 \times 1) = 2 - 2 - 1 = -1$.
    • Norms: $|u| = \sqrt{6}$, $|v| = \sqrt{6}$.
    • $\cos(\theta) = \tfrac{-1}{\sqrt{6} \times \sqrt{6}} = -\tfrac{1}{6}$, so $\theta \approx 99.6^\circ$.
      Slightly obtuse.

Physical Interpretation

In physics, the dot product computes work:

$$ \text{Work} = \text{Force} \cdot \text{Displacement} = |\text{Force}| , |\text{Displacement}| \cos(\theta). $$

Only the component of the force in the direction of motion contributes. If you push straight down on a box while trying to move it horizontally, the dot product is zero: no work is done in the direction of motion.

Everyday Analogies

  • Teamwork analogy: Two people pushing a car. If they push in nearly the same direction, the dot product is large and positive (strong cooperation). If they push at right angles, the dot product is zero (they don't help each other). If they push in opposite directions, the dot product is negative (they work against each other).
  • Conversation analogy: Think of two ideas. If they're aligned, the "dot product" of their meanings is high. If they're unrelated, it's zero. If they contradict, it's negative.

Algebraic Properties

  • Commutative: $u \cdot v = v \cdot u$
  • Distributive: $u \cdot (v + w) = u \cdot v + u \cdot w$
  • Scalar compatibility: $(c \cdot u) \cdot v = c ,(u \cdot v)$
  • Non-negativity: $v \cdot v = |v|^2 \geq 0$

These guarantee that the dot product behaves consistently and meshes with the structure of vector spaces.

Why It Matters

The dot product is the first bridge between algebra and geometry. It:

  • Defines angles and orthogonality in higher dimensions.
  • Powers projections and decompositions, which underlie least squares, regression, and data fitting.
  • Appears in physics as energy, power, and work.
  • Serves as the kernel of many machine learning methods (e.g., similarity measures in high-dimensional spaces).

Without the dot product, linear algebra would lack a way to connect numbers with geometry and meaning.

Try It Yourself

  1. Compute (2, –1) · (–3, 4). Then find the angle between them.
  2. Check if (1, 2, 3) and (2, 4, 6) are orthogonal. What does the dot product tell you?
  3. Find the projection of (3, 1) onto (1, 2). Draw the original vector, the projection, and the perpendicular component.
  4. In physics terms: Suppose a 10 N force is applied at 60° to the direction of motion, and the displacement is 5 m. How much work is done?

These exercises reveal the dual power of the dot product: as a formula to compute and as a geometric tool to interpret.

7. Angles Between Vectors and Cosine

Having defined the dot product, we are now ready to measure angles between vectors. In everyday life, angles tell us how two lines or directions relate-whether they point the same way, are perpendicular, or are opposed. In linear algebra, the dot product and cosine function give us a precise, generalizable way to define angles in any dimension, not just in 2D or 3D. This section explores how we compute, interpret, and apply vector angles.

The Definition of an Angle Between Vectors

For two nonzero vectors $u$ and $v$, the angle $\theta$ between them is defined by:

$$ \cos(\theta) = \frac{u \cdot v}{|u| , |v|}. $$

This formula comes directly from the geometric definition of the dot product.
Rearranging gives:

$$ \theta = \arccos!\left(\frac{u \cdot v}{|u| , |v|}\right). $$

Key points:

  • $\theta$ is always between $0^\circ$ and $180^\circ$ (or $0$ and $\pi$ radians).
  • The denominator normalizes the dot product by dividing by the product of lengths, so the result is dimensionless and always between $-1$ and $1$.
  • The cosine value directly encodes alignment: positive, zero, or negative.

Interpretation of Cosine Values

The cosine tells us about the directional relationship:

  • $\cos(\theta) = 1 ;;\Rightarrow;; \theta = 0^\circ$ → vectors point in exactly the same direction.
  • $\cos(\theta) = 0 ;;\Rightarrow;; \theta = 90^\circ$ → vectors are orthogonal (perpendicular).
  • $\cos(\theta) = -1 ;;\Rightarrow;; \theta = 180^\circ$ → vectors point in exactly opposite directions.
  • $\cos(\theta) > 0$ → acute angle → vectors point more “together” than apart.
  • $\cos(\theta) < 0$ → obtuse angle → vectors point more “against” each other.

Thus, the cosine compresses geometric alignment into a single number.

Examples

  1. $u = (1, 0), ; v = (0, 1)$

    • Dot product: $1 \times 0 + 0 \times 1 = 0$
    • Norms: $1$ and $1$
    • $\cos(\theta) = 0 ;\Rightarrow; \theta = 90^\circ$
      The vectors are perpendicular, as expected.
  2. $u = (2, 3), ; v = (4, 6)$

    • Dot product: $(2 \times 4) + (3 \times 6) = 8 + 18 = 26$
    • Norms: $\sqrt{2^2 + 3^2} = \sqrt{13}$, and $\sqrt{4^2 + 6^2} = \sqrt{52} = 2\sqrt{13}$
    • $\cos(\theta) = \tfrac{26}{\sqrt{13} \cdot 2\sqrt{13}} = \tfrac{26}{26} = 1$
    • $\theta = 0^\circ$
      These vectors are multiples, so they align perfectly.
  3. $u = (1, 1), ; v = (-1, 1)$

    • Dot product: $(1 \times -1) + (1 \times 1) = -1 + 1 = 0$
    • $\cos(\theta) = 0 ;\Rightarrow; \theta = 90^\circ$
      The vectors are perpendicular, forming diagonals of a square.

Angles in Higher Dimensions

The beauty of the formula is that it works in any dimension.
Even in $\mathbb{R}^{100}$ or higher, we can define the angle between two vectors using only their dot product and norms.

While we cannot visualize the geometry directly in high dimensions, the cosine formula still captures how aligned two directions are:

$$ \cos(\theta) = \frac{u \cdot v}{|u| , |v|}. $$

This is critical in machine learning, where data often lives in very high-dimensional spaces.

Cosine Similarity

The cosine of the angle between two vectors is often called cosine similarity. It is widely used in data analysis and machine learning to measure how similar two data vectors are, independent of their magnitude.

  • In text mining, documents are turned into word-frequency vectors. Cosine similarity measures how "close in topic" two documents are, regardless of length.
  • In recommendation systems, cosine similarity compares user preference vectors to suggest similar users or items.

This demonstrates how a geometric concept extends far beyond pure math.

Orthogonality Revisited

The angle formula reinforces the special role of orthogonality.
If $\cos(\theta) = 0$, then $u \cdot v = 0$.

This means the dot product not only computes length but also serves as a direct test for perpendicularity.
This algebraic shortcut is far easier than manually checking geometric right angles.

Angles and Projections

Angles are closely tied to projections.
The length of the projection of $u$ onto $v$ is $|u|\cos(\theta)$.

If the angle is small, the projection is large — most of $u$ lies in the direction of $v$.
If the angle is close to $90^\circ$, the projection shrinks toward zero.

Thus, the cosine acts as a scaling factor between directions.

Everyday Analogies

  • Teamwork analogy: If two people push a heavy object, the effectiveness of their combined effort depends on the angle.
    If they push in nearly the same direction (small $\theta$), they cooperate efficiently.
    If they push at right angles ($\theta = 90^\circ$), they waste effort.
    If they push opposite each other ($\theta \approx 180^\circ$), they cancel out.

  • Conversation analogy: If two people's opinions align ($\cos \theta \approx 1$), they agree strongly.
    If they are orthogonal ($\cos \theta = 0$), they are unrelated.
    If they oppose each other ($\cos \theta \approx -1$), they fundamentally disagree.

  • Navigation analogy: If two roads meet at a small angle, their directions are similar.
    If they cross perpendicularly, their directions are independent.

Why It Matters

Angles between vectors provide:

  • A way to generalize geometry beyond 2D/3D.
  • A measure of similarity in high-dimensional data.
  • The foundation for orthogonality, projections, and decomposition of spaces.
  • A tool for optimization: in gradient descent, for example, the angle between the gradient and step direction determines how effectively we reduce error.

Without the ability to measure angles, we could not connect algebraic manipulations with geometric intuition or practical applications.

Try It Yourself

  1. Compute the angle between (2, 1) and (1, –1). Interpret the result.
  2. Find two vectors in 3D that form a 60° angle. Verify using the cosine formula.
  3. Consider word vectors for "cat" and "dog" in a machine learning model. Why might cosine similarity be a better measure of similarity than Euclidean distance?
  4. Challenge: In $\mathbb{R}^3$, find a vector orthogonal to both (1, 2, 3) and (3, 2, 1). What angle does it make with each of them?

By experimenting with these problems, you will see how angles provide the missing link between algebraic formulas and geometric meaning in linear algebra.

8. Projections and Decompositions

In earlier sections, we saw how the dot product measures alignment and how the cosine formula gives us angles between vectors. The next natural step is to use these tools to project one vector onto another. Projection is a way to "shadow" one vector onto the direction of another, splitting vectors into meaningful parts: one along a given direction and one perpendicular to it. This is the essence of decomposition, and it is everywhere in linear algebra, geometry, physics, and data science.

Scalar Projection

The scalar projection of a vector $u$ onto a vector $v$ measures how much of $u$ lies in the direction of $v$. It is given by:

$$ \text{proj}_{\text{scalar}}(u \text{ onto } v) = \frac{u \cdot v}{|v|}. $$

  • If this value is positive, $u$ has a component pointing in the same direction as $v$.
  • If it is negative, $u$ points partly in the opposite direction.
  • If it is zero, $u$ is completely perpendicular to $v$.

Example:
$u = (3, 4)$, $v = (1, 0)$.
Dot product: $(3 \times 1 + 4 \times 0) = 3$.
$|v| = 1$.
So the scalar projection is $3$. This tells us $u$ has a "shadow" of length $3$ on the $x$-axis.

Vector Projection

The vector projection gives the actual arrow in the direction of $v$ that corresponds to this scalar amount:

$$ \text{proj}_{\text{vector}}(u \text{ onto } v) = \frac{u \cdot v}{|v|^2} , v. $$

This formula normalizes $v$ into a unit vector, then scales it by the scalar projection.
The result is a new vector lying along $v$, capturing exactly the "parallel" part of $u$.

Example:
$u = (3, 4)$, $v = (1, 2)$

  • Dot product: $3 \times 1 + 4 \times 2 = 3 + 8 = 11$
  • Norm squared of $v$: $(1^2 + 2^2) = 5$
  • Coefficient: $11 / 5 = 2.2$
  • Projection vector: $2.2 \cdot (1, 2) = (2.2, 4.4)$

So the part of $(3, 4)$ in the direction of $(1, 2)$ is $(2.2, 4.4)$.

Perpendicular Component

Once we have the projection, we can find the perpendicular component (often called the rejection) simply by subtracting:

$$ u_{\perp} = u - \text{proj}_{\text{vector}}(u \text{ onto } v). $$

This gives the part of $u$ that is entirely orthogonal to $v$.

Example continued:
$u_{\perp} = (3, 4) - (2.2, 4.4) = (0.8, -0.4)$

Check:
$(0.8, -0.4) \cdot (1, 2) = 0.8 \times 1 + (-0.4) \times 2 = 0.8 - 0.8 = 0$.
Indeed, orthogonal.

Geometric Picture

Projection is like dropping a perpendicular from one vector onto another. Imagine shining a light perpendicular to v: the shadow of u on the line spanned by v is the projection. This visualization explains why projections split vectors naturally into two pieces:

  • Parallel part: Along the line of v.
  • Perpendicular part: Orthogonal to v, forming a right angle.

Together, these two parts reconstruct the original vector exactly.

Decomposition of Vectors

Every vector $u$ can be decomposed relative to another vector $v$ into two parts:

$$ u = \text{proj}{\text{vector}}(u \text{ onto } v) + \big(u - \text{proj}{\text{vector}}(u \text{ onto } v)\big). $$

This decomposition is unique and geometrically meaningful.
It generalizes to subspaces: we can project onto entire planes or higher-dimensional spans, splitting a vector into a "within-subspace" part and a "perpendicular-to-subspace" part.

Applications

  1. Physics (Work and Forces): Work is the projection of force onto displacement. Only the part of the force in the direction of motion contributes. Example: Pushing on a sled partly sideways wastes effort-the sideways component projects to zero.

  2. Geometry and Engineering: Projections are used in CAD (computer-aided design) to flatten 3D objects onto 2D surfaces, like blueprints or shadows.

  3. Computer Graphics: Rendering 3D scenes onto a 2D screen is fundamentally a projection process.

  4. Data Science: Projecting high-dimensional data onto a lower-dimensional subspace (like the first two principal components in PCA) makes patterns visible while preserving as much information as possible.

  5. Signal Processing: Decomposition into projections onto sine and cosine waves forms the basis of Fourier analysis, which powers audio, image, and video compression.

Everyday Analogies

  • Flashlight shadow: Imagine shining a flashlight so that a stick casts a shadow on the floor. The shadow is the projection of the stick onto the floor plane.
  • Team effort: If two people pull a box, the effective progress in one person's direction is the projection of the other's pull onto that direction.
  • Grades analogy: If your performance is a mix of effort and distraction, the projection onto "effort" shows how much of your work aligns with real progress.

Algebraic Properties

  • Projections are linear: proj(u + w) = proj(u) + proj(w).
  • The perpendicular part is always orthogonal to the direction of projection.
  • The decomposition is unique: no other pair of parallel and perpendicular vectors will reconstruct u.
  • The projection operator onto a unit vector v̂ satisfies: proj(u) = (v̂ v̂ᵀ)u, showing how projection can be expressed in matrix form.

Why It Matters

Projection is not just a geometric trick; it is the core of many advanced topics:

  • Least squares regression is finding the projection of a data vector onto the span of predictor vectors.
  • Orthogonal decompositions like Gram–Schmidt and QR factorization rely on projections to build orthogonal bases.
  • Optimization methods often involve projecting guesses back onto feasible sets.
  • Machine learning uses projections constantly to reduce dimensions, compare vectors, and align features.

Without projection, we could not cleanly separate influence along directions or reduce complexity in structured ways.

Try It Yourself

  1. Project (2, 3) onto (1, 0). What does the perpendicular component look like?
  2. Project (3, 1) onto (2, 2). Verify the perpendicular part is orthogonal.
  3. Decompose (5, 5, 0) into parallel and perpendicular parts relative to (1, 0, 0).
  4. Challenge: Write the projection matrix for projecting onto (1, 2). Apply it to (3, 4). Does it match the formula?

Through these exercises, you will see that projection is more than an operation-it is a lens through which we decompose, interpret, and simplify vectors and spaces.

9. Cauchy–Schwarz and Triangle Inequalities

Linear algebra is not only about operations with vectors-it also involves understanding the fundamental relationships between them. Two of the most important results in this regard are the Cauchy–Schwarz inequality and the triangle inequality. These are cornerstones of vector spaces because they establish precise boundaries for lengths, angles, and inner products. Without them, the geometry of linear algebra would fall apart.

The Cauchy–Schwarz Inequality

For any two vectors $u$ and $v$ in $\mathbb{R}^n$, the Cauchy–Schwarz inequality states:

$$ |u \cdot v| \leq |u| , |v|. $$

This means that the absolute value of the dot product of two vectors is always less than or equal to the product of their lengths.

Equality holds if and only if u and v are linearly dependent (i.e., one is a scalar multiple of the other).

Why It Is True

Recall the geometric formula for the dot product:

$$ u \cdot v = |u| , |v| \cos(\theta). $$

Since $-1 \leq \cos(\theta) \leq 1$, the magnitude of the dot product cannot exceed $|u| , |v|$.
This is exactly the inequality.

Example

Let $u = (3, 4)$ and $v = (-4, 3)$.

  • Dot product: $(3 \times -4) + (4 \times 3) = -12 + 12 = 0$
  • Norms: $|u| = 5$, $|v| = 5$
  • Product of norms: $25$
  • $|u \cdot v| = 0 \leq 25$, which satisfies the inequality

Equality does not hold since they are not multiples - they are perpendicular.

Intuition

The inequality tells us that two vectors can never "overlap" more strongly than the product of their magnitudes. If they align perfectly, the overlap is maximum (equality). If they're perpendicular, the overlap is zero.

Think of it as: "the shadow of one vector on another can never be longer than the vector itself."

The Triangle Inequality

For any vectors $u$ and $v$, the triangle inequality states:

$$ |u + v| \leq |u| + |v|. $$

This mirrors the geometric fact that in a triangle, any side is at most as long as the sum of the other two sides.

Example

Let $u = (1, 2)$ and $v = (3, 4)$.

  • $|u + v| = |(4, 6)| = \sqrt{16 + 36} = \sqrt{52} \approx 7.21$
  • $|u| + |v| = \sqrt{5} + 5 \approx 2.24 + 5 = 7.24$

Indeed, $7.21 \leq 7.24$, very close in this case.

Equality Case

The triangle inequality becomes equality when the vectors point in exactly the same direction (or are scalar multiples with nonnegative coefficients). For example, (1, 1) and (2, 2) produce equality because adding them gives a vector whose length equals the sum of their lengths.

Everyday Analogies

  • Cauchy–Schwarz: Imagine comparing two people's study habits across multiple subjects. Each vector represents hours spent in each subject. The dot product represents how much their habits "align." Cauchy–Schwarz says the alignment can never exceed the product of their individual efforts.
  • Triangle inequality: Think of walking in a city. If you want to get from home to the store and then from the store to the park, the total distance is at least as long as going straight from home to the park. There is no shortcut longer than the direct route.

Extensions

  • These inequalities hold in all inner product spaces, not just ℝⁿ. This means they apply to functions, sequences, and more abstract mathematical objects.
  • In Hilbert spaces (infinite-dimensional generalizations), they remain just as essential.

Why They Matter

  1. They guarantee that the dot product and norm are well-behaved and geometrically meaningful.
  2. They ensure that the norm satisfies the requirements of a distance measure: nonnegativity, symmetry, and triangle inequality.
  3. They underpin the validity of projections, orthogonality, and least squares methods.
  4. They are essential in proving convergence of algorithms, error bounds, and stability in numerical linear algebra.

Without these inequalities, we could not trust that the geometry of vector spaces behaves consistently.

Try It Yourself

  1. Verify Cauchy–Schwarz for (2, –1, 3) and (–1, 4, 0). Compute both sides.
  2. Try the triangle inequality for (–3, 4) and (5, –12). Does equality hold?
  3. Find two vectors where Cauchy–Schwarz is an equality. Explain why.
  4. Challenge: Prove the triangle inequality in $\mathbb{R}^2$ using only the Pythagorean theorem and algebra, without relying on dot products.

Working through these problems will show you why these inequalities are not abstract curiosities but the structural glue of linear algebra's geometry.

10. Orthonormal sets in $\mathbb{R}^2$ and $\mathbb{R}^3$

Up to now, we've discussed vectors, their lengths, angles, and how to project one onto another. A natural culmination of these ideas is the concept of orthonormal sets. These are collections of vectors that are not only orthogonal (mutually perpendicular) but also normalized (each of length 1). Orthonormal sets form the cleanest, most efficient coordinate systems in linear algebra. They are the mathematical equivalent of having rulers at right angles, perfectly calibrated to unit length.

Orthogonal and Normalized

Let's break the term "orthonormal" into two parts:

  • Orthogonal: Two vectors $u$ and $v$ are orthogonal if $u \cdot v = 0$.
    In $\mathbb{R}^2$, this means the vectors meet at a right angle.
    In $\mathbb{R}^3$, it means they form perpendicular directions.

  • Normalized: A vector $v$ is normalized if its length is $1$, i.e., $|v| = 1$.
    Such vectors are called unit vectors.

When we combine both conditions, we get orthonormal vectors: vectors that are both perpendicular to each other and have unit length.

Orthonormal Sets in $\mathbb{R}^2$

In two dimensions, an orthonormal set typically consists of two vectors.
A classic example is:

$e_1 = (1, 0), \quad e_2 = (0, 1)$

  • Dot product: $e_1 \cdot e_2 = (1 \times 0 + 0 \times 1) = 0 ;;\Rightarrow;;$ orthogonal
  • Lengths: $|e_1| = 1$, $|e_2| = 1 ;;\Rightarrow;;$ normalized

Thus, ${e_1, e_2}$ is an orthonormal set.
In fact, this is the standard basis for $\mathbb{R}^2$.
Any vector $(x, y)$ can be written as $x e_1 + y e_2$.
This is the simplest coordinate system.

Orthonormal Sets in $\mathbb{R}^3$

In three dimensions, an orthonormal set usually has three vectors.
The standard basis is:

$e_1 = (1, 0, 0), \quad e_2 = (0, 1, 0), \quad e_3 = (0, 0, 1)$

  • Each pair has dot product zero, so they are orthogonal
  • Each has length $1$, so they are normalized
  • Together, they span all of $\mathbb{R}^3$

Geometrically, they correspond to the $x$-, $y$-, and $z$-axes in 3D space.
Any vector $(x, y, z)$ can be written as a linear combination $x e_1 + y e_2 + z e_3$.

Beyond the Standard Basis

The standard basis is not the only orthonormal set. For example:

$u = \left(\tfrac{1}{\sqrt{2}}, \tfrac{1}{\sqrt{2}}\right), \quad v = \left(-\tfrac{1}{\sqrt{2}}, \tfrac{1}{\sqrt{2}}\right)$

  • Dot product: $(\tfrac{1}{\sqrt{2}})(-\tfrac{1}{\sqrt{2}}) + (\tfrac{1}{\sqrt{2}})(\tfrac{1}{\sqrt{2}}) = -\tfrac{1}{2} + \tfrac{1}{2} = 0$
  • Lengths: $\sqrt{(\tfrac{1}{\sqrt{2}})^2 + (\tfrac{1}{\sqrt{2}})^2} = \sqrt{\tfrac{1}{2} + \tfrac{1}{2}} = 1$

So ${u, v}$ is also orthonormal in $\mathbb{R}^2$.
These vectors are rotated $45^\circ$ relative to the standard axes.

Similarly, in $\mathbb{R}^3$, you can construct rotated orthonormal sets (such as unit vectors along diagonals), as long as the conditions of perpendicularity and unit length hold.

Properties of Orthonormal Sets

  1. Simplified coordinates: If ${v_1, \ldots, v_k}$ is an orthonormal set, then for any vector $u$ in their span, the coefficients are easy to compute:
    $$ c_i = u \cdot v_i $$
    This is much simpler than solving systems of equations.

  2. Pythagorean theorem generalized: If vectors are orthonormal, the squared length of their sum is the sum of the squares of their coefficients.
    For example, if $u = a v_1 + b v_2$, then
    $$ |u|^2 = a^2 + b^2 $$

  3. Projection is easy: Projecting onto an orthonormal set is straightforward — just take dot products.

  4. Matrices become nice: When vectors form the columns of a matrix, orthonormality makes that matrix an orthogonal matrix, which has special properties: its transpose equals its inverse, and it preserves lengths and angles.

Importance in $\mathbb{R}^2$ and $\mathbb{R}^3$

  • In geometry, orthonormal bases correspond to coordinate axes.
  • In physics, they represent independent directions of motion or force.
  • In computer graphics, orthonormal sets define camera axes and object rotations.
  • In engineering, they simplify stress, strain, and rotation analysis.

Even though $\mathbb{R}^2$ and $\mathbb{R}^3$ are relatively simple, the same ideas extend naturally to higher dimensions, where visualization is impossible but the algebra is identical.

Everyday Analogies

  • Navigating a city: Imagine two perpendicular streets, each marked in meters. Walking 3 units east and 4 units north gives coordinates (3, 4). That's an orthonormal system.
  • Furniture assembly: When you're told to align one part "straight up" and another "straight across," you're working with orthonormal directions.
  • Digital screens: Computer monitors use pixel grids aligned horizontally and vertically, a practical realization of orthonormality.

Why Orthonormal Sets Matter

Orthonormality is the gold standard for building bases in linear algebra:

  • It makes calculations fast and simple.
  • It ensures numerical stability in computations (important in algorithms and simulations).
  • It underpins key decompositions like QR factorization, singular value decomposition (SVD), and spectral theorems.
  • It provides the cleanest way to think about space: orthogonal, independent directions scaled to unit length.

Whenever possible, mathematicians and engineers prefer orthonormal bases over arbitrary ones.

Try It Yourself

  1. Verify that (3/5, 4/5) and (–4/5, 3/5) form an orthonormal set in $\mathbb{R}^2$.
  2. Construct three orthonormal vectors in $\mathbb{R}^3$ that are not the standard basis. Hint: start with (1/√2, 1/√2, 0) and build perpendiculars.
  3. For u = (2, 1), compute its coordinates relative to the orthonormal set {(1/√2, 1/√2), (–1/√2, 1/√2)}.
  4. Challenge: Prove that if {v₁, …, vₖ} is orthonormal, then the matrix with these as columns is orthogonal, i.e., QᵀQ = I.

Through these exercises, you will see how orthonormal sets make every aspect of linear algebra-from projections to decompositions-simpler, cleaner, and more powerful.

Closing

Lengths, angles revealed,
projections trace hidden lines,
clarity takes shape.

Chapter 2. Matrices and basic operations

Opening

Rows and columns meet,
woven grids of silent rules,
machines of order.

11. Matrices as Tables and as Machines

The next stage in our journey is to move from vectors to matrices. A matrix may look like just a rectangular array of numbers, but in linear algebra it plays two distinct and equally important roles:

  1. As a table of numbers, storing data, coefficients, or geometric patterns in a compact form.
  2. As a machine that transforms vectors into other vectors, capturing the essence of linear transformations.

Both views are valid, and learning to switch between them is crucial to building intuition.

Matrices as Tables

At the most basic level, a matrix is a grid of numbers arranged into rows and columns.

  • A $2 \times 2$ matrix has 2 rows and 2 columns:

    $$ A = \begin{bmatrix} a_{11} & a_{12} \ a_{21} & a_{22} \end{bmatrix} $$

  • A $3 \times 2$ matrix has 3 rows and 2 columns:

    $$ B = \begin{bmatrix} b_{11} & b_{12} \ b_{21} & b_{22} \ b_{31} & b_{32} \end{bmatrix} $$

Each entry $a_{ij}$ or $b_{ij}$ tells us the number in the i-th row and j-th column. The rows of a matrix can represent constraints, equations, or observations; the columns can represent features, variables, or directions.

In this sense, matrices are data containers, organizing information efficiently. That's why matrices show up in spreadsheets, statistics, computer graphics, and scientific computing.

Matrices as Machines

The deeper view of a matrix is as a function from vectors to vectors. If x is a column vector, then multiplying A·x produces a new vector.

For example:

$$ A = \begin{bmatrix} 2 & 0 \ 1 & 3 \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} 4 \ 5 \end{bmatrix}. $$

Multiplying:

$$ A\mathbf{x} = \begin{bmatrix} 2×4 + 0×5 \ 1×4 + 3×5 \end{bmatrix} = \begin{bmatrix} 8 \ 19 \end{bmatrix}. $$

Here, the matrix is acting as a machine that takes input (4, 5) and outputs (8, 19). The "machine rules" are encoded in the rows of A.

Column View of Matrix Multiplication

Another way to see it: multiplying A·x is the same as taking a linear combination of A's columns.

If

$$ A = \begin{bmatrix} a_1 & a_2 \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} x_1 \ x_2 \end{bmatrix}, $$

then:

$$ A\mathbf{x} = x_1 a_1 + x_2 a_2. $$

So the vector x tells the machine "how much" of each column to mix together. This column view is critical-it connects matrices to span, dimension, and basis ideas we saw earlier.

The Duality of Tables and Machines

  • As a table, a matrix is a static object: numbers written in rows and columns.
  • As a machine, the same numbers become instructions for transforming vectors.

This duality is not just conceptual-it's the key to understanding why linear algebra is so powerful. A dataset, once stored as a table, can be interpreted as a transformation. Likewise, a transformation, once understood, can be encoded as a table.

Examples in Practice

  1. Physics: A stress–strain matrix is a table of coefficients. But it also acts as a machine that transforms applied forces into deformations.
  2. Computer Graphics: A 2D rotation matrix is a machine that spins vectors, but it can be stored in a simple 2×2 table.
  3. Economics: Input–output models use matrices as tables of production coefficients. Applying them to demand vectors transforms them into resource requirements.

Geometric Intuition

Every 2×2 or 3×3 matrix corresponds to some linear transformation in the plane or space. Examples:

  • Scaling: $\begin{bmatrix} 2 & 0 \ 0 & 2 \end{bmatrix}$ doubles lengths.
  • Reflection: $\begin{bmatrix} 1 & 0 \ 0 & -1 \end{bmatrix}$ flips across the x-axis.
  • Rotation: $\begin{bmatrix} \cos θ & -\sin θ \ \sin θ & \cos θ \end{bmatrix}$ rotates vectors by θ.

These are not just tables of numbers-they are precise, reusable machines.

Why This Matters

This section sets the stage for all matrix theory:

  • Thinking of matrices as tables helps in data interpretation and organization.
  • Thinking of matrices as machines helps in understanding linear transformations, eigenvalues, and decompositions.
  • Most importantly, learning to switch between the two perspectives makes linear algebra both concrete and abstract-bridging computation with geometry.

Try It Yourself

  1. Write a 2×3 matrix and identify its rows and columns. What might they represent in a real-world dataset?
  2. Multiply $\begin{bmatrix} 1 & 2 \ 3 & 4 \end{bmatrix}$ by $\begin{bmatrix} 2 \ –1 \end{bmatrix}$. Interpret the result using both the row and column views.
  3. Construct a matrix that scales vectors by 2 along the x-axis and reflects them across the y-axis. Test it on (1, 1).
  4. Challenge: Show how the same 3×3 rotation matrix can be viewed as a data table of cosines/sines and as a machine that turns input vectors.

By mastering both perspectives, you'll see matrices not just as numbers but as dynamic objects that encode and execute transformations.

12. Matrix Shapes, Indexing, and Block Views

Matrices come in many shapes and sizes, and the way we label their entries matters. This section is about learning how to read and write matrices carefully, how to work with rows and columns, and how to use block structure to simplify problems. These seemingly simple ideas are what allow us to manipulate large systems with precision and efficiency.

Shapes of Matrices

The shape of a matrix is given by its number of rows and columns:

  • A m×n matrix has m rows and n columns.
  • Rows run horizontally, columns run vertically.
  • Square matrices have m = n; rectangular matrices have m ≠ n.

Examples:

  • A 2×3 matrix:

    $$ \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix} $$

  • A 3×2 matrix:

    $$ \begin{bmatrix} 7 & 8 \ 9 & 10 \ 11 & 12 \end{bmatrix} $$

Shape matters because it determines whether certain operations (like multiplication) are possible.

Indexing: The Language of Entries

Each entry in a matrix has two indices: one for its row, one for its column.

  • $a_{ij}$ = entry in row i, column j.
  • The first index always refers to the row, the second to the column.

For example, in

$$ A = \begin{bmatrix} 1 & 4 & 7 \ 2 & 5 & 8 \ 3 & 6 & 9 \end{bmatrix}, $$

we have:

  • $a_{11} = 1$, $a_{23} = 8$, $a_{32} = 6$.

Indexing is the grammar of matrix language. Without it, we can't specify positions or write formulas clearly.

Rows and Columns as Vectors

Every row and every column of a matrix is itself a vector.

  • The i-th row is written as $A_{i,*}$.
  • The j-th column is written as $A_{*,j}$.

Example: From the matrix above,

  • First row: (1, 4, 7).
  • Second column: (4, 5, 6).

This duality is powerful: rows often represent constraints or equations, while columns represent directions or features. Later, when we interpret matrix–vector products, we'll see that multiplying A·x means combining columns, while multiplying yᵀ·A means combining rows.

Submatrices

Sometimes we want just part of a matrix. A submatrix is formed by selecting certain rows and columns.

Example: From

$$ B = \begin{bmatrix} 2 & 4 & 6 \ 1 & 3 & 5 \ 7 & 8 & 9 \end{bmatrix}, $$

the submatrix of the first two rows and last two columns is:

$$ \begin{bmatrix} 4 & 6 \ 3 & 5 \end{bmatrix}. $$

Submatrices allow us to zoom in and isolate parts of a problem.

Block Matrices: Dividing to Conquer

Large matrices can often be broken into blocks, which are smaller submatrices arranged inside. This is like dividing a spreadsheet into quadrants.

For example:

$$ C = \begin{bmatrix} A_{11} & A_{12} \ A_{21} & A_{22} \end{bmatrix}, $$

where each $A_{ij}$ is itself a smaller matrix.

This structure is useful in:

  • Computation: Algorithms often process blocks instead of individual entries.
  • Theory: Many proofs and factorizations rely on viewing a matrix in blocks (e.g., LU, QR, Schur decomposition).
  • Applications: Partitioning data tables into logical sections.

Example: Splitting a 4×4 matrix into four 2×2 blocks helps us treat it as a "matrix of matrices."

Special Shapes

Some shapes of matrices are so common they deserve names:

  • Row vector: 1×n matrix.
  • Column vector: n×1 matrix.
  • Diagonal matrix: Nonzero entries only on the diagonal.
  • Identity matrix: Square diagonal matrix with 1's on the diagonal.
  • Zero matrix: All entries are 0.

Recognizing these shapes saves time and clarifies reasoning.

Everyday Analogies

  • Spreadsheets: A matrix is like a grid of cells, each with a row and column label. Indexing lets you specify exactly which cell you mean.
  • Maps: Cities on a map can be located by coordinates (row, column). The same logic applies to entries in a matrix.
  • Lego blocks: Just as large Lego structures are built from smaller blocks, large matrices are often analyzed by splitting into submatrices.

Why It Matters

Careful attention to matrix shapes, indexing, and block views ensures:

  1. Precision: We can describe positions unambiguously.
  2. Structure awareness: Recognizing patterns (diagonal, triangular, block) leads to more efficient computations.
  3. Scalability: Block partitioning is the foundation of modern numerical linear algebra libraries, where matrices are too large to handle entry by entry.
  4. Geometry: Rows and columns as vectors connect matrix structure to span, basis, and dimension.

These basic tools prepare us for multiplication, transformations, and factorization.

Try It Yourself

  1. Write a 3×4 matrix and label the entry in row 2, column 3.

  2. Extract a 2×2 submatrix from the corners of a 4×4 matrix of your choice.

  3. Break a 6×6 matrix into four 3×3 blocks. How would you represent it compactly?

  4. Challenge: Given

    $$ D = \begin{bmatrix} 1 & 2 & 3 & 4 \ 5 & 6 & 7 & 8 \ 9 & 10 & 11 & 12 \end{bmatrix}, $$

    write it as a block matrix with a 2×2 block in the top-left, a 2×2 block in the top-right, and a 1×4 block in the bottom row.

By practicing with shapes, indexing, and blocks, you'll develop the ability to navigate matrices not just as raw grids of numbers but as structured objects ready for deeper algebraic and geometric insights.

13. Matrix Addition and Scalar Multiplication

Before exploring matrix–vector and matrix–matrix multiplication, it is essential to understand the simplest operations we can perform with matrices: addition and scalar multiplication. These operations extend the rules we learned for vectors, but now applied to entire grids of numbers. Although straightforward, they are the foundation for more complex algebraic manipulations and help establish the idea of matrices as elements of a vector space.

Matrix Addition: Entry by Entry

If two matrices $A$ and $B$ have the same shape (same number of rows and columns), we can add them by adding corresponding entries.

Formally: If

$$ A = [a_{ij}], \quad B = [b_{ij}], $$

then

$$ A + B = [a_{ij} + b_{ij}]. $$

Example:

$$ \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix} + \begin{bmatrix} 7 & 8 & 9 \ 10 & 11 & 12 \end{bmatrix}

\begin{bmatrix} 8 & 10 & 12 \ 14 & 16 & 18 \end{bmatrix}. $$

Key point: Addition is only defined if the matrices are the same shape. A 2×3 matrix cannot be added to a 3×2 matrix.

Scalar Multiplication: Scaling Every Entry

A scalar multiplies every entry of a matrix.

Formally: For scalar $c$ and matrix $A = [a_{ij}]$,

$$ cA = [c \cdot a_{ij}]. $$

Example:

$$ 3 \cdot \begin{bmatrix} 2 & -1 \ 0 & 4 \end{bmatrix}

\begin{bmatrix} 6 & -3 \ 0 & 12 \end{bmatrix}. $$

This mirrors vector scaling: stretching or shrinking the whole matrix by a constant factor.

Properties of Addition and Scalar Multiplication

These two operations satisfy familiar algebraic properties that make the set of all m×n matrices into a vector space:

  1. Commutativity: $A + B = B + A$.
  2. Associativity: $(A + B) + C = A + (B + C)$.
  3. Additive identity: $A + 0 = A$, where 0 is the zero matrix.
  4. Additive inverse: For every $A$, there exists $-A$ such that $A + (-A) = 0$.
  5. Distributivity: $c(A + B) = cA + cB$.
  6. Compatibility: $(c + d)A = cA + dA$.
  7. Scalar associativity: $(cd)A = c(dA)$.
  8. Unit scalar: $1A = A$.

These guarantee that working with matrices feels like working with numbers and vectors, only in a higher-level setting.

Matrix Arithmetic as Table Operations

From the table view, addition and scalar multiplication are just simple bookkeeping: line up two tables of the same shape and add entry by entry; multiply the whole table by a constant.

Example: Imagine two spreadsheets of monthly expenses. Adding them gives combined totals. Multiplying by 12 converts a monthly table into a yearly estimate.

Matrix Arithmetic as Machine Operations

From the machine view, these operations adjust the behavior of linear transformations:

  • Adding matrices corresponds to adding their effects when applied to vectors.
  • Scaling a matrix scales the effect of the transformation.

Example: Let $A$ rotate vectors slightly, and $B$ stretch vectors. The matrix $A + B$ represents a transformation that applies both influences together. Scaling by 2 doubles the effect of the transformation.

Special Case: Zero and Identity

  • Zero matrix: All entries are 0. Adding it to any matrix changes nothing.
  • Scalar multiples of the identity: $cI$ scales every vector by c when applied. For example, $2I$ doubles every vector's length.

These act as neutral or scaling elements in matrix arithmetic.

Geometric Intuition

  1. In $\mathbb{R}^2$ or $\mathbb{R}^3$, adding transformation matrices is like superimposing geometric effects: e.g., one matrix shears, another rotates, their sum mixes both.
  2. Scaling a transformation makes its action stronger or weaker. Doubling a shear makes it twice as pronounced.

This shows that even before multiplication, addition and scaling already have geometric meaning.

Everyday Analogies

  • Recipes: Adding two recipes (matrices) ingredient by ingredient gives a combined shopping list. Multiplying a recipe by 3 scales it for 3 times as many people.
  • Financial planning: Adding two budget tables gives a combined budget. Multiplying by 12 scales monthly costs to yearly totals.
  • Mixing effects: Think of audio signals represented by matrices. Adding them overlays sounds; scaling adjusts volume.

Why It Matters

Though simple, these operations:

  • Define matrices as elements of vector spaces.
  • Lay the groundwork for linear combinations of matrices, critical in eigenvalue problems, optimization, and control theory.
  • Enable modular problem-solving: break big transformations into smaller ones and recombine them.
  • Appear everywhere in practice, from combining datasets to scaling transformations.

Without addition and scalar multiplication, we could not treat matrices systematically as algebraic objects.

Try It Yourself

  1. Add

$$ \begin{bmatrix} 2 & 0 \ 1 & 3 \end{bmatrix} \quad \text{and} \quad \begin{bmatrix} -2 & 5 \ 4 & -3 \end{bmatrix}. $$

  1. Multiply

$$ \begin{bmatrix} 1 & -1 & 2 \ 0 & 3 & 4 \end{bmatrix} $$

by –2.

  1. Show that (A + B) + C = A + (B + C) with explicit 2×2 matrices.

  2. Challenge: Construct two 3×3 matrices A and B such that A + B = 0. What does that tell you about B?

By practicing these fundamentals, you will see that even the most basic operations on matrices already build the algebraic backbone for deeper results like matrix multiplication, transformations, and factorization.

14. Matrix–Vector Product (Linear Combinations of Columns)

We now arrive at one of the most important operations in all of linear algebra: the matrix–vector product. This operation takes a matrix $A$ and a vector x, and produces a new vector. While the computation is straightforward, its interpretations are deep: it can be seen as combining rows, as combining columns, or as applying a linear transformation. This is the operation that connects matrices to the geometry of vector spaces.

The Algebraic Rule

Suppose $A$ is an $m \times n$ matrix, and x is a vector in $\mathbb{R}^n$. The product $A\mathbf{x}$ is a vector in $\mathbb{R}^m$, defined as:

$$ A = \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \ a_{21} & a_{22} & \cdots & a_{2n} \ \vdots & \vdots & \ddots & \vdots \ a_{m1} & a_{m2} & \cdots & a_{mn} \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} x_1 \ x_2 \ \vdots \ x_n \end{bmatrix}. $$

Then:

$$ A\mathbf{x} = \begin{bmatrix} a_{11}x_1 + a_{12}x_2 + \cdots + a_{1n}x_n \ a_{21}x_1 + a_{22}x_2 + \cdots + a_{2n}x_n \ \vdots \ a_{m1}x_1 + a_{m2}x_2 + \cdots + a_{mn}x_n \end{bmatrix}. $$

Each entry of the output is a dot product between one row of $A$ and the vector x.

Row View: Dot Products

From the row perspective, $A\mathbf{x}$ is computed row by row:

  • Take each row of $A$.
  • Dot it with x.
  • That result becomes one entry of the output.

Example:

$$ A = \begin{bmatrix} 2 & 1 \ 3 & 4 \ -1 & 2 \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} 5 \ -1 \end{bmatrix}. $$

  • First row dot x: $2(5) + 1(-1) = 9$.
  • Second row dot x: $3(5) + 4(-1) = 11$.
  • Third row dot x: $(-1)(5) + 2(-1) = -7$.

So:

$$ A\mathbf{x} = \begin{bmatrix} 9 \ 11 \ -7 \end{bmatrix}. $$

Column View: Linear Combinations

From the column perspective, $A\mathbf{x}$ is a linear combination of the columns of A.

If

$$ A = \begin{bmatrix} | & | & & | \ a_1 & a_2 & \cdots & a_n \ | & | & & | \end{bmatrix}, \quad \mathbf{x} = \begin{bmatrix} x_1 \ x_2 \ \vdots \ x_n \end{bmatrix}, $$

then:

$$ A\mathbf{x} = x_1 a_1 + x_2 a_2 + \cdots + x_n a_n. $$

That is: multiply each column of $A$ by the corresponding entry in x, then add them up.

This interpretation connects directly to the idea of span: the set of all vectors $A\mathbf{x}$ as x varies is exactly the span of the columns of $A$.

The Machine View: Linear Transformations

The machine view ties everything together: multiplying a vector by a matrix means applying the linear transformation represented by the matrix.

  • If $A$ is a 2×2 rotation matrix, then $A\mathbf{x}$ rotates the vector x.
  • If $A$ is a scaling matrix, then $A\mathbf{x}$ stretches or shrinks x.
  • If $A$ is a projection matrix, then $A\mathbf{x}$ projects x onto a line or plane.

Thus, the algebraic definition encodes geometric and functional meaning.

Examples of Geometric Action

  1. Scaling:

$$ A = \begin{bmatrix} 2 & 0 \ 0 & 2 \end{bmatrix}. $$

Then $A\mathbf{x}$ doubles the length of any vector x.

  1. Reflection:

$$ A = \begin{bmatrix} 1 & 0 \ 0 & -1 \end{bmatrix}. $$

This flips vectors across the x-axis.

  1. Rotation by θ:

$$ A = \begin{bmatrix} \cosθ & -\sinθ \ \sinθ & \cosθ \end{bmatrix}. $$

This rotates vectors counterclockwise by θ in the plane.

Everyday Analogies

  • Mixing ingredients: The vector x is a recipe, and the columns of $A$ are the ingredients. The product $A\mathbf{x}$ is the final mixture.
  • Weighted averages: A student's final grade is a matrix–vector product: weights (the vector) multiplied by scores (the matrix columns).
  • Signal processing: Combining input signals with weights produces a new output, just like multiplying a matrix of signals by a weight vector.

Why It Matters

The matrix–vector product is the building block of everything in linear algebra:

  1. It defines the action of a matrix as a linear map.
  2. It connects directly to span and dimension (columns generate all possible outputs).
  3. It underpins solving linear systems, eigenvalue problems, and decompositions.
  4. It is the engine of computation in applied mathematics, from computer graphics to machine learning (e.g., neural networks compute billions of matrix–vector products).

Try It Yourself

  1. Compute

$$ \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix} \begin{bmatrix} 2 \ 0 \ 1 \end{bmatrix}. $$

  1. Express the result of the above product as a linear combination of the columns of the matrix.

  2. Construct a 2×2 matrix that reflects vectors across the line $y = x$. Test it on (1, 0) and (0, 1).

  3. Challenge: For a 3×3 matrix, show that the set of all possible $A\mathbf{x}$ (as x varies) is exactly the column space of $A$.

By mastering both the computational rules and the interpretations of the matrix–vector product, you will gain the most important insight in linear algebra: matrices are not just tables-they are engines that transform space.

15. Matrix–Matrix Product (Composition of Linear Steps)

Having understood how a matrix acts on a vector, the next natural step is to understand how one matrix can act on another. This leads us to the matrix–matrix product, a rule for combining two matrices into a single new matrix. Though the arithmetic looks complicated at first, the underlying idea is elegant: multiplying two matrices represents composing two linear transformations.

The Algebraic Rule

Suppose $A$ is an $m \times n$ matrix and $B$ is an $n \times p$ matrix. Their product $C = AB$ is an $m \times p$ matrix defined by:

$$ c_{ij} = \sum_{k=1}^n a_{ik} b_{kj}. $$

That is: each entry of $C$ is the dot product of the i-th row of $A$ with the j-th column of $B$.

Example: A 2×3 times a 3×2

$$ A = \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix}, \quad B = \begin{bmatrix} 7 & 8 \ 9 & 10 \ 11 & 12 \end{bmatrix}. $$

Product: $C = AB$ will be 2×2.

  • $c_{11} = 1\cdot 7 + 2\cdot 9 + 3\cdot 11 = 58$.
  • $c_{12} = 1\cdot 8 + 2\cdot 10 + 3\cdot 12 = 64$.
  • $c_{21} = 4\cdot 7 + 5\cdot 9 + 6\cdot 11 = 139$.
  • $c_{22} = 4\cdot 8 + 5\cdot 10 + 6\cdot 12 = 154$.

So:

$$ C = \begin{bmatrix} 58 & 64 \ 139 & 154 \end{bmatrix}. $$

Column View: Linear Combinations of Columns

From the column perspective, $AB$ is computed by applying $A$ to each column of $B$.

If $B = [b_1 ; b_2 ; \cdots ; b_p]$, then:

$$ AB = [A b_1 ; A b_2 ; \cdots ; A b_p]. $$

That is: multiply $A$ by each column of $B$. This is often the simplest way to think of the product.

Row View: Linear Combinations of Rows

From the row perspective, each row of $AB$ is formed by combining rows of $B$ using coefficients from a row of $A$. This dual view is less common but equally useful, especially in proofs and algorithms.

The Machine View: Composition of Transformations

The most important interpretation is the machine view: multiplying matrices corresponds to composing transformations.

  • If $A$ maps $\mathbb{R}^n \to \mathbb{R}^m$ and $B$ maps $\mathbb{R}^p \to \mathbb{R}^n$, then $AB$ maps $\mathbb{R}^p \to \mathbb{R}^m$.
  • In words: do $B$ first, then $A$.

Example:

  • Let $B$ rotate vectors by 90°.
  • Let $A$ scale vectors by 2.
  • Then $AB$ rotates and then scales-both steps combined into a single transformation.

Geometric Examples

  1. Scaling then rotation:

$$ A = \begin{bmatrix} 2 & 0 \ 0 & 2 \end{bmatrix}, \quad B = \begin{bmatrix} 0 & -1 \ 1 & 0 \end{bmatrix}. $$

Then $AB$ scales vectors by 2 after rotating them 90°.

  1. Projection then reflection: If $B$ projects onto the x-axis and $A$ reflects across the y-axis, then $AB$ represents "project then reflect."

Properties of Matrix Multiplication

  1. Associative: $(AB)C = A(BC)$.
  2. Distributive: $A(B + C) = AB + AC$.
  3. Not commutative: In general, $AB \neq BA$. Order matters!
  4. Identity: $AI = IA = A$.

These properties highlight that while multiplication is structured, it is not symmetric. The order encodes the order of operations in transformations.

Everyday Analogies

  • Cooking steps: If $B$ is "chop vegetables" and $A$ is "cook vegetables," then $AB$ is "cook after chopping." Doing it the other way (BA) would make no sense!
  • Assembly line: Each machine (matrix) performs an operation on the input. Chaining them corresponds to multiplying the matrices.
  • Maps and routes: Going from home to the station (B), then from station to office (A) equals the combined route home→office (AB).

Why It Matters

Matrix multiplication is the core of linear algebra because:

  1. It encodes function composition in algebraic form.
  2. It provides a way to capture multiple transformations in a single matrix.
  3. It underpins algorithms in computer graphics, robotics, statistics, and machine learning.
  4. It reveals deeper structure, like commutativity failing, which reflects real-world order of operations.

Almost every application of linear algebra-solving equations, computing eigenvalues, training neural networks-relies on efficient matrix multiplication.

Try It Yourself

  1. Compute

$$ \begin{bmatrix} 1 & 0 \ 2 & 3 \end{bmatrix} \begin{bmatrix} 4 & 5 \ 6 & 7 \end{bmatrix}. $$

  1. Show that $AB \neq BA$ for the matrices

$$ A = \begin{bmatrix} 0 & 1 \ 0 & 0 \end{bmatrix}, \quad B = \begin{bmatrix} 0 & 0 \ 1 & 0 \end{bmatrix}. $$

  1. Construct two 2×2 matrices where $AB = BA$. Why does commutativity happen here?

  2. Challenge: If $A$ is a projection and $B$ is a rotation, compute $AB$ and $BA$. Do they represent the same geometric operation?

Through these perspectives, the matrix–matrix product shifts from being a mechanical formula to being a language for combining linear steps-each product telling the story of "do this, then that."

16. Identity, Inverse, and Transpose

With addition, scalar multiplication, and matrix multiplication in place, we now introduce three special operations and objects that form the backbone of matrix algebra: the identity matrix, the inverse of a matrix, and the transpose of a matrix. Each captures a fundamental principle-neutrality, reversibility, and symmetry-and together they provide the algebraic structure that makes linear algebra so powerful.

The Identity Matrix

The identity matrix is the matrix equivalent of the number 1 in multiplication.

  • Definition: The identity matrix $I_n$ is the $n \times n$ matrix with 1's on the diagonal and 0's everywhere else.

Example (3×3):

$$ I_3 = \begin{bmatrix} 1 & 0 & 0 \ 0 & 1 & 0 \ 0 & 0 & 1 \end{bmatrix}. $$

  • Property: For any $n \times n$ matrix $A$,

    $$ AI_n = I_nA = A. $$

  • Machine view: $I$ does nothing-it maps every vector to itself.

The Inverse of a Matrix

The inverse is the matrix equivalent of the reciprocal of a number.

  • Definition: For a square matrix $A$, its inverse $A^{-1}$ is the matrix such that

    $$ AA^{-1} = A^{-1}A = I. $$

  • Not all matrices have inverses. A matrix is invertible if and only if it is square and its determinant is nonzero.

Example:

$$ A = \begin{bmatrix} 2 & 1 \ 1 & 1 \end{bmatrix}, \quad A^{-1} = \begin{bmatrix} 1 & -1 \ -1 & 2 \end{bmatrix}. $$

Check:

$$ AA^{-1} = \begin{bmatrix} 2 & 1 \ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & -1 \ -1 & 2 \end{bmatrix}

\begin{bmatrix} 1 & 0 \ 0 & 1 \end{bmatrix} = I. $$

  • Machine view: Applying $A$ transforms a vector. Applying $A^{-1}$ undoes that transformation, restoring the original input.

Non-Invertible Matrices

Some matrices cannot be inverted. These are called singular.

  • Example:

    $$ B = \begin{bmatrix} 2 & 4 \ 1 & 2 \end{bmatrix}. $$

    Here, the second column is a multiple of the first. The transformation squashes vectors into a line, losing information-so it cannot be reversed.

This ties invertibility to geometry: a transformation that collapses dimensions cannot be undone.

The Transpose of a Matrix

The transpose reflects a matrix across its diagonal.

  • Definition: For $A = [a_{ij}]$,

    $$ A^T = [a_{ji}]. $$

  • In words: rows become columns, columns become rows.

Example:

$$ A = \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix}, \quad A^T = \begin{bmatrix} 1 & 4 \ 2 & 5 \ 3 & 6 \end{bmatrix}. $$

  • Properties:

    • $(A^T)^T = A$.
    • $(A + B)^T = A^T + B^T$.
    • $(cA)^T = cA^T$.
    • $(AB)^T = B^T A^T$ (note the reversed order!).

Symmetric and Orthogonal Matrices

Two important classes emerge from the transpose:

  • Symmetric matrices: $A = A^T$. Example:

    $$ \begin{bmatrix} 2 & 3 \ 3 & 5 \end{bmatrix}. $$

    These have beautiful properties: real eigenvalues and orthogonal eigenvectors.

  • Orthogonal matrices: $Q^TQ = I$. Their columns form an orthonormal set, and they represent pure rotations/reflections.

Everyday Analogies

  • Identity: A mirror that doesn't distort your reflection-it leaves everything unchanged.
  • Inverse: A "reverse recipe"-if one step mixes, the inverse unmixed (where possible).
  • Transpose: Reorganizing a spreadsheet by flipping rows and columns.

Why It Matters

  1. The identity guarantees a neutral element for multiplication.
  2. The inverse provides a way to solve equations $A\mathbf{x} = \mathbf{b}$ via $\mathbf{x} = A^{-1}\mathbf{b}$.
  3. The transpose ties matrices to geometry, inner products, and symmetry.
  4. Together, they form the algebraic foundation for deeper topics: determinants, eigenvalues, factorizations, and numerical methods.

Without these tools, matrix algebra would lack structure and reversibility.

Try It Yourself

  1. Compute the transpose of

$$ \begin{bmatrix} 1 & 0 & 2 \ -3 & 4 & 5 \end{bmatrix}. $$

  1. Verify that $(AB)^T = B^TA^T$ for

$$ A = \begin{bmatrix} 1 & 2 \ 0 & 3 \end{bmatrix}, \quad B = \begin{bmatrix} 4 & 0 \ 5 & 6 \end{bmatrix}. $$

  1. Find the inverse of

$$ \begin{bmatrix} 3 & 2 \ 1 & 1 \end{bmatrix}. $$

  1. Challenge: Show that if $Q$ is orthogonal, then $Q^{-1} = Q^T$. Interpret this geometrically as saying "rotations can be undone by transposing."

Through these exercises, you'll see how identity, inverse, and transpose anchor the structure of linear algebra, providing neutrality, reversibility, and symmetry in every calculation.

17. Symmetric, Diagonal, Triangular, and Permutation Matrices

Not all matrices are created equal-some have special shapes or patterns that give them unique properties. These structured matrices are the workhorses of linear algebra: they simplify computation, reveal geometry, and form the building blocks for algorithms. In this section, we study four especially important classes: symmetric, diagonal, triangular, and permutation matrices.

Symmetric Matrices

A matrix is symmetric if it equals its transpose:

$$ A = A^T. $$

Example:

$$ \begin{bmatrix} 2 & 3 & 4 \ 3 & 5 & 6 \ 4 & 6 & 9 \end{bmatrix}. $$

  • Geometric meaning: Symmetric matrices represent linear transformations that have no "handedness." They often arise in physics (energy, covariance, stiffness).
  • Algebraic fact: Symmetric matrices have real eigenvalues and an orthonormal basis of eigenvectors. This property underpins the spectral theorem, one of the pillars of linear algebra.

Diagonal Matrices

A matrix is diagonal if all non-diagonal entries are zero.

$$ D = \begin{bmatrix} d_1 & 0 & 0 \ 0 & d_2 & 0 \ 0 & 0 & d_3 \end{bmatrix}. $$

  • Multiplying by $D$ scales each coordinate separately.

  • Computations with diagonals are lightning fast:

    • Adding: add diagonal entries.
    • Multiplying: multiply diagonal entries.
    • Inverting: invert each diagonal entry (if nonzero).

Example:

$$ \begin{bmatrix} 2 & 0 \ 0 & 3 \end{bmatrix} \begin{bmatrix} x \ y \end{bmatrix}

\begin{bmatrix} 2x \ 3y \end{bmatrix}. $$

This is why diagonalization is so valuable: turning a general matrix into a diagonal one simplifies everything.

Triangular Matrices

A matrix is upper triangular if all entries below the main diagonal are zero, and lower triangular if all entries above the diagonal are zero.

  • Upper triangular example:

    $$ \begin{bmatrix} 1 & 2 & 3 \ 0 & 4 & 5 \ 0 & 0 & 6 \end{bmatrix}. $$

  • Lower triangular example:

    $$ \begin{bmatrix} 7 & 0 & 0 \ 8 & 9 & 0 \ 10 & 11 & 12 \end{bmatrix}. $$

Why they matter:

  • Determinant = product of diagonal entries.
  • Easy to solve systems by substitution (forward or backward).
  • Every square matrix can be factored into triangular matrices (LU decomposition).

Permutation Matrices

A permutation matrix is obtained by permuting the rows (or columns) of an identity matrix.

Example:

$$ P = \begin{bmatrix} 0 & 1 & 0 \ 1 & 0 & 0 \ 0 & 0 & 1 \end{bmatrix}. $$

Multiplying by $P$:

  • On the left, permutes the rows of a matrix.
  • On the right, permutes the columns of a matrix.

Permutation matrices are used in pivoting strategies in elimination, ensuring numerical stability in solving systems. They are also orthogonal: $P^{-1} = P^T$.

Connections Between Them

  • A diagonal matrix is a special case of triangular (both upper and lower).
  • Symmetric matrices often become diagonal under orthogonal transformations.
  • Permutation matrices help reorder triangular or diagonal matrices without breaking their structure.

Together, these classes show that structure leads to simplicity-many computational algorithms exploit these patterns for speed and stability.

Everyday Analogies

  • Symmetric: A perfectly balanced seesaw-forces are mirrored on both sides.
  • Diagonal: Independent volume knobs for each channel of a stereo system-no cross-interference.
  • Triangular: Step-by-step instructions where each step depends only on earlier steps, never later ones.
  • Permutation: Shuffling cards-same elements, different order.

Why It Matters

  1. Symmetric matrices guarantee stable and interpretable eigen-decompositions.
  2. Diagonal matrices make computation effortless.
  3. Triangular matrices are the backbone of elimination and factorization methods.
  4. Permutation matrices preserve structure while reordering, critical for algorithms.

Almost every advanced method in numerical linear algebra relies on reducing general matrices into one of these structured forms.

Try It Yourself

  1. Verify that

$$ \begin{bmatrix} 1 & 2 \ 2 & 5 \end{bmatrix} $$

is symmetric. Find its transpose.

  1. Compute the determinant of

$$ \begin{bmatrix} 3 & 0 & 0 \ 0 & 4 & 0 \ 0 & 0 & 5 \end{bmatrix}. $$

  1. Solve

$$ \begin{bmatrix} 2 & 3 & 1 \ 0 & 5 & 2 \ 0 & 0 & 4 \end{bmatrix} \mathbf{x} = \begin{bmatrix} 1 \ 2 \ 3 \end{bmatrix} $$

using back substitution.

  1. Construct a 4×4 permutation matrix that swaps the first and last rows. Apply it to a 4×1 vector of your choice.

By exploring these four structured families, you'll start to see that not all matrices are messy-many have order hidden in their arrangement, and exploiting that order is the key to both theoretical understanding and efficient computation.

18. Trace and Basic Matrix Properties

So far we have studied shapes, multiplication rules, and special classes of matrices. In this section we introduce a simple but surprisingly powerful quantity: the trace of a matrix. Along with it, we review a set of basic matrix properties that provide shortcuts, invariants, and insights into how matrices behave.

Definition of the Trace

For a square matrix $A = [a_{ij}]$ of size $n \times n$, the trace is the sum of the diagonal entries:

$$ \text{tr}(A) = a_{11} + a_{22} + \cdots + a_{nn}. $$

Example:

$$ A = \begin{bmatrix} 2 & 5 & 7 \ 0 & 3 & 1 \ 4 & 6 & 8 \end{bmatrix}, \quad \text{tr}(A) = 2 + 3 + 8 = 13. $$

The trace extracts a single number summarizing the "diagonal content" of a matrix.

Properties of the Trace

The trace is linear and interacts nicely with multiplication and transposition:

  1. Linearity:

    • $\text{tr}(A + B) = \text{tr}(A) + \text{tr}(B)$.
    • $\text{tr}(cA) = c \cdot \text{tr}(A)$.
  2. Cyclic Property:

    • $\text{tr}(AB) = \text{tr}(BA)$, as long as the products are defined.
    • More generally, $\text{tr}(ABC) = \text{tr}(BCA) = \text{tr}(CAB)$.
    • But in general, $\text{tr}(AB) \neq \text{tr}(A)\text{tr}(B)$.
  3. Transpose Invariance:

    • $\text{tr}(A^T) = \text{tr}(A)$.
  4. Similarity Invariance:

    • If $B = P^{-1}AP$, then $\text{tr}(B) = \text{tr}(A)$.
    • This means the trace is a similarity invariant, depending only on the linear transformation, not the basis.

Trace and Eigenvalues

One of the most important connections is between the trace and eigenvalues:

$$ \text{tr}(A) = \lambda_1 + \lambda_2 + \cdots + \lambda_n, $$

where $\lambda_i$ are the eigenvalues of $A$ (counting multiplicity).

This links the simple diagonal sum to the deep spectral properties of the matrix.

Example:

$$ A = \begin{bmatrix} 1 & 0 \ 0 & 3 \end{bmatrix}, \quad \text{tr}(A) = 4, \quad \lambda_1 = 1, ; \lambda_2 = 3, \quad \lambda_1 + \lambda_2 = 4. $$

Other Basic Matrix Properties

Alongside the trace, here are some important algebraic facts that every student of linear algebra must know:

  1. Determinant vs. Trace:

    • For 2×2 matrices, $A = \begin{bmatrix} a & b \ c & d \end{bmatrix}$, $\text{tr}(A) = a + d$, $\det(A) = ad - bc$.
    • Together, trace and determinant encode the eigenvalues: roots of $x^2 - \text{tr}(A)x + \det(A) = 0$.
  2. Norms and Inner Products:

    • The Frobenius norm is defined using the trace: $|A|_F = \sqrt{\text{tr}(A^TA)}$.
  3. Orthogonal Invariance:

    • For any orthogonal matrix $Q$, $\text{tr}(Q^TAQ) = \text{tr}(A)$.

Geometric and Practical Meaning

  • The trace of a transformation can be seen as the sum of its action along the coordinate axes.
  • In physics, the trace of the stress tensor measures pressure.
  • In probability, the trace of a covariance matrix is the total variance of a system.
  • In statistics and machine learning, the trace is often used as a measure of overall "size" or complexity of a model.

Everyday Analogies

  • Grades on report card: The trace is like summing the "main subjects" (diagonal entries) without looking at electives (off-diagonal entries).
  • Company budget: The diagonal could represent department totals, and the trace is the grand total.
  • Lighting system: Imagine each diagonal entry is a light switch brightness for each room; the trace is the sum total brightness in the building.

Why It Matters

The trace is deceptively simple but incredibly powerful:

  1. It connects directly to eigenvalues, forming a bridge between raw matrix entries and spectral theory.
  2. It is invariant under similarity, making it a reliable measure of a transformation independent of basis.
  3. It shows up in optimization, physics, statistics, and quantum mechanics.
  4. It simplifies computations: many proofs in linear algebra reduce to trace properties.

Try It Yourself

  1. Compute the trace of

$$ \begin{bmatrix} 4 & 2 & 0 \ -1 & 3 & 5 \ 7 & 6 & 1 \end{bmatrix}. $$

  1. Verify that $\text{tr}(AB) = \text{tr}(BA)$ for

$$ A = \begin{bmatrix} 1 & 2 \ 0 & 3 \end{bmatrix}, \quad B = \begin{bmatrix} 4 & 0 \ 5 & 6 \end{bmatrix}. $$

  1. For the 2×2 matrix

$$ \begin{bmatrix} 2 & 1 \ 1 & 2 \end{bmatrix}, $$

compute its eigenvalues and check that their sum equals the trace.

  1. Challenge: Show that the total variance of a dataset with covariance matrix $\Sigma$ is equal to $\text{tr}(\Sigma)$.

Mastering the trace and its properties will prepare you for the next leap: understanding how matrices interact with volume, orientation, and determinants.

19. Affine Transforms and Homogeneous Coordinates

Up to now, matrices have been used to describe linear transformations: scaling, rotating, reflecting, projecting. But real-world geometry often involves more than just linear effects-it includes translations (shifts) as well. A pure linear map cannot move the origin, so to handle translations (and combinations of them with rotations, scalings, and shears), we extend our toolkit to affine transformations. The secret weapon that makes this work is the idea of homogeneous coordinates.

What is an Affine Transformation?

An affine transformation is any map of the form:

$$ f(\mathbf{x}) = A\mathbf{x} + \mathbf{b}, $$

where $A$ is a matrix (linear part) and $\mathbf{b}$ is a vector (translation part).

  • $A$ handles scaling, rotation, reflection, shear, or projection.
  • $\mathbf{b}$ shifts everything by a constant amount.

Examples in 2D:

  1. Rotate by 90° and then shift right by 2.
  2. Stretch vertically by 3 and shift upward by 1.

Affine maps preserve parallel lines and ratios of distances along lines, but not necessarily angles or lengths.

Why Linear Maps Alone Aren't Enough

If we only use a 2×2 matrix in 2D or 3×3 in 3D, the origin always stays fixed. That's a limitation: real-world movements (like moving a shape from one place to another) require shifting the origin too. To capture both linear and translational effects uniformly, we need a clever trick.

Homogeneous Coordinates

The trick is to add one extra coordinate.

  • In 2D, a point $(x, y)$ becomes $(x, y, 1)$.
  • In 3D, a point $(x, y, z)$ becomes $(x, y, z, 1)$.

This new representation is called homogeneous coordinates. It allows us to fold translations into matrix multiplication.

Affine Transform as a Matrix in Homogeneous Form

In 2D:

$$ \begin{bmatrix} a & b & t_x \ c & d & t_y \ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \ y \ 1 \end{bmatrix}

\begin{bmatrix} ax + by + t_x \ cx + dy + t_y \ 1 \end{bmatrix}. $$

Here,

  • The 2×2 block $\begin{bmatrix} a & b \ c & d \end{bmatrix}$ is the linear part.
  • The last column $\begin{bmatrix} t_x \ t_y \end{bmatrix}$ is the translation.

So with one unified matrix, we can handle both linear transformations and shifts.

Examples in 2D

  1. Translation by (2, 3):

$$ \begin{bmatrix} 1 & 0 & 2 \ 0 & 1 & 3 \ 0 & 0 & 1 \end{bmatrix}. $$

  1. Scaling by 2 in x and 3 in y, then shifting by (–1, 4):

$$ \begin{bmatrix} 2 & 0 & -1 \ 0 & 3 & 4 \ 0 & 0 & 1 \end{bmatrix}. $$

  1. Rotation by 90° and shift right by 5:

$$ \begin{bmatrix} 0 & -1 & 5 \ 1 & 0 & 0 \ 0 & 0 & 1 \end{bmatrix}. $$

Homogeneous Coordinates in 3D

In 3D, affine transformations use 4×4 matrices. The upper-left 3×3 block handles rotation, scaling, or shear; the last column encodes translation.

Example: translation by (2, –1, 4):

$$ \begin{bmatrix} 1 & 0 & 0 & 2 \ 0 & 1 & 0 & -1 \ 0 & 0 & 1 & 4 \ 0 & 0 & 0 & 1 \end{bmatrix}. $$

This formulation is universal in computer graphics and robotics.

Everyday Analogies

  • Photography: Moving a camera involves not only rotating it (linear part) but also translating it in space.
  • Navigation: Walking north (linear step) and then shifting east (translation).
  • Graphics software: Scaling an image larger and then dragging it to a new position-exactly affine transformations in action.

Why It Matters

  1. Unified representation: Using homogeneous coordinates, we can treat translations as matrices, enabling consistent matrix multiplication for all transformations.
  2. Practicality: This approach underpins 3D graphics pipelines, animation, CAD, robotics, and computer vision.
  3. Composability: Multiple affine transformations can be combined into a single homogeneous matrix by multiplying them.
  4. Geometry preserved: Affine maps preserve straight lines and parallelism, essential in engineering and design.

Try It Yourself

  1. Write the homogeneous matrix that reflects across the x-axis and then shifts up by 3. Apply it to $(2, 1)$.
  2. Construct a 4×4 homogeneous matrix that rotates around the z-axis by 90° and translates by (1, 2, 0).
  3. Show that multiplying two 3×3 homogeneous matrices in 2D yields another valid affine transform.
  4. Challenge: Prove that affine maps preserve parallel lines by applying a general affine matrix to two parallel lines and checking their slopes.

Mastering affine transformations and homogeneous coordinates bridges the gap between pure linear algebra and real-world geometry, giving you the mathematical foundation behind computer graphics, robotics, and spatial modeling.

20. Computing with Matrices (Cost Counts and Simple Speedups)

Thus far, we have studied what matrices are and what they represent. But in practice, working with matrices also means thinking about computation-how much work operations take, how algorithms can be sped up, and why structure matters. This section introduces the basic ideas of computational cost in matrix operations, simple strategies for efficiency, and why these considerations are crucial in modern applications.

Counting Operations: The Cost Model

The simplest way to measure the cost of a matrix operation is to count the basic arithmetic operations (additions and multiplications).

  • Matrix–vector product: For an $m \times n$ matrix and an $n \times 1$ vector:

    • Each of the $m$ output entries requires $n$ multiplications and $n-1$ additions.
    • Total cost ≈ $2mn$ operations.
  • Matrix–matrix product: For an $m \times n$ matrix times an $n \times p$ matrix:

    • Each of the $mp$ entries requires $n$ multiplications and $n-1$ additions.
    • Total cost ≈ $2mnp$ operations.
  • Gaussian elimination (solving $Ax=b$): For an $n \times n$ system:

    • Roughly $\tfrac{2}{3}n^3$ operations.

These counts show how quickly costs grow with dimension. Doubling $n$ makes the work 8 times larger for elimination.

Why Cost Counts Matter

  1. Scalability: Small problems (2×2 or 3×3) are trivial, but modern datasets involve matrices with millions of rows. Knowing the cost is essential.
  2. Feasibility: Some exact algorithms become impossible for very large matrices. Approximation methods are used instead.
  3. Optimization: Engineers and scientists design specialized algorithms to reduce costs by exploiting structure (sparsity, symmetry, triangular form).

Simple Speedups with Structure

  • Diagonal Matrices: Multiplying by a diagonal matrix costs only $n$ operations (scale each component).
  • Triangular Matrices: Solving triangular systems requires only $\tfrac{1}{2}n^2$ operations (substitution), far cheaper than general elimination.
  • Sparse Matrices: If most entries are zero, we skip multiplications by zero. For large sparse systems, cost scales with the number of nonzeros, not $n^2$.
  • Block Matrices: Breaking matrices into blocks allows algorithms to reuse optimized small-matrix routines (common in BLAS libraries).

Memory Considerations

Cost is not only arithmetic: storage also matters.

  • A dense $n \times n$ matrix requires $n^2$ entries of memory.
  • Sparse storage formats (like CSR, COO) record only nonzero entries and their positions, saving massive space.
  • Memory access speed can dominate arithmetic cost in large computations.

Parallelism and Hardware

Modern computing leverages hardware for speed:

  • Vectorization (SIMD): Perform many multiplications at once.
  • Parallelization: Split work across many CPU cores.
  • GPUs: Specialize in massive parallel matrix–vector and matrix–matrix operations (critical in deep learning).

This is why linear algebra libraries (BLAS, LAPACK, cuBLAS) are indispensable: they squeeze performance from hardware.

Everyday Analogies

  • Cooking: Preparing one dish is easy. Preparing 100 dishes means thinking about batch size, oven space, and parallel steps.
  • Budgeting: Adding two small budgets by hand is fine; merging thousands of spreadsheets requires software and structure.
  • Travel: Driving across town is quick. Driving cross-country requires fuel planning, route optimization, and rest stops-scale changes everything.

Why It Matters

  1. Efficiency: Understanding cost lets us choose the right algorithm for the job.
  2. Algorithm design: Structured matrices (diagonal, sparse, orthogonal) make computations much faster and more stable.
  3. Applications: Every field that uses matrices-graphics, optimization, statistics, AI-relies on efficient computation.
  4. Foundations: Later topics like LU/QR/SVD factorization are motivated by balancing cost and stability.

Try It Yourself

  1. Compute the number of operations required for multiplying a 1000×500 matrix with a 500×200 matrix. Compare with multiplying a 1000×1000 dense matrix by a vector.
  2. Show how solving a 3×3 triangular system is faster than Gaussian elimination. Count the exact multiplications and additions.
  3. Construct a sparse 5×5 matrix with only 7 nonzero entries. Estimate the cost of multiplying it by a vector versus a dense 5×5 matrix.
  4. Challenge: Suppose you need to store a 1,000,000×1,000,000 dense matrix. Estimate how much memory (in bytes) it would take if each entry is 8 bytes. Could it fit on a laptop? Why do sparse formats save the day?

By learning to count costs and exploit structure, you prepare yourself not only to understand matrices abstractly but also to use them effectively in real-world, large-scale problems. This balance between theory and computation is at the heart of modern linear algebra.

Closing

Patterns intertwine,
transformations gently fold,
structure in the square.

Chapter 3. Linear Systems and Elimination

21. From Equations to Matrices

Linear algebra often begins with systems of equations-collections of unknowns linked by linear relationships. While these systems can be solved directly using substitution or elimination, they quickly become messy when there are many variables. The key insight of linear algebra is that all systems of linear equations can be captured compactly by matrices and vectors. This section explains how we move from equations written out in words and symbols to the matrix form that powers computation.

A Simple Example

Consider this system of two equations in two unknowns:

$$ \begin{cases}
2x + y = 5 \
3x - y = 4
\end{cases} $$

At first glance, this is just algebra: two equations, two unknowns. But notice the structure: each equation is a sum of multiples of the variables, set equal to a constant. This pattern-linear combinations of unknowns equal to a result-is exactly what matrices capture.

Writing in Coefficient Table Form

Extract the coefficients of each variable from the system:

  • First equation: coefficients are $2$ for $x$, $1$ for $y$.
  • Second equation: coefficients are $3$ for $x$, $-1$ for $y$.

Arrange these coefficients in a rectangular array:

$$ A = \begin{bmatrix}
2 & 1 \
3 & -1
\end{bmatrix}. $$

This matrix $A$ is called the coefficient matrix.

Next, write the unknowns as a vector:

$$ \mathbf{x} = \begin{bmatrix} x \ y \end{bmatrix}. $$

Finally, write the right-hand side constants as another vector:

$$ \mathbf{b} = \begin{bmatrix} 5 \ 4 \end{bmatrix}. $$

Now the entire system can be written in a single line:

$$ A\mathbf{x} = \mathbf{b}. $$

Why This is Powerful

This compact form hides no information; it is equivalent to the original equations. But it gives us enormous advantages:

  1. Clarity: We see the structure clearly-the system is "matrix times vector equals vector."
  2. Scalability: Whether we have 2 equations or 2000, the same notation applies.
  3. Tools: All the machinery of matrix operations (elimination, inverses, decompositions) now becomes available.
  4. Geometry: The matrix equation $A\mathbf{x} = \mathbf{b}$ means: combine the columns of $A$ (scaled by entries of x) to land on b.

A Larger Example

System of three equations in three unknowns:

$$ \begin{cases}
x + 2y - z = 2 \
2x - y + 3z = 1 \
3x + y + 2z = 4
\end{cases} $$

  • Coefficient matrix:

    $$ A = \begin{bmatrix}
    1 & 2 & -1 \
    2 & -1 & 3 \
    3 & 1 & 2
    \end{bmatrix}. $$

  • Unknown vector:

    $$ \mathbf{x} = \begin{bmatrix} x \ y \ z \end{bmatrix}. $$

  • Constant vector:

    $$ \mathbf{b} = \begin{bmatrix} 2 \ 1 \ 4 \end{bmatrix}. $$

Matrix form:

$$ A\mathbf{x} = \mathbf{b}. $$

This single equation captures three equations and three unknowns in one object.

Row vs. Column View

  • Row view: Each row of $A$ dotted with x gives one equation.
  • Column view: The entire system means b is a linear combination of the columns of $A$.

For the 2×2 case earlier:

$$ A\mathbf{x} = \begin{bmatrix} 2 & 1 \ 3 & -1 \end{bmatrix}
\begin{bmatrix} x \ y \end{bmatrix}
= x \begin{bmatrix} 2 \ 3 \end{bmatrix} + y \begin{bmatrix} 1 \ -1 \end{bmatrix}. $$

So solving the system means finding scalars $x, y$ that combine the columns of $A$ to reach $\mathbf{b}$.

Augmented Matrix Form

Sometimes we want to save space further. We can put the coefficients and constants side by side in an augmented matrix:

$$ [A | \mathbf{b}] =
\begin{bmatrix}
2 & 1 & | & 5 \
3 & -1 & | & 4
\end{bmatrix}. $$

This form is especially useful for elimination methods, where we manipulate rows without writing variables at each step.

Everyday Analogies

  • Recipes: A recipe tells you how many units of each ingredient (coefficients) produce the dish (constant result). Writing it as a matrix is like organizing all recipes into a clean table.
  • Schedules: Each row of a timetable (equation) corresponds to one condition. Putting it into matrix form organizes it into one big grid.
  • Construction: The coefficients are like "how many bricks per wall," while the vector x is "number of walls built." The product gives total bricks, and the system sets the required totals.

Why It Matters

This step-rewriting equations as matrix form-is the gateway into linear algebra. Once you can do it, you no longer think of systems of equations as isolated lines on paper, but as a unified object that can be studied with general tools. It opens the door to:

  • Gaussian elimination,
  • rank and null space,
  • determinants,
  • eigenvalues,
  • optimization methods.

Every major idea flows from this compact representation.

Try It Yourself

  1. Write the system

    $$ \begin{cases}
    4x - y = 7 \
    -2x + 3y = 5
    \end{cases} $$

    in matrix form.

  2. For the system

    $$ \begin{cases}
    x + y + z = 6 \
    2x - y + z = 3 \
    x - y - z = -2
    \end{cases} $$

    build the coefficient matrix, unknown vector, and constant vector.

  3. Express the augmented matrix for the above system.

  4. Challenge: Interpret the system in column view. What does it mean geometrically to express $(6, 3, -2)$ as a linear combination of the columns of the coefficient matrix?

By practicing these rewrites, you will see that linear algebra is not about juggling many equations-it is about seeing structure in one compact equation. This step transforms scattered equations into the language of matrices, where the real power begins.

22. Row Operations

Once a system of linear equations has been expressed as a matrix, the next step is to simplify that matrix into a form where the solutions become clear. The main tool for this simplification is the set of elementary row operations. These operations allow us to manipulate the rows of a matrix in systematic ways that preserve the solution set of the corresponding system of equations.

The Three Types of Row Operations

There are exactly three types of legal row operations, each with a clear algebraic meaning:

  1. Row Swapping ($R_i \leftrightarrow R_j$): Exchange two rows. This corresponds to reordering equations in a system. Since the order of equations doesn't change the solutions, this operation is always valid.

    Example:

    $$ \begin{bmatrix}
    2 & 1 & | & 5 \
    3 & -1 & | & 4
    \end{bmatrix}
    \quad \longrightarrow \quad
    \begin{bmatrix}
    3 & -1 & | & 4 \
    2 & 1 & | & 5
    \end{bmatrix}. $$

  2. Row Scaling ($R_i \to cR_i, ; c \neq 0$): Multiply all entries in a row by a nonzero constant. This is like multiplying both sides of an equation by the same number, which doesn't change its truth.

    Example:

    $$ \begin{bmatrix}
    2 & 1 & | & 5 \
    3 & -1 & | & 4
    \end{bmatrix}
    \quad \longrightarrow \quad
    \begin{bmatrix}
    1 & \tfrac{1}{2} & | & \tfrac{5}{2} \
    3 & -1 & | & 4
    \end{bmatrix}. $$

  3. Row Replacement ($R_i \to R_i + cR_j$): Add a multiple of one row to another. This corresponds to replacing one equation with a linear combination of itself and another, a fundamental elimination step.

    Example:

    $$ \begin{bmatrix}
    2 & 1 & | & 5 \
    3 & -1 & | & 4
    \end{bmatrix}
    \quad \overset{R_2 \to R_2 - \tfrac{3}{2}R_1}{\longrightarrow} \quad
    \begin{bmatrix}
    2 & 1 & | & 5 \
    0 & -\tfrac{5}{2} & | & -\tfrac{7}{2}
    \end{bmatrix}. $$

Why These Are the Only Allowed Operations

These three operations are the backbone of elimination because they do not alter the solution set of the system. Each is equivalent to applying an invertible transformation:

  • Row swaps are reversible (swap back).
  • Row scalings by $c$ can be undone by scaling by $1/c$.
  • Row replacements can be undone by adding the opposite multiple.

Thus, each operation is invertible, and the transformed system is always equivalent to the original.

Row Operations as Matrices

Each elementary row operation can itself be represented by multiplying on the left with a special matrix called an elementary matrix.

For example:

  • Swapping rows 1 and 2 in a 2×2 system is done by

    $$ E = \begin{bmatrix} 0 & 1 \ 1 & 0 \end{bmatrix}. $$

  • Scaling row 1 by 3 in a 2×2 system is done by

    $$ E = \begin{bmatrix} 3 & 0 \ 0 & 1 \end{bmatrix}. $$

This perspective is crucial later for factorization methods like LU decomposition, where elimination is expressed as a product of elementary matrices.

Step-by-Step Example

System:

$$ \begin{cases}
x + 2y = 4 \
3x + 4y = 10
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 2 & | & 4 \
3 & 4 & | & 10
\end{bmatrix}. $$

  1. Eliminate the $3x$ under the first pivot: $R_2 \to R_2 - 3R_1$.

    $$ \begin{bmatrix}
    1 & 2 & | & 4 \
    0 & -2 & | & -2
    \end{bmatrix}. $$

  2. Scale the second row: $R_2 \to -\tfrac{1}{2}R_2$.

    $$ \begin{bmatrix}
    1 & 2 & | & 4 \
    0 & 1 & | & 1
    \end{bmatrix}. $$

  3. Eliminate above the pivot: $R_1 \to R_1 - 2R_2$.

    $$ \begin{bmatrix}
    1 & 0 & | & 2 \
    0 & 1 & | & 1
    \end{bmatrix}. $$

Solution: $x = 2, ; y = 1$.

Geometry of Row Operations

Row operations do not alter the solution space:

  • Swapping rows reorders equations but keeps the same lines or planes.
  • Scaling rows rescales equations but leaves their geometric set unchanged.
  • Adding rows corresponds to combining constraints, but the shared intersection (solution set) is preserved.

Thus, row operations act like "reshaping the system" while leaving the intersection intact.

Everyday Analogies

  • Cooking recipe: Scaling a row is like doubling all ingredients in one recipe-it doesn't change the proportions.
  • Task list: Swapping two rows is just reordering tasks; nothing about the tasks themselves changes.
  • Budgeting: Adding one department's budget equation to another is just reorganizing financial records, not altering totals.

Why It Matters

Row operations are the essential moves in solving linear systems by hand or computer. They:

  1. Make elimination systematic.
  2. Preserve solution sets while simplifying structure.
  3. Lay the groundwork for echelon forms, rank, and factorization.
  4. Provide the mechanical steps that computers automate in Gaussian elimination.

Try It Yourself

  1. Apply row operations to reduce

    $$ \begin{bmatrix}
    2 & 1 & | & 7 \
    1 & -1 & | & 1
    \end{bmatrix} $$

    to a form where the solution is obvious.

  2. Show explicitly why swapping two equations in a system doesn't change its solutions.

  3. Construct the elementary matrix for "add –2 times row 1 to row 3" in a 3×3 system.

  4. Challenge: Prove that any elementary row operation corresponds to multiplication by an invertible matrix.

Mastering these operations equips you with the mechanical and conceptual foundation for the next stage: systematically reducing matrices to row-echelon form.

23. Row-Echelon and Reduced Row-Echelon Forms

After introducing row operations, the natural question is: what are we trying to achieve by performing them? The answer is to transform a matrix into a standardized, simplified form where the solutions to the corresponding system of equations can be read off directly. Two such standardized forms are central in linear algebra: row-echelon form (REF) and reduced row-echelon form (RREF).

Row-Echelon Form (REF)

A matrix is in row-echelon form if:

  1. All nonzero rows are above any rows of all zeros.
  2. In each nonzero row, the first nonzero entry (called the leading entry or pivot) is to the right of the leading entry of the row above it.
  3. All entries below a pivot are zero.

Example of REF:

$$ \begin{bmatrix}
1 & 2 & 3 & | & 4 \
0 & 1 & -1 & | & 2 \
0 & 0 & 5 & | & -3 \
0 & 0 & 0 & | & 0
\end{bmatrix}. $$

Here, the pivots are the first 1 in row 1, the 1 in row 2, and the 5 in row 3. Each pivot is to the right of the one above it, and all entries below pivots are zero.

Reduced Row-Echelon Form (RREF)

A matrix is in reduced row-echelon form if, in addition to the rules of REF:

  1. Each pivot is equal to 1.
  2. Each pivot is the only nonzero entry in its column (everything above and below pivots is zero).

Example of RREF:

$$ \begin{bmatrix}
1 & 0 & 0 & | & 3 \
0 & 1 & 0 & | & -2 \
0 & 0 & 1 & | & 1
\end{bmatrix}. $$

This form is so simplified that solutions can be read directly: here, $x=3$, $y=-2$, $z=1$.

Relationship Between REF and RREF

  • REF is easier to reach-it only requires eliminating entries below pivots.
  • RREF requires going further-clearing entries above pivots and scaling pivots to 1.
  • Every matrix can be reduced to REF (many possible versions), but RREF is unique: no matter how you proceed, if you carry out all row operations fully, you end with the same RREF.

Example: Step-by-Step to RREF

System:

$$ \begin{cases}
x + 2y + z = 4 \
2x + 5y + z = 7 \
3x + 6y + 2z = 10
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 2 & 1 & | & 4 \
2 & 5 & 1 & | & 7 \
3 & 6 & 2 & | & 10
\end{bmatrix}. $$

  1. Eliminate below first pivot (the 1 in row 1, col 1):

    • $R_2 \to R_2 - 2R_1$
    • $R_3 \to R_3 - 3R_1$

    $$ \begin{bmatrix}
    1 & 2 & 1 & | & 4 \
    0 & 1 & -1 & | & -1 \
    0 & 0 & -1 & | & -2
    \end{bmatrix}. $$

    This is now in REF.

  2. Scale pivots and eliminate above them:

    • $R_3 \to -R_3$ to make pivot 1.
    • $R_2 \to R_2 + R_3$.
    • $R_1 \to R_1 - R_2 - R_3$.

    Final:

    $$ \begin{bmatrix}
    1 & 0 & 0 & | & 2 \
    0 & 1 & 0 & | & 1 \
    0 & 0 & 1 & | & 2
    \end{bmatrix}. $$

Solution: $x=2, y=1, z=2$.

Geometry of REF and RREF

  • REF corresponds to simplifying the system step by step, making it "triangular" so variables can be solved one after another.
  • RREF corresponds to a system that is fully disentangled-each variable isolated, with its value or free-variable relationship explicitly visible.

Everyday Analogies

  • Filing papers: REF is like stacking documents in neat piles, but still grouped. RREF is like sorting every document individually into labeled folders.
  • Solving a puzzle: REF gives you partial progress (pieces are grouped), while RREF finishes the puzzle so each piece is in its exact place.
  • Cooking: REF is like preparing ingredients into rough categories (vegetables chopped, meat trimmed). RREF is the final stage where every dish is cooked and plated, fully ready.

Why It Matters

  1. REF is the foundation of Gaussian elimination, the workhorse algorithm for solving systems.
  2. RREF gives complete clarity: unique representation of solution sets, revealing free and pivot variables.
  3. RREF underlies algorithms in computer algebra systems, symbolic solvers, and educational tools.
  4. Understanding these forms builds intuition for rank, null space, and solution structure.

Try It Yourself

  1. Reduce

    $$ \begin{bmatrix}
    2 & 4 & | & 6 \
    1 & 3 & | & 5
    \end{bmatrix} $$

    to REF, then RREF.

  2. Find the RREF of

    $$ \begin{bmatrix}
    1 & 1 & 1 & | & 3 \
    2 & 3 & 4 & | & 8 \
    1 & 2 & 3 & | & 5
    \end{bmatrix}. $$

  3. Explain why two different elimination sequences can lead to different REF but the same RREF.

  4. Challenge: Prove that every matrix has a unique RREF by considering the effect of row operations systematically.

Reaching row-echelon and reduced row-echelon forms transforms messy systems into structured ones, turning algebraic clutter into an organized path to solutions.

24. Pivots, Free Variables, and Leading Ones

When reducing a matrix to row-echelon or reduced row-echelon form, certain positions in the matrix take on a special importance. These are the pivots-the leading nonzero entries in each row. Around them, the entire solution structure of a linear system is organized. Understanding pivots, the variables they anchor, and the freedom that arises from non-pivot columns is essential to solving linear equations systematically.

What is a Pivot?

In row-echelon form, a pivot is the first nonzero entry in a row, moving from left to right. After scaling in reduced row-echelon form, each pivot is set to exactly 1.

Example:

$$ \begin{bmatrix}
1 & 2 & 0 & | & 5 \
0 & 1 & 3 & | & -2 \
0 & 0 & 0 & | & 0
\end{bmatrix} $$

  • Pivot in row 1: the 1 in column 1.
  • Pivot in row 2: the 1 in column 2.
  • Column 3 has no pivot.

Columns with pivots are pivot columns. Columns without pivots correspond to free variables.

Pivot Variables vs. Free Variables

  • Pivot variables: Variables that align with pivot columns. They are determined by the equations.
  • Free variables: Variables that align with non-pivot columns. They are unconstrained and can take arbitrary values.

Example:

$$ \begin{bmatrix}
1 & 0 & 2 & | & 3 \
0 & 1 & -1 & | & 4
\end{bmatrix}. $$

This corresponds to:

$$ x_1 + 2x_3 = 3, \quad x_2 - x_3 = 4. $$

Here:

  • $x_1$ and $x_2$ are pivot variables (from pivot columns 1 and 2).
  • $x_3$ is a free variable.

Thus, $x_1$ and $x_2$ depend on $x_3$:

$$ x_1 = 3 - 2x_3, \quad x_2 = 4 + x_3, \quad x_3 \text{ free}. $$

The solution set is infinite, described by the freedom in $x_3$.

Geometric Meaning

  • Pivot variables represent coordinates that are "pinned down."
  • Free variables correspond to directions along which the solution can extend infinitely.

In 2D:

  • If there is one pivot variable and one free variable, solutions form a line. In 3D:
  • Two pivots, one free → solutions form a line.
  • One pivot, two free → solutions form a plane.

Thus, the number of free variables determines the dimension of the solution set.

Rank and Free Variables

The number of pivot columns equals the rank of the matrix.

If the coefficient matrix $A$ is $m \times n$:

  • Rank = number of pivots.
  • Number of free variables = $n - \text{rank}(A)$.

This is the rank–nullity connection in action:

$$ \text{number of variables} = \text{rank} + \text{nullity}. $$

Step-by-Step Example

System:

$$ \begin{cases}
x + 2y + z = 4 \
2x + 5y + z = 7
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 2 & 1 & | & 4 \
2 & 5 & 1 & | & 7
\end{bmatrix}. $$

Reduce:

  • $R_2 \to R_2 - 2R_1$ →

    $$ \begin{bmatrix}
    1 & 2 & 1 & | & 4 \
    0 & 1 & -1 & | & -1
    \end{bmatrix}. $$

Now:

  • Pivot columns: 1 and 2 → variables $x, y$.
  • Free column: 3 → variable $z$.

Solution:

$$ x = 4 - 2y - z, \quad y = -1 + z, \quad z \text{ free}. $$

Substitute:

$$ (x, y, z) = (6 - 3z, ; -1 + z, ; z). $$

Solutions form a line in 3D parameterized by $z$.

Why Leading Ones Matter

In RREF, each pivot is scaled to 1, making it easy to isolate pivot variables. Without leading ones, equations may still be correct but harder to interpret.

For example:

$$ \begin{bmatrix}
2 & 0 & | & 6 \
0 & -3 & | & 9
\end{bmatrix} $$

becomes

$$ \begin{bmatrix}
1 & 0 & | & 3 \
0 & 1 & | & -3
\end{bmatrix}. $$

The solutions are immediately visible: $x=3, y=-3$.

Everyday Analogies

  • Team roles: Pivot variables are assigned jobs, while free variables can choose freely, shaping the group's flexibility.
  • Recipe ingredients: Pivots are required ingredients with fixed proportions, free variables are optional additions.
  • Construction plans: Pivot columns are load-bearing beams, free columns are spaces that can be filled in flexibly.

Why It Matters

  1. Identifying pivots shows which variables are determined and which are free.
  2. The number of pivots defines rank, a central concept in linear algebra.
  3. Free variables determine whether the system has a unique solution, infinitely many, or none.
  4. Leading ones in RREF give immediate transparency to the solution set.

Try It Yourself

  1. Reduce

    $$ \begin{bmatrix}
    1 & 3 & 1 & | & 5 \
    2 & 6 & 2 & | & 10
    \end{bmatrix} $$

    and identify pivot and free variables.

  2. For the system

    $$ x + y + z = 2, \quad 2x + 3y + 5z = 7, $$

    write the RREF and express the solution with free variables.

  3. Compute the rank and number of free variables of a 3×5 matrix with two pivot columns.

  4. Challenge: Show that if the number of pivots equals the number of variables, the system has either no solution or a unique solution, but never infinitely many.

Understanding pivots and free variables provides the key to classifying solution sets: unique, infinite, or none. This classification lies at the heart of solving linear systems.

25. Solving Consistent Systems

A system of linear equations is called consistent if it has at least one solution. Consistency is the first property to check when working with a system, because before worrying about uniqueness or parametrization, we must know whether a solution exists at all. This section explains how to recognize consistent systems, how to solve them using row-reduction, and how to describe their solutions in terms of pivots and free variables.

What Consistency Means

Given a system $A\mathbf{x} = \mathbf{b}$:

  • Consistent: At least one solution $\mathbf{x}$ satisfies the system.
  • Inconsistent: No solution exists.

Consistency depends on the relationship between the vector $\mathbf{b}$ and the column space of $A$:

$$ \mathbf{b} \in \text{Col}(A) \quad \iff \quad \text{system is consistent}. $$

If $\mathbf{b}$ cannot be written as a linear combination of the columns of $A$, the system has no solution.

Checking Consistency with Row Reduction

To test consistency, reduce the augmented matrix $[A | \mathbf{b}]$ to row-echelon form.

  • If you find a row of the form:

    $$ [0 ;; 0 ;; \dots ;; 0 ;|; c], \quad c \neq 0, $$

    then the system is inconsistent (contradiction: 0 = c).

  • If no such contradiction appears, the system is consistent.

Example 1: Consistent System with Unique Solution

System:

$$ \begin{cases}
x + y = 2 \
x - y = 0
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 1 & | & 2 \
1 & -1 & | & 0
\end{bmatrix}. $$

Row reduce:

  • $R_2 \to R_2 - R_1$:

    $$ \begin{bmatrix}
    1 & 1 & | & 2 \
    0 & -2 & | & -2
    \end{bmatrix}. $$

  • $R_2 \to -\tfrac{1}{2}R_2$:

    $$ \begin{bmatrix}
    1 & 1 & | & 2 \
    0 & 1 & | & 1
    \end{bmatrix}. $$

  • $R_1 \to R_1 - R_2$:

    $$ \begin{bmatrix}
    1 & 0 & | & 1 \
    0 & 1 & | & 1
    \end{bmatrix}. $$

Solution: $x = 1, ; y = 1$. Unique solution.

Example 2: Consistent System with Infinitely Many Solutions

System:

$$ \begin{cases}
x + y + z = 3 \
2x + 2y + 2z = 6
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 1 & 1 & | & 3 \
2 & 2 & 2 & | & 6
\end{bmatrix}. $$

Row reduce:

  • $R_2 \to R_2 - 2R_1$:

    $$ \begin{bmatrix}
    1 & 1 & 1 & | & 3 \
    0 & 0 & 0 & | & 0
    \end{bmatrix}. $$

No contradiction, so consistent. Solution:

$$ x = 3 - y - z, \quad y \text{ free}, \quad z \text{ free}. $$

The solution set is a plane in $\mathbb{R}^3$.

Example 3: Inconsistent System (for contrast)

System:

$$ \begin{cases}
x + y = 1 \
x + y = 2
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 1 & | & 1 \
1 & 1 & | & 2
\end{bmatrix}. $$

Row reduce:

  • $R_2 \to R_2 - R_1$:

    $$ \begin{bmatrix}
    1 & 1 & | & 1 \
    0 & 0 & | & 1
    \end{bmatrix}. $$

Contradiction: $0 = 1$. Inconsistent, no solution.

Geometric Interpretation of Consistency

  • In 2D:

    • Two lines intersect at a point → consistent, unique solution.
    • Two lines overlap → consistent, infinitely many solutions.
    • Two lines are parallel and distinct → inconsistent, no solution.
  • In 3D:

    • Three planes intersect at a point → unique solution.
    • Planes intersect along a line or coincide → infinitely many solutions.
    • Planes fail to meet (like a triangular "gap") → no solution.

Pivot Structure and Solutions

  • Unique solution: Every variable is a pivot variable (no free variables).
  • Infinitely many solutions: At least one free variable exists, but no contradiction.
  • No solution: Contradictory row appears in augmented matrix.

Everyday Analogies

  • Meeting point: If everyone agrees on the same café (unique solution), the plan is consistent. If they agree on any café along a certain street (infinite solutions), it's still consistent. If they give completely different addresses, there's no consistent plan.
  • Recipes: If the ingredients match exactly one way, unique solution. If they can vary while still yielding the dish, infinite solutions. If the instructions contradict, no dish is possible.

Why It Matters

  1. Consistency is the first checkpoint in solving systems.
  2. The classification into unique, infinite, or none underpins all of linear algebra.
  3. Understanding consistency ties algebra (row operations) to geometry (intersections of lines, planes, hyperplanes).
  4. These ideas scale: in data science and engineering, checking whether equations are consistent is equivalent to asking if a model fits observed data.

Try It Yourself

  1. Reduce the augmented matrix

    $$ \begin{bmatrix}
    1 & 2 & 1 & | & 5 \
    2 & 4 & 2 & | & 10 \
    3 & 6 & 3 & | & 15
    \end{bmatrix} $$

    and determine if the system is consistent.

  2. Classify the system as having unique, infinite, or no solutions:

    $$ \begin{cases}
    x + y + z = 2 \
    x - y + z = 0 \
    2x + 0y + 2z = 3
    \end{cases} $$

  3. Explain geometrically what it means when the augmented matrix has a contradictory row.

  4. Challenge: Show algebraically that a system is consistent if and only if $\mathbf{b}$ lies in the span of the columns of $A$.

Consistent systems mark the balance point between algebraic rules and geometric reality: they are where equations and space meet in harmony.

26. Detecting Inconsistency

Not every system of linear equations has a solution. Some are inconsistent, meaning the equations contradict one another and no vector $\mathbf{x}$ can satisfy them all at once. Detecting such inconsistency early is crucial: it saves wasted effort trying to solve an impossible system and reveals important geometric and algebraic properties.

What Inconsistency Looks Like Algebraically

Consider the system:

$$ \begin{cases}
x + y = 1 \
x + y = 3
\end{cases} $$

Clearly, the two equations cannot both be true. In augmented matrix form:

$$ \begin{bmatrix}
1 & 1 & | & 1 \
1 & 1 & | & 3
\end{bmatrix}. $$

Row reduction gives:

$$ \begin{bmatrix}
1 & 1 & | & 1 \
0 & 0 & | & 2
\end{bmatrix}. $$

The bottom row says $0 = 2$, a contradiction. This is the hallmark of inconsistency: a row of zeros in the coefficient part, with a nonzero constant in the augmented part.

General Rule for Detection

A system $A\mathbf{x} = \mathbf{b}$ is inconsistent if, after row reduction, the augmented matrix contains a row of the form:

$$ [0 ;; 0 ;; \dots ;; 0 ;|; c], \quad c \neq 0. $$

This indicates that all variables vanish from the equation, leaving an impossible statement like $0 = c$.

Example 1: Parallel Lines in 2D

$$ \begin{cases}
x + y = 2 \
2x + 2y = 5
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 1 & | & 2 \
2 & 2 & | & 5
\end{bmatrix}. $$

Row reduce:

  • $R_2 \to R_2 - 2R_1$:

$$ \begin{bmatrix}
1 & 1 & | & 2 \
0 & 0 & | & 1
\end{bmatrix}. $$

Contradiction: no solution. Geometrically, the two equations are parallel lines that never intersect.

Example 2: Contradictory Planes in 3D

$$ \begin{cases}
x + y + z = 1 \
2x + 2y + 2z = 2 \
x + y + z = 3
\end{cases} $$

The first and third equations already conflict: the same plane equation is forced to equal two different constants.

Augmented matrix reduces to:

$$ \begin{bmatrix}
1 & 1 & 1 & | & 1 \
0 & 0 & 0 & | & 0 \
0 & 0 & 0 & | & 2
\end{bmatrix}. $$

Contradiction: no solution. The "planes" fail to intersect in common.

Geometry of Inconsistency

  • In 2D: Inconsistent systems correspond to parallel lines with different intercepts.
  • In 3D: They correspond to planes that are parallel but offset, or planes arranged in a way that leaves a "gap" (no shared intersection).
  • In higher dimensions: Inconsistency means the target vector $\mathbf{b}$ lies outside the column space of $A$.

Rank Test for Consistency

Another way to detect inconsistency is using ranks.

  • Let $\text{rank}(A)$ be the number of pivots in the coefficient matrix.
  • Let $\text{rank}([A|\mathbf{b}])$ be the number of pivots in the augmented matrix.

Rule:

  • If $\text{rank}(A) = \text{rank}([A|\mathbf{b}])$, the system is consistent.
  • If $\text{rank}(A) < \text{rank}([A|\mathbf{b}])$, the system is inconsistent.

This rank condition is fundamental and works in any dimension.

Everyday Analogies

  • Meeting schedules: If one friend says "meet at 2pm" and another says "meet at 2pm and 3pm simultaneously," the instructions contradict-no meeting possible.
  • Construction blueprints: If two architects specify identical walls but with different lengths, the building plan is impossible.
  • Cooking instructions: If one step requires "boil pasta until firm" and another says "the same pasta must already be raw," the recipe cannot be carried out.

Why It Matters

  1. Inconsistency reveals overdetermined or contradictory data in real problems (physics, engineering, statistics).
  2. The ability to detect inconsistency quickly through row reduction or rank saves computation.
  3. It connects geometry (non-intersecting spaces) with algebra (contradictory rows).
  4. It prepares the way for least-squares methods, where inconsistent systems are approximated instead of solved exactly.

Try It Yourself

  1. Reduce the augmented matrix

$$ \begin{bmatrix}
1 & -1 & | & 2 \
2 & -2 & | & 5
\end{bmatrix} $$

and decide if the system is consistent.

  1. Show geometrically why the system

$$ x + y = 0, \quad x + y = 1 $$

is inconsistent.

  1. Use the rank test to check consistency of

$$ \begin{cases}
x + y + z = 2 \
2x + 2y + 2z = 4 \
3x + 3y + 3z = 5
\end{cases} $$

  1. Challenge: Explain why $\text{rank}(A) < \text{rank}([A|\mathbf{b}])$ implies inconsistency, using the concept of the column space.

Detecting inconsistency is not just about spotting contradictions-it connects algebra, geometry, and linear transformations, showing exactly when a system cannot possibly fit together.

27. Gaussian Elimination by Hand

Gaussian elimination is the systematic procedure for solving systems of linear equations by using row operations to simplify the augmented matrix. The goal is to transform the system into row-echelon form (REF) and then use back substitution to find the solutions. This method is the backbone of linear algebra computations and is the foundation of most computer algorithms for solving linear systems.

The Big Idea

  1. Represent the system as an augmented matrix.
  2. Use row operations to eliminate variables step by step, moving left to right, top to bottom.
  3. Stop when the matrix is in REF.
  4. Solve the triangular system by back substitution.

Step-by-Step Recipe

Suppose we have $n$ equations with $n$ unknowns.

  1. Choose a pivot in the first column (a nonzero entry). If needed, swap rows to bring a nonzero entry to the top.
  2. Eliminate below the pivot by subtracting multiples of the pivot row from lower rows so that all entries below the pivot become zero.
  3. Move to the next row and next column, pick the next pivot, and repeat elimination.
  4. Continue until all pivots are in stair-step form (REF).
  5. Use back substitution to solve for the unknowns starting from the bottom row.

Example 1: A 2×2 System

System:

$$ \begin{cases}
x + 2y = 5 \
3x + 4y = 11
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 2 & | & 5 \
3 & 4 & | & 11
\end{bmatrix}. $$

  1. Pivot at (1,1) = 1.

  2. Eliminate below: $R_2 \to R_2 - 3R_1$.

    $$ \begin{bmatrix}
    1 & 2 & | & 5 \
    0 & -2 & | & -4
    \end{bmatrix}. $$

  3. Back substitution: From row 2: $-2y = -4 \implies y = 2$. Substitute into row 1: $x + 2(2) = 5 \implies x = 1$.

Solution: $(x, y) = (1, 2)$.

Example 2: A 3×3 System

System:

$$ \begin{cases}
x + y + z = 6 \
2x + 3y + z = 14 \
x - y + 2z = 2
\end{cases} $$

Augmented matrix:

$$ \begin{bmatrix}
1 & 1 & 1 & | & 6 \
2 & 3 & 1 & | & 14 \
1 & -1 & 2 & | & 2
\end{bmatrix}. $$

Step 1: Pivot at (1,1). Eliminate below:

  • $R_2 \to R_2 - 2R_1$.
  • $R_3 \to R_3 - R_1$.

$$ \begin{bmatrix}
1 & 1 & 1 & | & 6 \
0 & 1 & -1 & | & 2 \
0 & -2 & 1 & | & -4
\end{bmatrix}. $$

Step 2: Pivot at (2,2). Eliminate below: $R_3 \to R_3 + 2R_2$.

$$ \begin{bmatrix}
1 & 1 & 1 & | & 6 \
0 & 1 & -1 & | & 2 \
0 & 0 & -1 & | & 0
\end{bmatrix}. $$

Step 3: Pivot at (3,3). Scale row: $R_3 \to -R_3$.

$$ \begin{bmatrix}
1 & 1 & 1 & | & 6 \
0 & 1 & -1 & | & 2 \
0 & 0 & 1 & | & 0
\end{bmatrix}. $$

Back substitution:

  • From row 3: $z = 0$.
  • From row 2: $y - z = 2 \implies y = 2$.
  • From row 1: $x + y + z = 6 \implies x = 4$.

Solution: $(x, y, z) = (4, 2, 0)$.

Why Gaussian Elimination Always Works

  • Each step reduces the number of variables in the lower equations.
  • Pivoting ensures stability (swap rows to avoid dividing by zero).
  • The algorithm either produces a triangular system (solvable by substitution) or reveals inconsistency (contradictory row).

Geometric Interpretation

  • Elimination corresponds to progressively restricting the solution set:

    • First equation → a plane in $\mathbb{R}^3$.
    • Add second equation → intersection becomes a line.
    • Add third equation → intersection becomes a point (unique solution) or vanishes (inconsistent).

Everyday Analogies

  • Cleaning a desk: Start with a mess (equations mixed together), then eliminate clutter one step at a time until everything is sorted neatly into piles.
  • Cooking: Elimination is like reducing a sauce-boiling away the excess until only the essence remains.
  • Detective work: Each equation eliminates possibilities, narrowing down suspects until only the guilty party (the solution) remains.

Why It Matters

  1. Gaussian elimination is the foundation for solving systems by hand and by computer.
  2. It reveals whether a system is consistent and if solutions are unique or infinite.
  3. It is the starting point for advanced methods like LU decomposition, QR factorization, and numerical solvers.
  4. It shows the interplay between algebra (row operations) and geometry (intersections of subspaces).

Try It Yourself

  1. Solve the system

    $$ \begin{cases}
    2x + y = 7 \
    4x + 3y = 15
    \end{cases} $$

    using Gaussian elimination.

  2. Reduce

    $$ \begin{bmatrix}
    1 & 2 & -1 & | & 3 \
    3 & 8 & 1 & | & 12 \
    2 & 6 & 3 & | & 11
    \end{bmatrix} $$

    to REF and solve.

  3. Practice with a system that has infinitely many solutions:

    $$ x + y + z = 4, \quad 2x + 2y + 2z = 8. $$

  4. Challenge: Explain why Gaussian elimination always terminates in at most $n$ pivot steps for an $n \times n$ system.

Gaussian elimination transforms the complexity of many equations into an orderly process, making the hidden structure of solutions visible step by step.

28. Back Substitution and Solution Sets

Once Gaussian elimination reduces a system to row-echelon form (REF), the next step is to actually solve for the unknowns. This process is called back substitution: we begin with the bottom equation (which involves the fewest variables) and work our way upward, solving step by step. Back substitution is what converts the structured triangular system into explicit solutions.

The Structure of Row-Echelon Form

A system in REF looks like this:

$$ \begin{bmatrix}

  • & * & * & * & | & * \
    0 & * & * & * & | & * \
    0 & 0 & * & * & | & * \
    0 & 0 & 0 & * & | & *
    \end{bmatrix} $$

  • Each row corresponds to an equation with fewer variables than the row above.

  • The bottom equation has only one or two variables.

  • This triangular form makes it possible to solve "from the bottom up."

Step-by-Step Example: Unique Solution

System after elimination:

$$ \begin{bmatrix}
1 & 2 & -1 & | & 3 \
0 & 1 & 2 & | & 4 \
0 & 0 & 1 & | & 2
\end{bmatrix}. $$

This corresponds to:

$$ \begin{cases}
x + 2y - z = 3 \
y + 2z = 4 \
z = 2
\end{cases} $$

  1. From the last equation: $z = 2$.
  2. Substitute into the second: $y + 2(2) = 4 \implies y = 0$.
  3. Substitute into the first: $x + 2(0) - 2 = 3 \implies x = 5$.

Solution: $(x, y, z) = (5, 0, 2)$.

Infinite Solutions with Free Variables

Not all systems reduce to unique solutions. If there are free variables (non-pivot columns), back substitution expresses pivot variables in terms of free ones.

Example:

$$ \begin{bmatrix}
1 & 2 & 1 & | & 4 \
0 & 1 & -1 & | & 1 \
0 & 0 & 0 & | & 0
\end{bmatrix}. $$

Equations:

$$ \begin{cases}
x + 2y + z = 4 \
y - z = 1
\end{cases} $$

  1. From row 2: $y = 1 + z$.
  2. From row 1: $x + 2(1 + z) + z = 4 \implies x = 2 - 3z$.

Solution set:

$$ (x, y, z) = (2 - 3t, ; 1 + t, ; t), \quad t \in \mathbb{R}. $$

Here $z = t$ is the free variable. The solutions form a line in 3D.

General Solution Structure

For a consistent system:

  1. Unique solution → every variable is a pivot variable (no free variables).
  2. Infinitely many solutions → some free variables remain. The solution set is parametrized by these variables and forms a line, plane, or higher-dimensional subspace.
  3. No solution → contradiction discovered earlier, so back substitution is impossible.

Geometric Meaning

  • Unique solution → a single intersection point of lines/planes.
  • Infinite solutions → overlapping subspaces (e.g., two planes intersecting in a line).
  • Back substitution describes the exact shape of this intersection.

Example: Parametric Vector Form

For the infinite-solution example above:

$$ (x, y, z) = (2, 1, 0) + t(-3, 1, 1). $$

This expresses the solution set as a base point plus a direction vector, making the geometry clear.

Everyday Analogies

  • Stacked tasks: Back substitution is like solving a sequence of tasks where each depends on the result of the one below it.
  • Domino effect: Once the last domino falls (the last variable solved), the rest fall in sequence.
  • Filling out a form: Each field depends on earlier answers; once the final field is fixed, the others can be determined in order.

Why It Matters

  1. Back substitution turns row-echelon form into concrete answers.
  2. It distinguishes unique vs. infinite solutions.
  3. It provides a systematic method usable by hand for small systems and forms the basis of computer algorithms for large ones.
  4. It reveals the structure of solution sets-whether a point, line, plane, or higher-dimensional object.

Try It Yourself

  1. Solve by back substitution:

$$ \begin{bmatrix}
1 & -1 & 2 & | & 3 \
0 & 1 & 3 & | & 5 \
0 & 0 & 1 & | & 2
\end{bmatrix}. $$

  1. Reduce and solve:

$$ x + y + z = 2, \quad 2x + 2y + 2z = 4. $$

  1. Express the solution set of the above system in parametric vector form.

  2. Challenge: For a 4×4 system with two free variables, explain why the solution set forms a plane in $\mathbb{R}^4$.

Back substitution completes the elimination process, translating triangular structure into explicit solutions, and shows how algebra and geometry meet in the classification of solution sets.

29. Rank and Its First Meaning

The concept of rank lies at the heart of linear algebra. It connects the algebra of solving systems, the geometry of subspaces, and the structure of matrices into one unifying idea. Rank measures the amount of independent information in a matrix: how many rows or columns carry unique directions instead of being repetitions or combinations of others.

Definition of Rank

The rank of a matrix $A$ is the number of pivots in its row-echelon form. Equivalently, it is:

  • The dimension of the column space (number of independent columns).
  • The dimension of the row space (number of independent rows).

All these definitions agree.

First Encounter with Rank: Pivot Counting

When solving a system with Gaussian elimination:

  • Every pivot corresponds to one determined variable.
  • The number of pivots = the rank.
  • The number of free variables = total variables – rank.

Example:

$$ \begin{bmatrix}
1 & 2 & 1 & | & 4 \
0 & 1 & -1 & | & 2 \
0 & 0 & 0 & | & 0
\end{bmatrix}. $$

Here, there are 2 pivots. So:

  • Rank = 2.
  • With 3 variables total, there is 1 free variable.

Rank in Terms of Independence

A set of vectors is linearly independent if none can be expressed as a combination of the others.

  • The rank of a matrix tells us how many independent rows or columns it has.
  • If some columns are combinations of others, they do not increase the rank.

Example:

$$ \begin{bmatrix}
1 & 2 & 3 \
2 & 4 & 6 \
3 & 6 & 9
\end{bmatrix}. $$

Here, each row is a multiple of the first. Rank = 1, since only one independent row/column direction exists.

Rank and Solutions of Systems

Consider $A\mathbf{x} = \mathbf{b}$.

  • If $\text{rank}(A) = \text{rank}([A|\mathbf{b}])$, the system is consistent.
  • If not, inconsistent.
  • If rank = number of variables, the system has a unique solution.
  • If rank < number of variables, there are infinitely many solutions.

Thus, rank classifies solution sets.

Rank and Geometry

Rank tells us the dimension of the subspace spanned by rows or columns.

  • Rank 1: all information lies along a line.
  • Rank 2: lies in a plane.
  • Rank 3: fills 3D space.

Example:

  • In $\mathbb{R}^3$, a matrix of rank 2 has columns spanning a plane through the origin.
  • A matrix of rank 1 has all columns on a single line.

Rank and Row vs. Column View

It is a remarkable fact that the number of independent rows = number of independent columns. This is not obvious at first glance, but it is always true. So we can define rank either by rows or by columns-it makes no difference.

Everyday Analogies

  • Library books: If three books say the same thing in different words, only one adds new knowledge. The others are redundant. Rank = number of genuinely independent books.
  • Recipes: If you have five recipes but four are just scaled versions of the first, you really only have one distinct recipe. Rank = 1.
  • Work team: If every team member repeats what another says, the effective number of independent voices is low. Rank measures how many unique contributions exist.

Why It Matters

  1. Rank is the bridge between algebra and geometry: pivots ↔ dimension.
  2. It classifies solutions to systems of equations.
  3. It measures redundancy in data (important in statistics, machine learning, signal processing).
  4. It prepares the way for advanced concepts like nullity, rank–nullity theorem, and singular value decomposition.

Try It Yourself

  1. Find the rank of

    $$ \begin{bmatrix}
    1 & 2 & 3 \
    2 & 4 & 5 \
    3 & 6 & 8
    \end{bmatrix}. $$

  2. Solve the system

    $$ x + y + z = 2, \quad 2x + 2y + 2z = 4, $$

    and identify the rank of the coefficient matrix.

  3. In $\mathbb{R}^3$, what is the geometric meaning of a 3×3 matrix of rank 2?

  4. Challenge: Prove that the row rank always equals the column rank by considering the echelon form of the matrix.

Rank is the first truly unifying concept in linear algebra: it tells us how much independent structure a matrix contains and sets the stage for understanding spaces, dimensions, and transformations.

30. LU Factorization

Gaussian elimination not only solves systems but also reveals a deeper structure: many matrices can be factored into simpler pieces. One of the most useful is the LU factorization, where a matrix $A$ is written as the product of a lower-triangular matrix $L$ and an upper-triangular matrix $U$. This factorization captures all the elimination steps in a compact form and allows systems to be solved efficiently.

What is LU Factorization?

If $A$ is an $n \times n$ matrix, then

$$ A = LU, $$

where:

  • $L$ is lower-triangular (entries below diagonal may be nonzero, diagonal entries = 1).
  • $U$ is upper-triangular (entries above diagonal may be nonzero).

This means:

  • $U$ stores the result of elimination (the triangular system).
  • $L$ records the multipliers used during elimination.

Example: 2×2 Case

Take

$$ A = \begin{bmatrix}
2 & 3 \
4 & 7
\end{bmatrix}. $$

Elimination: $R_2 \to R_2 - 2R_1$.

  • Multiplier = 2 (used to eliminate entry 4).

  • Resulting $U$:

    $$ U = \begin{bmatrix}
    2 & 3 \
    0 & 1
    \end{bmatrix}. $$

  • $L$:

    $$ L = \begin{bmatrix}
    1 & 0 \
    2 & 1
    \end{bmatrix}. $$

Check:

$$ LU = \begin{bmatrix}
1 & 0 \
2 & 1
\end{bmatrix}
\begin{bmatrix}
2 & 3 \
0 & 1
\end{bmatrix}
= \begin{bmatrix}
2 & 3 \
4 & 7
\end{bmatrix} = A. $$

Example: 3×3 Case

$$ A = \begin{bmatrix}
2 & 1 & 1 \
4 & -6 & 0 \
-2 & 7 & 2
\end{bmatrix}. $$

Step 1: Eliminate below pivot (row 1).

  • Multiplier $m_{21} = 4/2 = 2$.
  • Multiplier $m_{31} = -2/2 = -1$.

Step 2: Eliminate below pivot in column 2.

  • After substitutions, multipliers and pivots are collected.

Result:

$$ L = \begin{bmatrix}
1 & 0 & 0 \
2 & 1 & 0 \
-1 & -1 & 1
\end{bmatrix}, \quad
U = \begin{bmatrix}
2 & 1 & 1 \
0 & -8 & -2 \
0 & 0 & 1
\end{bmatrix}. $$

Thus $A = LU$.

Solving Systems with LU

Suppose $Ax = b$. If $A = LU$:

  1. Solve $Ly = b$ by forward substitution (since $L$ is lower-triangular).
  2. Solve $Ux = y$ by back substitution (since $U$ is upper-triangular).

This two-step process is much faster than elimination from scratch each time, especially if solving multiple systems with the same $A$ but different $b$.

Pivoting and Permutations

Sometimes elimination requires row swaps (to avoid division by zero or instability). Then factorization is written as:

$$ PA = LU, $$

where $P$ is a permutation matrix recording the row swaps. This is the practical form used in numerical computing.

Applications of LU Factorization

  1. Efficient solving: Multiple right-hand sides $Ax = b$. Compute $LU$ once, reuse for each $b$.
  2. Determinants: $\det(A) = \det(L)\det(U)$. Since diagonals of $L$ are 1, this reduces to the product of the diagonal of $U$.
  3. Matrix inverse: By solving $Ax = e_i$ for each column $e_i$, we can compute $A^{-1}$ efficiently with LU.
  4. Numerical methods: LU is central in scientific computing, engineering simulations, and optimization.

Geometric Meaning

LU decomposition separates the elimination process into:

  • $L$: shear transformations (adding multiples of rows).
  • $U$: scaling and alignment into triangular form.

Together, they represent the same linear transformation as $A$, but decomposed into simpler building blocks.

Everyday Analogies

  • Recipe preparation: $L$ is the prep work (chopping, mixing), while $U$ is the final cooking (arranging in order). Together, they produce the finished dish.
  • Assembly line: $L$ records the sequence of adjustments, $U$ the final structured product.
  • Team project: $L$ shows who contributed what during the work process, $U$ is the neatly organized final report.

Why It Matters

  1. LU factorization compresses elimination into a reusable format.
  2. It is a cornerstone of numerical linear algebra and used in almost every solver.
  3. It links computation (efficient algorithms) with theory (factorization of transformations).
  4. It introduces the broader idea that matrices can be broken into simple, interpretable parts.

Try It Yourself

  1. Factor

    $$ A = \begin{bmatrix}
    1 & 2 \
    3 & 8
    \end{bmatrix} $$

    into $LU$.

  2. Solve

    $$ \begin{bmatrix}
    2 & 1 \
    6 & 3
    \end{bmatrix}
    \begin{bmatrix}
    x \ y
    \end{bmatrix} =
    \begin{bmatrix}
    5 \ 15
    \end{bmatrix} $$

    using LU decomposition.

  3. Compute $\det(A)$ for

    $$ A = \begin{bmatrix}
    2 & 1 & 1 \
    4 & -6 & 0 \
    -2 & 7 & 2
    \end{bmatrix} $$

    by using its LU factorization.

  4. Challenge: Prove that if $A$ is invertible, then it has an LU factorization (possibly after row swaps).

LU factorization organizes elimination into a powerful tool: compact, efficient, and deeply tied to both the theory and practice of linear algebra.

Closing

Paths diverge or merge,
pivots mark the way forward,
truth distilled in rows.

Chapter 4. Vector spaces and subspaces

Opening

Endless skies expand,
spaces within spaces grow,
freedom takes its shape.

31. Axioms of Vector Spaces

Up to now, we have worked with vectors in $\mathbb{R}^2$, $\mathbb{R}^3$, and higher-dimensional Euclidean spaces. But the true power of linear algebra comes from abstracting away from coordinates. A vector space is not tied to arrows in physical space-it is any collection of objects that behave like vectors, provided they satisfy certain rules. These rules are called the axioms of vector spaces.

The Idea of a Vector Space

A vector space is a set $V$ equipped with two operations:

  1. Vector addition: Combine two vectors in $V$ to get another vector in $V$.
  2. Scalar multiplication: Multiply a vector in $V$ by a scalar (a number from a field, usually $\mathbb{R}$ or $\mathbb{C}$).

The magic is that as long as certain rules (axioms) hold, the objects in $V$ can be treated as vectors. They need not be arrows or coordinate lists-they could be polynomials, functions, matrices, or sequences.

The Eight Axioms

Let $u, v, w \in V$ (vectors) and $a, b \in \mathbb{R}$ (scalars). The axioms are:

  1. Closure under addition: $u + v \in V$.
  2. Commutativity of addition: $u + v = v + u$.
  3. Associativity of addition: $(u + v) + w = u + (v + w)$.
  4. Existence of additive identity: There exists a zero vector $0 \in V$ such that $v + 0 = v$.
  5. Existence of additive inverses: For every $v$, there is $-v$ such that $v + (-v) = 0$.
  6. Closure under scalar multiplication: $a v \in V$.
  7. Distributivity of scalar multiplication over vector addition: $a(u + v) = au + av$.
  8. Distributivity of scalar multiplication over scalar addition: $(a + b)v = av + bv$.
  9. Associativity of scalar multiplication: $a(bv) = (ab)v$.
  10. Existence of multiplicative identity: $1 \cdot v = v$.

(These are sometimes listed as eight, with some grouped together, but the essence is the same.)

Examples of Vector Spaces

  1. Euclidean spaces: $\mathbb{R}^n$ with standard addition and scalar multiplication.
  2. Polynomials: The set of all polynomials with real coefficients, $\mathbb{R}[x]$.
  3. Functions: The set of all continuous functions on $[0,1]$, with addition of functions and scalar multiplication.
  4. Matrices: The set of all $m \times n$ matrices with real entries.
  5. Sequences: The set of all infinite real sequences $(a_1, a_2, \dots)$.

All of these satisfy the vector space axioms.

Non-Examples

  1. The set of natural numbers $\mathbb{N}$ is not a vector space (no additive inverses).
  2. The set of positive real numbers $\mathbb{R}^+$ is not a vector space (not closed under scalar multiplication with negative numbers).
  3. The set of polynomials of degree exactly 2 is not a vector space (not closed under addition: $x^2 + x^2 = 2x^2$ is still degree 2, but $x^2 - x^2 = 0$, which is degree 0, not allowed).

These examples show why the axioms are essential: without them, the structure breaks.

The Zero Vector

Every vector space must contain a zero vector. This is not optional. It is the "do nothing" element for addition. In $\mathbb{R}^n$, this is $(0,0,\dots,0)$. In polynomials, it is the zero polynomial. In function spaces, it is the function $f(x) = 0$.

Additive Inverses

For every vector $v$, we require $-v$. This ensures that equations like $u+v=w$ can always be rearranged to $u=w-v$. Without additive inverses, solving linear equations would not work.

Scalars and Fields

Scalars come from a field: usually the real numbers $\mathbb{R}$ or the complex numbers $\mathbb{C}$. The choice of scalars matters:

  • Over $\mathbb{R}$, a polynomial space is different from over $\mathbb{C}$.
  • Over finite fields (like integers modulo $p$), vector spaces exist in discrete mathematics and coding theory.

Geometric Interpretation

  • The axioms guarantee that vectors can be added and scaled in predictable ways.
  • Closure ensures the space is "self-contained."
  • Additive inverses ensure symmetry: every direction can be reversed.
  • Distributivity ensures consistency between scaling and addition.

Together, these rules make vector spaces stable and reliable mathematical objects.

Everyday Analogies

  • Language: Words form sentences by rules of grammar. Vector spaces are sets where addition and scaling follow strict grammar-like rules.
  • Music: Notes combine (addition) and change pitch (scaling). A musical space is meaningful only if these operations stay within the system.
  • Construction: Bricks and mortar can be combined (addition) and scaled (larger or smaller structures), but only when rules of stability are followed.

Why It Matters

  1. Vector spaces unify many areas of math under a single framework.
  2. They generalize $\mathbb{R}^n$ to functions, polynomials, and beyond.
  3. The axioms guarantee that all the tools of linear algebra-span, basis, dimension, linear maps-apply.
  4. Recognizing vector spaces in disguise is a major step in advanced math and physics.

Try It Yourself

  1. Verify that the set of all 2×2 matrices is a vector space under matrix addition and scalar multiplication.
  2. Show that the set of polynomials of degree at most 3 is a vector space, but the set of polynomials of degree exactly 3 is not.
  3. Check whether the set of all even functions $f(-x) = f(x)$ is a vector space.
  4. Challenge: Consider the set of all differentiable functions $f$ on $[0,1]$. Show that this set forms a vector space under the usual operations.

The axioms of vector spaces provide the foundation on which the rest of linear algebra is built. Everything that follows-subspaces, independence, basis, dimension-grows naturally from this formal framework.

32. Subspaces, Column Space, and Null Space

Once the idea of a vector space is in place, the next step is to recognize smaller vector spaces that live inside bigger ones. These are called subspaces. Subspaces are central in linear algebra because they reveal the internal structure of matrices and linear systems. Two special subspaces-the column space and the null space-play particularly important roles.

What Is a Subspace?

A subspace $W$ of a vector space $V$ is a subset of $V$ that is itself a vector space under the same operations. To qualify as a subspace, $W$ must satisfy:

  1. The zero vector $0$ is in $W$.
  2. If $u, v \in W$, then $u+v \in W$ (closed under addition).
  3. If $u \in W$ and $c$ is a scalar, then $cu \in W$ (closed under scalar multiplication).

That's it-no further checking of all ten vector space axioms is needed, because those are inherited from $V$.

Simple Examples of Subspaces

  • In $\mathbb{R}^3$:

    • A line through the origin is a 1-dimensional subspace.
    • A plane through the origin is a 2-dimensional subspace.
    • The whole space itself is a subspace.
    • The trivial subspace ${0}$ contains only the zero vector.
  • In the space of polynomials:

    • All polynomials of degree ≤ 3 form a subspace.
    • All polynomials with zero constant term form a subspace.
  • In function spaces:

    • All continuous functions on $[0,1]$ form a subspace of all functions on $[0,1]$.
    • All solutions to a linear differential equation form a subspace.

The Column Space of a Matrix

Given a matrix $A$, the column space is the set of all linear combinations of its columns. Formally,

$$ C(A) = { A\mathbf{x} : \mathbf{x} \in \mathbb{R}^n }. $$

  • The column space lives inside $\mathbb{R}^m$ if $A$ is $m \times n$.
  • It represents all possible outputs of the linear transformation defined by $A$.
  • Its dimension is equal to the rank of $A$.

Example:

$$ A = \begin{bmatrix}
1 & 2 \
2 & 4 \
3 & 6
\end{bmatrix}. $$

The second column is just twice the first. So the column space is all multiples of $\begin{bmatrix}1 \ 2 \ 3\end{bmatrix}$, which is a line in $\mathbb{R}^3$. Rank = 1.

The Null Space of a Matrix

The null space (or kernel) of a matrix $A$ is the set of all vectors $\mathbf{x}$ such that

$$ A\mathbf{x} = 0. $$

  • It lives in $\mathbb{R}^n$ if $A$ is $m \times n$.
  • It represents the "invisible" directions that collapse to zero under the transformation.
  • Its dimension is the nullity of $A$.

Example:

$$ A = \begin{bmatrix}
1 & 2 & 3 \
4 & 5 & 6
\end{bmatrix}. $$

Solve $A\mathbf{x} = 0$. This yields a null space spanned by one vector, meaning it is a line through the origin in $\mathbb{R}^3$.

Column Space vs. Null Space

  • Column space: describes outputs ($y$-values that can be reached).
  • Null space: describes hidden inputs (directions that vanish).

Together, they capture the full behavior of a matrix.

Geometric Interpretation

  • In $\mathbb{R}^3$, the column space could be a plane or a line inside 3D space.
  • The null space is orthogonal (in a precise sense) to the row space, which we'll study later.
  • Understanding both spaces gives a complete picture of how the matrix transforms vectors.

Everyday Analogies

  • Column space as achievements: Think of the matrix as a machine. The column space is the set of all things the machine can produce.
  • Null space as wasted effort: Any input vector in the null space produces nothing at all-like pressing buttons on a broken remote control.
  • Teamwork analogy: If each team member contributes along independent directions, the column space is large. If some repeat others' work, redundancy reduces the column space.

Why It Matters

  1. Subspaces are the natural habitat of linear algebra: almost everything happens inside them.
  2. The column space explains what systems $Ax=b$ are solvable.
  3. The null space explains why some systems have multiple solutions (free variables).
  4. These ideas extend to advanced topics like eigenvectors, SVD, and differential equations.

Try It Yourself

  1. Show that the set ${(x,y,0) : x,y \in \mathbb{R}}$ is a subspace of $\mathbb{R}^3$.

  2. For

    $$ A = \begin{bmatrix}
    1 & 2 & 3 \
    0 & 0 & 0 \
    1 & 2 & 3
    \end{bmatrix}, $$

    find the column space and its dimension.

  3. For the same $A$, compute the null space and its dimension.

  4. Challenge: Prove that the null space of $A$ is always a subspace of $\mathbb{R}^n$.

Subspaces-especially the column space and null space-are the first glimpse of the hidden geometry inside every matrix, showing us which directions survive and which vanish.

33. Span and Generating Sets

The idea of a span captures the simplest and most powerful way to build new vectors from old ones: by taking linear combinations. A span is not just a set of scattered points but a structured, complete collection of all combinations of a given set of vectors. Understanding span leads directly to the concepts of bases, dimension, and the structure of subspaces.

Definition of Span

Given vectors $v_1, v_2, \dots, v_k \in V$, the span of these vectors is

$$ \text{span}{v_1, v_2, \dots, v_k} = {a_1 v_1 + a_2 v_2 + \dots + a_k v_k : a_i \in \mathbb{R}}. $$

  • A span is the set of all possible linear combinations of the vectors.
  • It is always a subspace.
  • The given vectors are called a generating set.

Simple Examples

  1. In $\mathbb{R}^2$:

    • Span of $(1,0)$ = all multiples of the x-axis (a line).
    • Span of $(1,0)$ and $(0,1)$ = the entire plane $\mathbb{R}^2$.
    • Span of $(1,0)$ and $(2,0)$ = still the x-axis, since the second vector is redundant.
  2. In $\mathbb{R}^3$:

    • Span of a single vector = a line.
    • Span of two independent vectors = a plane through the origin.
    • Span of three independent vectors = the whole space $\mathbb{R}^3$.

Span as Coverage

  • If you think of vectors as "directions," the span is everything you can reach by walking in those directions, with any step lengths (scalars) allowed.
  • If you only have one direction, you can walk back and forth on a line.
  • With two independent directions, you can sweep out a plane.
  • With three independent directions in 3D, you can move anywhere.

Generating Sets

A set of vectors is a generating set (or spanning set) for a subspace if their span equals that subspace.

  • Example: ${(1,0), (0,1)}$ generates $\mathbb{R}^2$.
  • Example: ${(1,0,0), (0,1,0), (0,0,1)}$ generates $\mathbb{R}^3$.
  • Example: The columns of a matrix generate its column space.

Different generating sets can span the same space. Some may be redundant, others minimal. Later, the concept of a basis refines this idea.

Redundancy in Spanning Sets

  • If one vector is a linear combination of others, it does not enlarge the span.
  • Example: In $\mathbb{R}^2$, ${(1,0), (0,1), (1,1)}$ spans the same space as ${(1,0), (0,1)}$.
  • Eliminating redundancy leads to a more efficient generating set.

Span and Linear Systems

Consider the system $Ax=b$.

  • The question "Is there a solution?" is equivalent to "Is $b$ in the span of the columns of $A$?"
  • Thus, span provides the geometric language for solvability.

Everyday Analogies

  • Languages: If you have enough letters (generators), you can spell any word (vector). Redundant letters don't add power (extra copies of "A" don't help).
  • Recipes: Ingredients are like generators; the span is all dishes you can cook from them. Some ingredients are essential, others can be left out.
  • Travel directions: If you only know how to go north, you're stuck on a line. Add east, and you can reach anywhere on the map.

Why It Matters

  1. Span is the foundation for defining subspaces generated by vectors.
  2. It connects directly to solvability of linear equations.
  3. It introduces the notion of redundancy, preparing for bases and independence.
  4. It generalizes naturally to function spaces and abstract vector spaces.

Try It Yourself

  1. Find the span of ${(1,2), (2,4)}$ in $\mathbb{R}^2$.
  2. Show that the vectors $(1,0,1), (0,1,1), (1,1,2)$ span only a plane in $\mathbb{R}^3$.
  3. Decide whether $(1,2,3)$ is in the span of $(1,0,1)$ and $(0,1,2)$.
  4. Challenge: Prove that the set of all polynomials ${1, x, x^2, \dots}$ spans the space of all polynomials.

The concept of span transforms our perspective: instead of focusing on single vectors, we see the entire landscape of possibilities they generate.

34. Linear Independence and Dependence

Having introduced span and generating sets, the natural question arises: when are the vectors in a spanning set truly necessary, and when are some redundant? This leads to the idea of linear independence. It is the precise way to distinguish between essential vectors (those that add new directions) and dependent vectors (those that can be expressed in terms of others).

Definition of Linear Independence

A set of vectors ${v_1, v_2, \dots, v_k}$ is linearly independent if the only solution to

$$ a_1 v_1 + a_2 v_2 + \dots + a_k v_k = 0 $$

is

$$ a_1 = a_2 = \dots = a_k = 0. $$

If there exists a nontrivial solution (some $a_i \neq 0$), then the vectors are linearly dependent.

Intuition

  • Independent vectors point in genuinely different directions.
  • Dependent vectors overlap: at least one can be built from the others.
  • In terms of span: removing a dependent vector does not shrink the span, because it adds no new direction.

Simple Examples in $\mathbb{R}^2$

  1. $(1,0)$ and $(0,1)$ are independent.

    • Equation $a(1,0) + b(0,1) = (0,0)$ forces $a = b = 0$.
  2. $(1,0)$ and $(2,0)$ are dependent.

    • Equation $2(1,0) - (2,0) = (0,0)$ shows dependence.
  3. Any set of 3 vectors in $\mathbb{R}^2$ is dependent, since the dimension of the space is 2.

Examples in $\mathbb{R}^3$

  1. $(1,0,0), (0,1,0), (0,0,1)$ are independent.
  2. $(1,2,3), (2,4,6)$ are dependent, since the second is just 2× the first.
  3. $(1,0,1), (0,1,1), (1,1,2)$ are dependent: the third is the sum of the first two.

Detecting Independence with Matrices

Put the vectors as columns in a matrix. Perform row reduction:

  • If every column has a pivot → the set is independent.
  • If some column is free → the set is dependent.

Example:

$$ \begin{bmatrix}
1 & 2 & 3 \
0 & 1 & 4 \
0 & 0 & 0
\end{bmatrix}. $$

Here the third column has no pivot → the 3rd vector is dependent on the first two.

Relationship with Dimension

  • In $\mathbb{R}^n$, at most $n$ independent vectors exist.
  • If you have more than $n$, dependence is guaranteed.
  • A basis of a vector space is simply a maximal independent set that spans the space.

Geometric Interpretation

  • Independent vectors = different directions.
  • Dependent vectors = one vector lies in the span of others.
  • In 2D: two independent vectors span the plane.
  • In 3D: three independent vectors span the space.

Everyday Analogies

  • Ideas in a meeting: Independent ideas contribute new insights. Dependent ideas repeat what others already said.
  • Recipes: Having salt, sugar, and flour gives three distinct ingredients. But having sugar and "2× sugar" is not new-it's dependent.
  • Travel directions: North and east are independent. North and "2× north" are dependent.

Why It Matters

  1. Independence ensures a generating set is minimal and efficient.
  2. It determines whether a system of vectors is a basis.
  3. It connects directly to rank: rank = number of independent columns (or rows).
  4. It is crucial in geometry, data compression, and machine learning-where redundancy must be identified and removed.

Try It Yourself

  1. Test whether $(1,2)$ and $(2,4)$ are independent.
  2. Are the vectors $(1,0,0), (0,1,0), (1,1,0)$ independent in $\mathbb{R}^3$?
  3. Place the vectors $(1,0,1), (0,1,1), (1,1,2)$ into a matrix and row-reduce to check independence.
  4. Challenge: Prove that any set of $n+1$ vectors in $\mathbb{R}^n$ is linearly dependent.

Linear independence is the tool that separates essential directions from redundant ones. It is the key to defining bases, counting dimensions, and understanding the structure of all vector spaces.

35. Basis and Coordinates

The concepts of span and linear independence come together in the powerful idea of a basis. A basis gives us the minimal set of building blocks needed to generate an entire vector space, with no redundancy. Once a basis is chosen, every vector in the space can be described uniquely by a list of numbers called its coordinates.

What Is a Basis?

A basis of a vector space $V$ is a set of vectors ${v_1, v_2, \dots, v_k}$ that satisfies two properties:

  1. Spanning property: $\text{span}{v_1, \dots, v_k} = V$.
  2. Independence property: The vectors are linearly independent.

In short: a basis is a spanning set with no redundancy.

Example: Standard Bases

  1. In $\mathbb{R}^2$, the standard basis is ${(1,0), (0,1)}$.
  2. In $\mathbb{R}^3$, the standard basis is ${(1,0,0), (0,1,0), (0,0,1)}$.
  3. In $\mathbb{R}^n$, the standard basis is the collection of unit vectors, each with a 1 in one position and 0 elsewhere.

These are called standard because they are the default way of describing coordinates.

Uniqueness of Coordinates

One of the most important facts about bases is that they provide unique representations of vectors.

  • Given a basis ${v_1, \dots, v_k}$, any vector $x \in V$ can be written uniquely as:

    $$ x = a_1 v_1 + a_2 v_2 + \dots + a_k v_k. $$

  • The coefficients $(a_1, a_2, \dots, a_k)$ are the coordinates of $x$ relative to that basis.

This uniqueness distinguishes bases from arbitrary spanning sets, where redundancy allows multiple representations.

Example in $\mathbb{R}^2$

Let basis = ${(1,0), (0,1)}$.

  • Vector $(3,5) = 3(1,0) + 5(0,1)$.
  • Coordinates relative to this basis: $(3,5)$.

If we switch to a different basis, the coordinates change even though the vector itself does not.

Example with Non-Standard Basis

Basis = ${(1,1), (1,-1)}$ in $\mathbb{R}^2$. Find coordinates of $x = (2,0)$.

Solve $a(1,1) + b(1,-1) = (2,0)$. This gives system:

$$ a + b = 2, \quad a - b = 0. $$

So $a=1, b=1$. Coordinates relative to this basis: $(1,1)$.

Notice: coordinates depend on basis choice.

Basis of Function Spaces

  1. For polynomials of degree ≤ 2: basis = ${1, x, x^2}$.

    • Example: $2 + 3x + 5x^2$ has coordinates $(2,3,5)$.
  2. For continuous functions on $[0,1]$, one possible basis is the infinite set ${1, x, x^2, \dots}$.

This shows bases are not restricted to geometric vectors.

Dimension

The number of vectors in a basis is the dimension of the vector space.

  • $\mathbb{R}^2$ has dimension 2.
  • $\mathbb{R}^3$ has dimension 3.
  • The space of polynomials of degree ≤ 3 has dimension 4.

Dimension tells us how many independent directions exist in the space.

Change of Basis

  • Switching from one basis to another is like translating between languages.
  • The same vector looks different depending on which "dictionary" (basis) you use.
  • Change-of-basis matrices allow systematic translation between coordinate systems.

Geometric Interpretation

  • A basis is like setting up coordinate axes in a space.
  • In 2D, two independent vectors define a grid.
  • In 3D, three independent vectors define a full coordinate system.
  • Different bases = different grids overlaying the same space.

Everyday Analogies

  • Language: A basis is like an alphabet. Every word (vector) can be spelled uniquely from the letters (basis vectors).
  • Colors: RGB is a basis for color space. Any color can be described uniquely by mixing red, green, and blue.
  • Music: Musical notes form a basis. Every chord or melody is a combination of them.

Why It Matters

  1. Bases provide the simplest possible description of a vector space.
  2. They allow us to assign unique coordinates to vectors.
  3. They connect the abstract structure of a space with concrete numerical representations.
  4. The concept underlies almost all of linear algebra: dimension, transformations, eigenvectors, and more.

Try It Yourself

  1. Show that ${(1,2), (3,4)}$ is a basis of $\mathbb{R}^2$.
  2. Express $(4,5)$ in terms of basis ${(1,1), (1,-1)}$.
  3. Prove that no basis of $\mathbb{R}^3$ can have more than 3 vectors.
  4. Challenge: Show that the set ${1, \cos x, \sin x}$ is a basis for the space of all linear combinations of $1, \cos x, \sin x$.

A basis is the minimal, elegant foundation of a vector space, turning the infinite into the manageable by providing a finite set of independent building blocks.

36. Dimension

Dimension is one of the most profound and unifying ideas in linear algebra. It gives a single number that captures the "size" or "capacity" of a vector space: how many independent directions it has. Unlike length, width, or height in everyday geometry, dimension in linear algebra applies to spaces of any kind-geometric, algebraic, or even function spaces.

Definition

The dimension of a vector space $V$ is the number of vectors in any basis of $V$.

  • Since all bases of a vector space have the same number of elements, dimension is well-defined.

  • If $\dim V = n$, then:

    • Every set of more than $n$ vectors in $V$ is dependent.
    • Every set of exactly $n$ independent vectors forms a basis.

Examples in Familiar Spaces

  1. $\dim(\mathbb{R}^2) = 2$.

    • Basis: $(1,0), (0,1)$.
    • Two directions cover the whole plane.
  2. $\dim(\mathbb{R}^3) = 3$.

    • Basis: $(1,0,0), (0,1,0), (0,0,1)$.
    • Three independent directions span 3D space.
  3. The set of all polynomials of degree ≤ 2 has dimension 3.

    • Basis: ${1, x, x^2}$.
  4. The space of all $m \times n$ matrices has dimension $mn$.

    • Each entry is independent, and the standard basis consists of matrices with a single 1 and the rest 0.

Finite vs. Infinite Dimensions

  • Finite-dimensional spaces: $\mathbb{R}^n$, polynomials of degree ≤ $k$.

  • Infinite-dimensional spaces:

    • The space of all polynomials (no degree limit).
    • The space of all continuous functions.
    • These cannot be spanned by a finite set of vectors.

Dimension and Subspaces

  • Any subspace of $\mathbb{R}^n$ has dimension ≤ $n$.
  • A line through the origin in $\mathbb{R}^3$: dimension 1.
  • A plane through the origin in $\mathbb{R}^3$: dimension 2.
  • The whole space: dimension 3.
  • The trivial subspace ${0}$: dimension 0.

Dimension and Systems of Equations

When solving $A\mathbf{x} = \mathbf{b}$:

  • The dimension of the column space = rank = number of independent directions in the outputs.

  • The dimension of the null space = number of free variables.

  • By the rank–nullity theorem:

    $$ \dim(\text{column space}) + \dim(\text{null space}) = \text{number of variables}. $$

Geometric Meaning

  • Dimension counts the minimum number of coordinates needed to describe a vector.
  • In $\mathbb{R}^2$, you need 2 numbers.
  • In $\mathbb{R}^3$, you need 3 numbers.
  • In the polynomial space of degree ≤ 3, you need 4 coefficients.

Thus, dimension = length of coordinate list.

Everyday Analogies

  • Maps: A flat map needs 2 coordinates (latitude, longitude). A globe is 3D and needs 3. Adding altitude makes it 3D as well.
  • Languages: To describe meaning, you need enough independent words. Redundant words don't add dimension; new independent concepts do.
  • Recipes: To describe all possible flavors, you need a certain number of independent ingredients. More ingredients = higher-dimensional "flavor space."

Checking Dimension in Practice

  1. Place candidate vectors as columns of a matrix.
  2. Row reduce to echelon form.
  3. Count pivots. That number = dimension of the span of those vectors.

Why It Matters

  1. Dimension is the most fundamental measure of a vector space.
  2. It tells us how "large" or "complex" the space is.
  3. It sets absolute limits: in $\mathbb{R}^n$, no more than $n$ independent vectors exist.
  4. It underlies coordinate systems, bases, and transformations.
  5. It bridges geometry (lines, planes, volumes) with algebra (solutions, equations, matrices).

Try It Yourself

  1. What is the dimension of the span of $(1,2,3)$, $(2,4,6)$, $(0,0,0)$?
  2. Find the dimension of the subspace of $\mathbb{R}^3$ defined by $x+y+z=0$.
  3. Prove that the set of all $2 \times 2$ symmetric matrices has dimension 3.
  4. Challenge: Show that the space of polynomials of degree ≤ $k$ has dimension $k+1$.

Dimension is the measuring stick of linear algebra: it tells us how many independent pieces of information are needed to describe the whole space.

37. Rank–Nullity Theorem

The rank–nullity theorem is one of the central results of linear algebra. It gives a precise balance between two fundamental aspects of a matrix: the dimension of its column space (rank) and the dimension of its null space (nullity). It shows that no matter how complicated a matrix looks, the distribution of information between its "visible" outputs and its "hidden" null directions always obeys a strict law.

Statement of the Theorem

Let $A$ be an $m \times n$ matrix (mapping $\mathbb{R}^n \to \mathbb{R}^m$):

$$ \text{rank}(A) + \text{nullity}(A) = n $$

where:

  • rank(A) = dimension of the column space of $A$.
  • nullity(A) = dimension of the null space of $A$.
  • $n$ = number of columns of $A$, i.e., the number of variables.

Intuition

Think of a matrix as a machine that transforms input vectors into outputs:

  • Rank measures how many independent output directions survive.
  • Nullity measures how many input directions get "lost" (mapped to zero).
  • The theorem says: total inputs = useful directions (rank) + wasted directions (nullity).

This ensures nothing disappears mysteriously-every input direction is accounted for.

Example 1: Full Rank

$$ A = \begin{bmatrix}
1 & 0 \
0 & 1 \
\end{bmatrix}. $$

  • Rank = 2 (two independent columns).
  • Null space = ${0}$, so nullity = 0.
  • Rank + nullity = 2 = number of variables.

Example 2: Dependent Columns

$$ A = \begin{bmatrix}
1 & 2 \
2 & 4 \
3 & 6 \
\end{bmatrix}. $$

  • Second column is a multiple of the first. Rank = 1.
  • Null space contains all vectors $(x,y)$ with $y = -2x$. Nullity = 1.
  • Rank + nullity = 1 + 1 = 2 = number of variables.

Example 3: Larger System

$$ A = \begin{bmatrix}
1 & 0 & 1 \
0 & 1 & 1
\end{bmatrix}. $$

  • Columns: $(1,0), (0,1), (1,1)$.
  • Only two independent columns → Rank = 2.
  • Null space: solve $x + z = 0, y + z = 0 \Rightarrow (x,y,z) = (-t,-t,t)$. Nullity = 1.
  • Rank + nullity = 2 + 1 = 3 = number of variables.

Proof Sketch (Conceptual)

  1. Row reduce $A$ to echelon form.

  2. Pivots correspond to independent columns → count = rank.

  3. Free variables correspond to null space directions → count = nullity.

  4. Each column is either a pivot column or corresponds to a free variable, so:

    $$ \text{rank} + \text{nullity} = \text{number of columns}. $$

Geometric Meaning

  • In $\mathbb{R}^3$, if a transformation collapses all vectors onto a plane (rank = 2), then one direction disappears entirely (nullity = 1).
  • In $\mathbb{R}^4$, if a matrix has rank 2, then its null space has dimension 2, meaning half the input directions vanish.

The theorem guarantees the geometry of "surviving" and "vanishing" directions always adds up consistently.

Applications

  1. Solving systems $Ax = b$:

    • Rank determines consistency and structure of solutions.
    • Nullity tells how many free parameters exist in the solution.
  2. Data compression: Rank identifies independent features; nullity shows redundancy.

  3. Computer graphics: Rank–nullity explains how 3D coordinates collapse into 2D images: one dimension of depth is lost.

  4. Machine learning: Rank signals how much real information a dataset contains; nullity indicates degrees of freedom that add nothing new.

Everyday Analogies

  • Work team: Rank = number of independent workers contributing new ideas. Nullity = number of workers repeating what others already said. Total team members = contributors + redundant voices.
  • Travel: Rank = number of useful directions on a map; nullity = directions that lead nowhere.
  • Languages: Rank = unique words, nullity = synonyms. Total vocabulary size is always the sum.

Why It Matters

  1. The rank–nullity theorem connects the abstract ideas of rank and nullity into a single, elegant formula.
  2. It ensures conservation of dimension: no information magically appears or disappears.
  3. It is essential in understanding solutions of systems, dimensions of subspaces, and the structure of linear transformations.
  4. It prepares the ground for deeper results in algebra, topology, and differential equations.

Try It Yourself

  1. Verify rank–nullity for

    $$ A = \begin{bmatrix}
    1 & 2 & 3 \
    4 & 5 & 6
    \end{bmatrix}. $$

  2. For a $4 \times 5$ matrix of rank 3, what is its nullity?

  3. In $\mathbb{R}^3$, suppose a matrix maps all of space onto a line. What are its rank and nullity?

  4. Challenge: Prove rigorously that the row space and null space are orthogonal complements, and use this to derive rank–nullity again.

The rank–nullity theorem is the law of balance in linear algebra: every input dimension is accounted for, either as a surviving direction (rank) or as one that vanishes (nullity).

38. Coordinates Relative to a Basis

Once a basis for a vector space is chosen, every vector in that space can be described uniquely in terms of the basis. These descriptions are called coordinates. Coordinates transform abstract vectors into concrete lists of numbers, making computation possible. Changing the basis changes the coordinates, but the underlying vector remains the same.

The Core Idea

Given a vector space $V$ and a basis $B = {v_1, v_2, \dots, v_n}$, every vector $x \in V$ can be written uniquely as:

$$ x = a_1 v_1 + a_2 v_2 + \dots + a_n v_n. $$

The coefficients $(a_1, a_2, \dots, a_n)$ are the coordinates of $x$ with respect to the basis $B$.

This representation is unique because basis vectors are independent.

Example in $\mathbb{R}^2$

  1. Standard basis: $B = {(1,0), (0,1)}$.

    • Vector $x = (3,5)$.
    • Coordinates relative to $B$: $(3,5)$.
  2. Non-standard basis: $B = {(1,1), (1,-1)}$.

    • Write $x = (3,5)$ as $a(1,1) + b(1,-1)$.

    • Solve:

      $$ a+b = 3, \quad a-b = 5. $$

      Adding: $2a = 8 \implies a = 4$. Subtracting: $2b = -2 \implies b = -1$.

    • Coordinates relative to this basis: $(4, -1)$.

The same vector looks different depending on the chosen basis.

Example in $\mathbb{R}^3$

Let $B = {(1,0,0), (1,1,0), (1,1,1)}$. Find coordinates of $x = (2,3,4)$.

Solve $a(1,0,0) + b(1,1,0) + c(1,1,1) = (2,3,4)$. This gives system:

$$ a+b+c = 2, \quad b+c = 3, \quad c = 4. $$

From $c=4$, we get $b+c=3 \implies b=-1$. Then $a+b+c=2 \implies a-1+4=2 \implies a=-1$. Coordinates: $(-1, -1, 4)$.

Matrix Formulation

If $B = {v_1, \dots, v_n}$, form the basis matrix

$$ P = [v_1 \ v_2 \ \dots \ v_n]. $$

Then for a vector $x$, its coordinate vector $[x]_B$ satisfies

$$ P [x]_B = x. $$

Thus,

$$ [x]_B = P^{-1}x. $$

This shows coordinate transformation is simply matrix multiplication.

Changing Coordinates

Suppose a vector has coordinates $[x]_B$ relative to basis $B$. If we switch to another basis $C$, we use a change-of-basis matrix to convert coordinates:

$$ [x]_C = (P_C^{-1} P_B) [x]_B. $$

This process is fundamental in computer graphics, robotics, and data transformations.

Geometric Meaning

  • A basis defines a coordinate system: axes in the space.
  • Coordinates are the "addresses" of vectors relative to those axes.
  • Changing basis is like rotating or stretching the grid: the address changes, but the point does not.

Everyday Analogies

  • Maps: Latitude and longitude are coordinates relative to Earth's axis. If we change the map projection, the coordinates change, but the physical location stays the same.
  • Languages: Describing the same object in English or French yields different words (coordinates), but the object (vector) is unchanged.
  • Music: The same melody can be written in different keys (bases); the notes shift, but the tune remains.

Why It Matters

  1. Coordinates make abstract vectors computable.
  2. They allow us to represent functions, polynomials, and geometric objects numerically.
  3. Changing basis simplifies problems-e.g., diagonalization makes matrices easy to analyze.
  4. They connect the abstract (spaces, bases) with the concrete (numbers, matrices).

Try It Yourself

  1. Express $x=(4,2)$ relative to basis ${(1,1),(1,-1)}$.
  2. Find coordinates of $x=(2,1,3)$ relative to basis ${(1,0,1),(0,1,1),(1,1,0)}$.
  3. If basis $B$ is the standard basis and basis $C={(1,1),(1,-1)}$, compute the change-of-basis matrix from $B$ to $C$.
  4. Challenge: Show that if $P$ is invertible, its columns form a basis, and explain why this guarantees uniqueness of coordinates.

Coordinates relative to a basis are the bridge between geometry and algebra: they turn abstract spaces into numerical systems where computation, reasoning, and transformation become systematic and precise.

39. Change-of-Basis Matrices

Every vector space allows multiple choices of basis, and each basis provides a different way of describing the same vectors. The process of moving from one basis to another is called a change of basis. To perform this change systematically, we use a change-of-basis matrix. This matrix acts as a translator between coordinate systems: it converts the coordinates of a vector relative to one basis into coordinates relative to another.

Why Change Bases?

  1. Simplicity of computation: Some problems are easier in certain bases. For example, diagonalizing a matrix allows us to raise it to powers more easily.
  2. Geometry: Different bases can represent rotated or scaled coordinate systems.
  3. Applications: In physics, computer graphics, robotics, and data science, changing bases is equivalent to switching perspectives or reference frames.

The Basic Setup

Let $V$ be a vector space with two bases:

  • $B = {b_1, b_2, \dots, b_n}$
  • $C = {c_1, c_2, \dots, c_n}$

Suppose a vector $x \in V$ has coordinates $[x]_B$ relative to $B$, and $[x]_C$ relative to $C$.

We want a matrix $P_{B \to C}$ such that:

$$ [x]C = P{B \to C} [x]_B. $$

This matrix $P_{B \to C}$ is the change-of-basis matrix from $B$ to $C$.

Constructing the Change-of-Basis Matrix

  1. Write each vector in the basis $B$ in terms of the basis $C$.
  2. Place these coordinate vectors as the columns of a matrix.
  3. The resulting matrix converts coordinates from $B$ to $C$.

In matrix form:

$$ P_{B \to C} = \big[ [b_1]_C \ [b_2]_C \ \dots \ [b_n]_C \big]. $$

Example in $\mathbb{R}^2$

Let

  • $B = {(1,0), (0,1)}$ (standard basis).
  • $C = {(1,1), (1,-1)}$.

To build $P_{B \to C}$:

  • Express each vector of $B$ in terms of $C$.

Solve:

$$ (1,0) = a(1,1) + b(1,-1). $$

This gives system:

$$ a+b=1, \quad a-b=0. $$

Solution: $a=\tfrac{1}{2}, b=\tfrac{1}{2}$. So $(1,0) = \tfrac{1}{2}(1,1) + \tfrac{1}{2}(1,-1)$.

Next:

$$ (0,1) = a(1,1) + b(1,-1). $$

System:

$$ a+b=0, \quad a-b=1. $$

Solution: $a=\tfrac{1}{2}, b=-\tfrac{1}{2}$.

Thus:

$$ P_{B \to C} = \begin{bmatrix}
\tfrac{1}{2} & \tfrac{1}{2} \
\tfrac{1}{2} & -\tfrac{1}{2}
\end{bmatrix}. $$

So for any vector $x$,

$$ [x]C = P{B \to C}[x]_B. $$

Inverse Change of Basis

If $P_{B \to C}$ is the change-of-basis matrix from $B$ to $C$, then its inverse is the change-of-basis matrix in the opposite direction:

$$ P_{C \to B} = (P_{B \to C})^{-1}. $$

This makes sense: translating back and forth between languages should undo itself.

General Formula with Basis Matrices

Let

$$ P_B = [b_1 \ b_2 \ \dots \ b_n], \quad P_C = [c_1 \ c_2 \ \dots \ c_n], $$

the matrices whose columns are basis vectors written in standard coordinates.

Then the change-of-basis matrix from $B$ to $C$ is:

$$ P_{B \to C} = P_C^{-1} P_B. $$

This formula is extremely useful because it reduces the problem to matrix multiplication.

Geometric Interpretation

  • Changing basis is like rotating or stretching the grid lines of a coordinate system.
  • The vector itself (the point in space) does not move. What changes is its description in terms of the new grid.
  • The change-of-basis matrix is the tool that translates between these descriptions.

Applications

  1. Diagonalization: Expressing a matrix in a basis of its eigenvectors makes it diagonal, simplifying analysis.
  2. Computer graphics: Changing camera viewpoints requires change-of-basis matrices.
  3. Robotics: Coordinate transformations connect robot arms, joints, and workspace frames.
  4. Data science: PCA finds a new basis (principal components) where data is easier to analyze.

Everyday Analogies

  • Languages: The word "dog" in English corresponds to "chien" in French. The change-of-basis matrix is the bilingual dictionary.
  • Currencies: Converting from dollars to euros requires an exchange rate. The matrix is the exchange table.
  • Maps: Switching between Cartesian and polar coordinates is a change of basis-different coordinates, same location.

Why It Matters

  1. Provides a universal method to translate coordinates between bases.
  2. Makes abstract transformations concrete and computable.
  3. Forms the backbone of diagonalization, Jordan form, and the spectral theorem.
  4. Connects algebraic manipulations with geometry and real-world reference frames.

Try It Yourself

  1. Compute the change-of-basis matrix from the standard basis to ${(2,1),(1,1)}$ in $\mathbb{R}^2$.
  2. Find the change-of-basis matrix from basis ${(1,0,0),(0,1,0),(0,0,1)}$ to ${(1,1,0),(0,1,1),(1,0,1)}$ in $\mathbb{R}^3$.
  3. Show that applying $P_{B \to C}$ then $P_{C \to B}$ returns the original coordinates.
  4. Challenge: Derive the formula $P_{B \to C} = P_C^{-1} P_B$ starting from the definition of coordinates.

Change-of-basis matrices give us the precise mechanism for switching perspectives. They ensure that although bases change, vectors remain invariant, and computations remain consistent.

40. Affine Subspaces

So far, vector spaces and subspaces have always passed through the origin. But in many real-world situations, we deal with shifted versions of these spaces: planes not passing through the origin, lines offset from the zero vector, or solution sets to linear equations with nonzero constants. These structures are called affine subspaces. They extend the idea of subspaces by allowing "translation away from the origin."

Definition

An affine subspace of a vector space $V$ is a set of the form

$$ x_0 + W = {x_0 + w : w \in W}, $$

where:

  • $x_0 \in V$ is a fixed vector (the "base point" or "anchor"),
  • $W \subseteq V$ is a linear subspace.

Thus, an affine subspace is simply a subspace shifted by a vector.

Examples in $\mathbb{R}^2$

  1. A line through the origin: $\text{span}{(1,2)}$. This is a subspace.
  2. A line not through the origin: $(3,1) + \text{span}{(1,2)}$. This is an affine subspace.
  3. The entire plane: $\mathbb{R}^2$, which is both a subspace and an affine subspace.

Examples in $\mathbb{R}^3$

  1. Plane through the origin: $\text{span}{(1,0,0),(0,1,0)}$.
  2. Plane not through the origin: $(2,3,4) + \text{span}{(1,0,0),(0,1,0)}$.
  3. Line parallel to the z-axis but passing through $(1,1,5)$: $(1,1,5) + \text{span}{(0,0,1)}$.

Relation to Linear Systems

Affine subspaces naturally arise as solution sets of linear equations.

  1. Homogeneous system: $Ax = 0$.

    • Solution set is a subspace (the null space).
  2. Non-homogeneous system: $Ax = b$ with $b \neq 0$.

    • Solution set is affine.

    • If $x_p$ is one particular solution, then the general solution is:

      $$ x = x_p + N(A), $$

      where $N(A)$ is the null space.

Thus, the geometry of solving equations leads naturally to affine subspaces.

Affine Dimension

The dimension of an affine subspace is defined as the dimension of its direction subspace $W$.

  • A point: affine subspace of dimension 0.
  • A line: dimension 1.
  • A plane: dimension 2.
  • Higher analogs continue in $\mathbb{R}^n$.

Difference Between Subspaces and Affine Subspaces

  • Subspaces always contain the origin.
  • Affine subspaces may or may not pass through the origin.
  • Every subspace is an affine subspace (with base point $x_0 = 0$).

Geometric Intuition

Think of affine subspaces as "flat sheets" floating in space:

  • A line through the origin is a rope tied at the center.
  • A line parallel to it but offset is the same rope moved to the side.
  • Affine subspaces preserve shape and direction, but not position.

Everyday Analogies

  • Railway tracks: A railway line is straight (like a subspace), but it doesn't need to pass through the city center (origin).
  • Office floors: Each floor in a building is a plane parallel to the ground, offset vertically. The ground floor is like the subspace through the origin; higher floors are affine subspaces.
  • Schedules: A repeating pattern (like working hours 9–5) is the subspace. Starting the shift at 10 instead of 9 shifts it into an affine version.

Applications

  1. Linear equations: General solutions are affine subspaces.
  2. Optimization: Feasible regions in linear programming are affine subspaces (intersected with inequalities).
  3. Computer graphics: Affine transformations map affine subspaces to affine subspaces, preserving straightness and parallelism.
  4. Machine learning: Affine decision boundaries (like hyperplanes) separate data into classes.

Why It Matters

  1. Affine subspaces generalize subspaces, making linear algebra more flexible.
  2. They allow us to describe solution sets that don't include the origin.
  3. They provide the geometric foundation for affine geometry, computer graphics, and optimization.
  4. They serve as the bridge from pure linear algebra to applied modeling.

Try It Yourself

  1. Show that the set of solutions to

    $$ x+y+z=1 $$

    is an affine subspace of $\mathbb{R}^3$. Identify its dimension.

  2. Find the general solution to

    $$ x+2y=3 $$

    and describe it as an affine subspace.

  3. Prove that the intersection of two affine subspaces is either empty or another affine subspace.

  4. Challenge: Show that every affine subspace can be written uniquely as $x_0 + W$ with $W$ a subspace.

Affine subspaces are the natural setting for most real-world linear problems: they combine the strict structure of subspaces with the freedom of translation, capturing both direction and position.

Closing

Each basis a song,
dimension counts melodies,
the space breathes its form.

Chapter 5. Linear Transformation and Structure

Opening

Maps preserve the line,
reflections ripple outward,
motion kept in frame.

41. Linear Transformations

A linear transformation is the heart of linear algebra. It is the rule that connects two vector spaces in a way that respects their linear structure: addition and scalar multiplication. Instead of thinking of vectors as static objects, linear transformations let us study how vectors move, stretch, rotate, project, or reflect. They give linear algebra its dynamic power and are the bridge between abstract theory and concrete applications.

Definition

A function $T: V \to W$ between vector spaces is called a linear transformation if for all $u, v \in V$ and scalars $a, b \in \mathbb{R}$ (or another field),

$$ T(au + bv) = aT(u) + bT(v). $$

This single condition encodes two rules:

  1. Additivity: $T(u+v) = T(u) + T(v)$.
  2. Homogeneity: $T(av) = aT(v)$.

If both are satisfied, the transformation is linear.

Examples of Linear Transformations

  1. Scaling: $T(x) = 3x$ in $\mathbb{R}$. Every number is stretched threefold.

  2. Rotation in the plane: $T(x,y) = (x\cos\theta - y\sin\theta, , x\sin\theta + y\cos\theta)$.

  3. Projection: Projecting $(x,y,z)$ onto the $xy$-plane: $T(x,y,z) = (x,y,0)$.

  4. Differentiation: On the space of polynomials, $T(p(x)) = p'(x)$.

  5. Integration: On continuous functions, $T(f)(x) = \int_0^x f(t) , dt$.

All these are linear because they preserve addition and scaling.

Non-Examples

  • $T(x) = x^2$ is not linear, because $(x+y)^2 \neq x^2 + y^2$.
  • $T(x,y) = (x+1, y)$ is not linear, because it fails homogeneity: scaling doesn't preserve the "+1."

Nonlinear rules break the structure of vector spaces.

Matrix Representation

Every linear transformation from $\mathbb{R}^n$ to $\mathbb{R}^m$ can be represented by a matrix.

If $T: \mathbb{R}^n \to \mathbb{R}^m$, then there exists an $m \times n$ matrix $A$ such that:

$$ T(x) = Ax. $$

The columns of $A$ are simply $T(e_1), T(e_2), \dots, T(e_n)$, where $e_i$ are the standard basis vectors.

Example: Let $T(x,y) = (2x+y, x-y)$.

  • $T(e_1) = T(1,0) = (2,1)$.
  • $T(e_2) = T(0,1) = (1,-1)$. So

$$ A = \begin{bmatrix} 2 & 1 \ 1 & -1 \end{bmatrix}. $$

Then $T(x,y) = A \begin{bmatrix} x \ y \end{bmatrix}$.

Properties of Linear Transformations

  1. The image of the zero vector is always zero: $T(0) = 0$.
  2. The image of a line through the origin is again a line (or collapsed to a point).
  3. Composition of linear transformations is linear.
  4. Every linear transformation preserves the structure of subspaces.

Kernel and Image (Preview)

For $T: V \to W$:

  • The kernel (or null space) is all vectors mapped to zero: $\ker T = {v \in V : T(v) = 0}$.
  • The image (or range) is all outputs that can be achieved: $\text{im}(T) = {T(v) : v \in V}$. The rank–nullity theorem applies here:

$$ \dim(\ker T) + \dim(\text{im}(T)) = \dim(V). $$

Geometric Interpretation

Linear transformations reshape space:

  • Scaling stretches space uniformly in one direction.
  • Rotation spins space while preserving lengths.
  • Projection flattens space onto lower dimensions.
  • Reflection flips space across a line or plane.

The key feature: straight lines remain straight, and the origin stays fixed.

Everyday Analogies

  • Maps and coordinates: A GPS system transforms geographic positions (lat/long) into screen positions (x,y).
  • Shadows: Projecting a 3D object onto the ground is a linear transformation.
  • Economics: A matrix that takes production levels (inputs) and outputs profits is a linear transformation of data.
  • Music: An equalizer linearly adjusts different frequencies: the structure of the sound is preserved but reshaped.

Applications

  1. Computer graphics: Scaling, rotating, projecting 3D objects onto 2D screens.
  2. Robotics: Transformations between joint coordinates and workspace positions.
  3. Data science: Linear mappings represent dimensionality reduction and feature extraction.
  4. Differential equations: Solutions often involve linear operators acting on function spaces.
  5. Machine learning: Weight matrices in neural networks are stacked linear transformations, interspersed with nonlinearities.

Why It Matters

  1. Linear transformations generalize matrices to any vector space.
  2. They unify geometry, algebra, and applications under one concept.
  3. They provide the natural framework for studying eigenvalues, eigenvectors, and decompositions.
  4. They model countless real-world processes: physical, computational, and abstract.

Try It Yourself

  1. Prove that $T(x,

Truncated — view the full README on GitHub.

Significant stargazers

(top 24 of 34)

Miguel Grinberg

12,947 followers · starred Sep 2025

Phan An

2,437 followers · starred Sep 2025

Armando Santos

135 followers · starred Sep 2025

Jauder Ho

85 followers · starred Sep 2025