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

Numerical linear algebra, hands-on

Computers round. See which numbers a floating-point system can hold, watch cancellation destroy digits, run Gaussian elimination in 3-digit arithmetic with and without pivoting, perturb an ill-conditioned system, reflect vectors with Householder matrices, and find eigenvalues by iteration.

≔

Definitions, animated

The chapter's definitions and key theorems. Animations are paced for following step by step; use the speed buttons under a video to change the pace. Jump to a card here.
7.1

Floating-point numbers

What a computer can store, and what it loses

A computer stores a real number as a floating-point number ±(0.d1d2⋯dt)b × be with t digits in base b and exponent L ≤ e ≤ U. Everything else is rounded: fl(x) = x(1 + δ) with |δ| ≤ ε, the machine epsilon. Each arithmetic operation rounds again. Mostly harmless, until two nearly equal numbers are subtracted and the leading digits cancel.

Floating-point explorer

Definition · Examples 7.1.1–7.1.3 · Exercises 7.1.1–7.1.3, 7.1.6–7.1.8
base b
digits t
exponent L … U…
zoom: show [0,]
x =

Arithmetic with t digits, and IEEE doubles

Examples 7.1.4, 7.1.5 · Exercises 7.1.4, 7.1.5
a =b =t =

Your browser's doubles (IEEE 754, b = 2, 53 significant bits)

x =
7.2

Gaussian elimination

LU factorization and its cost

Elimination without interchanges computes multipliers mki = aki/aii and factors A = LU (unit lower L holding the multipliers, upper U). Then Ax = b is solved by forward substitution Ly = b and back substitution Ux = y. The factorization costs about n3/3 multiplications; each further right-hand side costs only about n2. Doubling n makes elimination about 8 times slower.

Operation counts and timing

Algorithms 7.2.1, 7.2.2
7.3

Pivoting strategies

Avoid small pivots and large multipliers

A small pivot produces large multipliers, and large multipliers amplify rounding errors. Partial pivoting picks, in each column, the entry of largest absolute value as pivot, so every |mki| ≤ 1; the row interchanges give PA = LU. Complete pivoting searches the whole remaining submatrix and also swaps columns. Partial pivoting is the standard choice.

Elimination in t-digit arithmetic

Examples 7.3.1–7.3.3, 7.4.2 · Exercises 7.3.1–7.3.4, 7.3.7
n digits t pivoting
7.4

Matrix norms and condition numbers

How sensitive is Ax = b?

A matrix norm measures how much A can stretch a vector: ‖A‖ = max ‖Ax‖/‖x‖. For the 1- and ∞-norms this is the largest column sum or row sum of |aij|; for the 2-norm it is σ1. The condition number cond(A) = ‖A‖ ‖A−1‖ bounds how relative errors in the data grow in the solution:

Error bound (Section 7.4)(1/cond(A)) · ‖r‖/‖b‖ ≤ ‖x − x′‖/‖x‖ ≤ cond(A) · ‖r‖/‖b‖, where r = b − Ax′ is the residual of a computed x′.

Ill-conditioned systems

Examples 7.4.1–7.4.5 · Exercises 7.4

Hilbert matrices hᵢⱼ = 1/(i + j − 1): solving Hx = H·(1, …, 1)ᵀ in double precision

7.5

Orthogonal transformations

Householder reflections and Givens rotations

Orthogonal matrices do not magnify errors: ‖Qx‖2 = ‖x‖2 and cond2(Q) = 1. A Householder matrix H = I − (1/β)vvT reflects across the hyperplane orthogonal to v; choosing v = x − αe1 with α = ±‖x‖ sends x to αe1, zeroing all entries below the first. A Givens rotation zeroes one entry at a time. Applying such matrices column by column gives the stable QR factorization.

Reflect or rotate onto an axis

Examples 7.5.1–7.5.4

In ℝⁿ: zero the entries of x below position k

x =k =
7.6

The eigenvalue problem

Power method and QR algorithm

Characteristic polynomials are useless numerically. The power method repeats v = Au, u = v/(scale): if |λ1| > |λ2| ≥ ⋯, the direction converges to the dominant eigenvector and the scale to λ1, with error shrinking like |λ2/λ1|k. The QR algorithm factors Ak = QkRk and sets Ak+1 = RkQk; these are similar matrices that typically become triangular, revealing all eigenvalues on the diagonal.

Power method and QR algorithm

Example 7.6.1, 7.6.2 · Exercises 7.6

QR algorithm: A₁ = A, Ak = QkRk, Ak+1 = RkQk