Course index · Chapter 1 · Leon, Linear Algebra with Applications, 8th ed.

Matrices & systems, hands-on

Thirteen small labs for the first chapter, including a closing look at a linear neural network, plus checked exercises from the book at the end of every section. Each lab takes an example from the text and lets you push on it: move a line, apply a row operation, drag a vector, raise a matrix to a power. Read the short summary, play with the lab, then work the exercises. Answers are checked exactly, and fractions like −5/2 are accepted. Every definition of the chapter also has its own card with a short animation made in Manim.

≔

Definitions, animated

The definitions of Chapter 1, each with a Manim animation paced for following step by step (20–50 seconds), with pauses after every step. Use the speed buttons under a video to slow it down further. The cards sit inside their sections; jump to one here.
1.1

Systems of linear equations

Solutions, consistency, and the geometry of a 2 × 2 system

A solution of an m × n system is an ordered n-tuple that satisfies every equation at once. A system with at least one solution is consistent; a system with none is inconsistent.

In a 2 × 2 system, each equation is a line in the plane, and a solution is a point lying on both lines. Two lines can meet in one point, be parallel, or coincide. So the solution set has exactly one point, no points, or infinitely many. The same three outcomes hold for every m × n system.

Two equations, two lines

Figure 1.1.1 · Exercises 3 and 9
Try this
  • Start from system (i). Change one coefficient so the lines become parallel. What happened to the two slopes?
  • Load (iii). The second equation is the first one multiplied by −1. Now change only b2. Which outcome do you get?
  • Exercise 9 says the system has a unique solution exactly when the slopes differ. Check it against the readout.

From equations to matrices, and back

Coefficient & augmented matrices · Exercises 1.1.2, 1.1.4, 1.1.5, 1.3.4

To write a system as a matrix: put all variable terms on the left in the order x1, x2, …; give each equation one row and each variable one column; put the right-hand sides in an extra column after the dashed line. A variable that is missing from an equation gets a 0. A variable written with no number in front has coefficient 1 (or −1).

Watch for
  • Terms written out of order, such as −x3 + 2x1: the column is decided by the variable, not by the position in the equation.
  • Once your matrix is right, the page writes the system as Ax = b and as a combination of columns, which is how §1.3 reads it.
1.2

Elimination and row echelon form

Row operations, pivots, lead and free variables (§1.1 → §1.2)

Two systems are equivalent if they have the same solution set. Three elementary row operations on the augmented matrix never change the solution set:

Elementary row operationsI. Interchange two rows.  II. Multiply a row by a nonzero number.  III. Replace a row by its sum with a multiple of another row.

Gaussian elimination uses them to reach a staircase shape. Section 1.1 stops at strict triangular form and finishes by back substitution. Section 1.2 scales each leading entry to 1 (row echelon form) and then clears the entries above the pivots too (reduced row echelon form, Gauss–Jordan reduction). Variables in pivot columns are lead variables; the rest are free and can take any value.

Row reduction workbench

