Chapter 2 · Computation

Matrices and Gaussian Elimination

One question

When, and how, can we solve Ax = b?

Before the code

Four ideas to keep in view

Each active line shows its action, array shape, and mathematical change.

01System
Ax = b

Rows are equations; columns are the directions combined by x.

02Product
AB = [Ab₁ | ··· | Abₗ]

Matrix multiplication repeats one matrix–vector product by columns.

03Elimination
Rᵢ ← Rᵢ − mRⱼ

Choose m so one target entry becomes exactly zero.

04Factorization
QA = LU

A row order and all elimination multipliers can be stored and reused.

Lecture bridge

See the zeros before writing the loop

One small system shows the pivot-and-cancel pattern used in the labs.

Start · [ A | b ]
02210
44012
23214
  1. 01R₁ ↔ R₂move 4 into the pivot
  2. 02R₃ ← R₃ − 0.5R₁2 → 0
  3. 03R₃ ← R₃ − 0.5R₂1 → 0
Result · [ U_raw | c ]
44012
02210
0013

Back-substitutionx = (1, 2, 3)

Practice sequence

Choose a lab

  1. 2.1Gaussian EliminationSolve one small 3×3 system by following the notebook’s LU → LDU → triangular-solve idea.row order → LDU → solveOpen lab
  2. 2.2Block Matrices and GraphsBuild one small block matrix, multiply it blockwise, and count two-step graph walks.join blocks → multiply → count walksOpen lab
  3. 2.3Testing LU DecompositionBuild one deterministic rank-2 matrix, read SciPy’s LU factors, and verify the result.low rank → LU → checkOpen lab
  4. 2.4Gaussian Elimination in DetailOpen the LU black box with one row swap and two visible cancellations.choose pivot → swap → cancelOpen lab