Examples from §1.1, §1.2 and §1.5
    Try this
    • Load §1.1 Ex 4 and press Suggest. Why must the first move be a swap?
    • Load Traffic flow and run to RREF. One variable stays free, so the flows are not determined. Set x4 = 200 in the readout's formulas: you should get 530, 370, 410 as in the book.
    • Load §1.5 Ex 4: A⁻¹. Reducing [A | I] to [I | B] produces B = A⁻¹.
    • Do a few steps by hand with the operation box. The workbench shows the elementary matrix E for each step, which is where §1.5 begins.
    1.3

    Matrix arithmetic

    Ax as a linear combination, and the row-times-column rule

    If A has columns a1, …, an, then Ax = x1a1 + x2a2 + ⋯ + xnan. Solving Ax = b means finding weights that combine the columns into b.

    Theorem 1.3.1 · Consistency theoremA linear system Ax = b is consistent if and only if b can be written as a linear combination of the column vectors of A.

    Columns, weights and the target b

    Examples 5–7
    Drag the tips of a₁, a₂ and the target b.
    Try this
    • The faint slanted grid shows every combination with whole-number weights. When the columns point in different directions, the grid covers the plane, so every b is reachable.
    • Load Example 7. The columns (1, 2) and (2, 4) lie on one line, so the only reachable targets are on that line. Drag b onto it and solve again.

    Row times column

    Example 8

    The (i, j) entry of AB is the ith row of A times the jth column of B. Equivalently, the jth column of AB is Abj, a combination of the columns of A. AB is defined only when A has as many columns as B has rows.

    Try this
    • Click any entry of AB to see which row and column produce it.
    • Switch to column view: each column of AB uses all of A, weighted by one column of B.
    1.4

    Matrix algebra

    Powers of a matrix in two applications

    Matrix multiplication is associative, so A(Ax) = A2x, and repeating a process k times is multiplying by Ak. Two applications in this section show what powers mean: a population model, where Anx is the state after n years, and a graph, where the entries of Ak count walks.

    What a matrix does to the plane

    Matrices from Exercises 1.4.5, 7, 21, 22, 24 (pp. 56–57)

    Multiplying by a 2 × 2 matrix A sends every vector x in the plane to Ax. The columns of A show where e1 = (1, 0) and e2 = (0, 1) land. Every other vector follows, because Ax = x1a1 + x2a2. Raising the power k applies the map k times.

    power k =
    Try this
    • Ex 5: the matrix with A² = O. Set k = 2 and watch the whole plane collapse to the origin.
    • Ex 22: a reflection G. At k = 2 everything returns to where it started, so G² = I (an involution). The letter F appears mirrored at k = 1.
    • Ex 24: idempotent matrices flatten the plane onto a line. Applying them again changes nothing, so A² = A.
    • Drag the green vector x to see where it lands.

    Marital status, year by year

    Application 1: A simple model for marital status computations
    Try this
    • With the book's rates, check the text: after 1 year, 6000 married; after 2 years, 5000 and 5000.
    • Move the starting population. The long-run split doesn't change. It depends only on the two rates.

    Counting walks with Ak

    Application 3 · Theorem 1.4.3 · Figure 1.4.2
    Theorem 1.4.3If A is the adjacency matrix of a graph, the (i, j) entry of Ak is the number of walks of length k from Vi to Vj.

    Tap two vertices in turn to add or remove the edge between them.

    length k =
      Try this
      • Click entries of Ak to list the walks it counts. With k = 3, entry (4, 1) is the book's walk V4 → V5 → V2 → V1.
      • The adjacency matrix of a graph is always symmetric. Is Ak symmetric too? Why would it be?
      1.5

      Elementary matrices

      Row operations as multiplication, and the LU factorization

      An elementary matrix is the identity with one row operation applied to it. Multiplying A on the left by E performs that same operation on A. Every elementary matrix is nonsingular, and its inverse undoes the operation.

      If A reduces to upper triangular U using only operation III, then E3E2E1A = U, and A = LU. L is lower triangular with 1s on the diagonal, and its entries below the diagonal are exactly the multipliers lij used during elimination.

      Building L and U one step at a time

      Triangular factorization · Example 6
      Edit A (integers or fractions like 3/2):
      Try this
      • Watch where each multiplier lands: the number used to clear position (i, j) is stored at position (i, j) of L.
      • Change a11 to 0. The first pivot is zero, so operation III alone cannot proceed and a row interchange would be needed.
      1.6

      Partitioned matrices

      Block multiplication and the outer product expansion

      Splitting a matrix into blocks lets you multiply block by block. Partition X into its columns x1, …, xn and Y into columns y1, …, yn. Then the product splits into a sum of outer products:

      Outer product expansionXYT = x1y1T + x2y2T + ⋯ + xnynT

      Each term xiyiT is a multiplication table: a column times a row. Every row of it is a multiple of yiT.

      Two multiplication tables add up to XYT

      Example 3
      Hover or tap a cell to follow it through the sum.
      Try this
      • Pick a cell of XYT. Its value is row i of X times row j of Y, and it also equals the sum of the two matching cells in the tables.

      Strassen's algorithm: seven products instead of eight

      Block multiplication applied recursively

      The ordinary rule needs 8 multiplications for a 2 × 2 product, one for each term aikbkj. Strassen (1969) found 7 products M1, …, M7 that combine into the same C = AB, at the cost of extra additions. The formulas never swap the order of a product, so they still hold when the entries are blocks. Split an n × n matrix into four n/2 × n/2 blocks, apply the formulas, and recurse. The cost drops from n3 to nlog₂7 ≈ n2.807 multiplications.

      Edit A and B. Click a product to see which entries it uses.
      Try this
      • Expand M3 + M5 by hand: everything cancels except a11b12 + a12b22 = c12.
      • In the table, each level of recursion saves one product in eight. For n = 1024 that adds up to about 3.8 times fewer multiplications.
      +

      Application: a linear neural network

      A layer is a matrix–vector product (§1.3); stacking layers is matrix multiplication (§1.4)

      A layer of a neural network takes a vector x and produces h = Wx + b. Row i of the weight matrix W holds the weights on the arrows into neuron i. So each neuron computes one row of W times the column x, plus its bias bi. The next layer does the same with its own matrix.

      Two linear layers collapse into oneW2(W1x + b1) + b2 = (W2W1)x + (W2b1 + b2), by the distributive and associative laws (Theorem 1.4.1).

      Real networks apply a nonlinear function, such as ReLU(t) = max(0, t), after each layer. These labs leave it out on purpose to show the linear algebra alone. They also show why the nonlinearity matters: without it, a network of any depth is just one matrix and one shift.

      Forward pass, one neuron at a time

      3 inputs → 4 hidden → 2 outputs
      Try this
      • Click a hidden or output neuron. Its incoming arrows are one row of the weight matrix: blue for positive weights, pink for negative, thicker for larger.
      • Switch to Collapsed to one layer. The outputs don't change, because W = W2W1 does the work of both layers. The hidden layer added 18 parameters and no new ability.

      Each layer moves the whole plane

      2 → 2 → 2, a batch of 100 points fed as columns of X

      Feed many inputs at once by putting them in the columns of a matrix X. Then H = W1X computes every hidden vector at once, using the column view of §1.3, and the bias shifts every column. Each layer is a linear map of the plane plus a shift, so straight lines stay straight and parallel lines stay parallel. The points are colored like an XOR pattern. A straight line can't separate blue from pink in the input, so no linear network can separate them in the output either.