Numerical Methods

All books

M05 — Eigenvalues

An eigenvalue problem asks which patterns a matrix returns unchanged, scaled by a number. The cheap method is to keep multiplying by the matrix; it always finds the largest eigenvalue, at a speed set by the gap to the next one. This notebook measures that speed, doubles it for free, aims it at any eigenvalue you name, and ends on the natural frequencies of a quarter car.

Book pages: Eigenvalues and Finding a chosen eigenvalue in books/numerical-methods. The running example is the book's matrix

A=[210131014],λ=3−3, 3, 3+3.A = \begin{bmatrix} 2 & 1 & 0 \\ 1 & 3 & 1 \\ 0 & 1 & 4 \end{bmatrix}, \qquad \lambda = 3 - \sqrt 3,\ 3,\ 3 + \sqrt 3 .

The question. Power iteration's vector converges at the rate ∣λ2/λ1∣|\lambda_2/\lambda_1|. How fast does its eigenvalue estimate converge, how do you reach an eigenvalue that is not the largest, and why does everyone call eigh instead?

By the end you can:

  • derive power iteration's rate ∣λ2/λ1∣|\lambda_2/\lambda_1| and measure it as an observed ratio of successive errors
  • explain why the Rayleigh quotient of a symmetric matrix has twice the digits
  • aim inverse iteration at any eigenvalue with a shift, and predict its rate
  • state what symmetry guarantees, and why a non-symmetric eigenvalue can move by the square root of a perturbation
  • say what eigh does (tridiagonal reduction, shifted QR) and when it lies
  • set up Kx=ω2MxKx = \omega^2 Mx for a mass–spring chain and read its modes

Assumes: M01 (observed rates and orders), M03 (LU, condition number), M04 (gradient descent); eigenvectors from a first linear-algebra course.

How to use it: predict before you reveal, commit before you check, and move the controls until the equation's behaviour stops surprising you.

Predict first. Try first: power iteration on AA multiplies the vector's error by about 0.6340.634 per step. The Rayleigh-quotient estimate vTAvv^{\mathsf T}Av of λ1\lambda_1 has its error multiplied per step by about

Choose a prediction

Check answer (without scripting)

Answer: 0.40, the square of the vector's rate. 0.6342=0.4020.634^2 = 0.402. The quotient's gradient vanishes at an eigenvector, so a vector error ε\varepsilon gives an eigenvalue error of order ε2\varepsilon^2.

Warm-up: remember (closed book)

1. Why can conjugate gradients not be applied straight to the KKT matrix (KBTB0)\begin{pmatrix}K & B^{\mathsf T}\\ B & 0\end{pmatrix}?

Question 1
How sure?

2. Why solve Ax=bAx = b with LU rather than form A−1A^{-1} and multiply?

Question 2
How sure?

3. For f(x)=exf(x) = e^x the condition number is κ(x)=∣x∣\kappa(x) = |x|. What does κ(10)=10\kappa(10) = 10 mean?

Question 3
How sure?

Show answers and explanations

1. It is indefinite: it has negative as well as positive eigenvalues. CG minimises 12zTMz−cTz\tfrac12 z^{\mathsf T}Mz - c^{\mathsf T}z, which has no minimum when MM has a negative eigenvalue. The solution is a saddle point; use MINRES, a block preconditioner or a direct solve.

2. The inverse is not backward stable for x, and costs about three times as much. x^=fl(A−1)b\hat x = \mathrm{fl}(A^{-1})b can have a backward error near κϵ\kappa\epsilon; LU's stays near ϵ\epsilon. Inversion also costs about n3n^3 against n3/3n^3/3.

3. A relative input error is amplified about tenfold, whatever method is used. Conditioning belongs to the problem. Even an exact algorithm turns a relative input error δ\delta into about 10δ10\delta in e10e^{10}.

1. Power iteration

Setting: the problem, its sets and its symbols

Problem. Given a symmetric A∈Rn×nA \in \mathbb{R}^{n \times n} whose eigenvalues satisfy ∣λ1∣>∣λ2∣≥⋯≥∣λn∣\lvert\lambda_1\rvert > \lvert\lambda_2\rvert \ge \dots \ge \lvert\lambda_n\rvert, and a start v0∈Rnv_0 \in \mathbb{R}^n with c1≠0c_1 \ne 0, find the dominant eigenpair (λ1,u1)(\lambda_1, u_1), Au1=λ1u1Au_1 = \lambda_1 u_1, as the limit of vk+1=Avk/∥Avk∥v_{k+1} = Av_k / \lVert Av_k \rVert; and find how many steps kk bring the error eke_k below a tolerance.

Symbol In Meaning
AA Rn×n\mathbb{R}^{n \times n} the matrix, symmetric; the running example has n=3n = 3
λi, ui\lambda_i,\ u_i R, Rn\mathbb{R},\ \mathbb{R}^n eigenpairs, Aui=λiuiAu_i = \lambda_i u_i, ∥ui∥=1\lVert u_i \rVert = 1, i=1,…,ni = 1, \dots, n, by decreasing ∣λi∣\lvert\lambda_i\rvert
v0v_0 Rn∖{0}\mathbb{R}^n \setminus \{0\} the start; (1,1,1)(1, 1, 1) in the table
cic_i R\mathbb{R} coordinates of the start in the eigenvectors, v0=∑iciuiv_0 = \sum_i c_i u_i
vkv_k Rn\mathbb{R}^n the normalised iterate after k∈Nk \in \mathbb{N} steps, ∥vk∥=1\lVert v_k \rVert = 1
rr [0,1)[0, 1) the gap ratio ∣λ2/λ1∣\lvert\lambda_2/\lambda_1\rvert; the slider sets it in a 4×44 \times 4 symmetric test matrix with eigenvalues 1,r,r/2,r/41, r, r/2, r/4
eke_k [0,2][0, \sqrt 2] the vector error ∥vk∓u1∥\lVert v_k \mp u_1 \rVert, sign chosen to match
m, dm,\ d R\mathbb{R} the browser kernel's mix and ratio, entries of its symmetric 2×22 \times 2 matrix
How these symbols connect

Given a symmetric A∈Rn×nA \in \mathbb{R}^{n \times n}, its eigenpairs (λi,ui)(\lambda_i, u_i) form an orthonormal basis in which any non-zero start v0v_0 has coordinates cic_i. Repeatedly applying AA and normalising maps vk↦vk+1=Avk/∥Avk∥v_k \mapsto v_{k+1} = Av_k / \lVert Av_k \rVert on the unit sphere, driving the vector error eke_k toward zero whenever c1≠0c_1 \ne 0 and the gap ratio r=∣λ2/λ1∣<1r = \lvert\lambda_2/\lambda_1\rvert \lt 1. All quantities are dimensionless; the slider sets rr for a 4×44 \times 4 test family to see how the step count kk responds, while mm and dd parameterise the browser kernel's 2×22 \times 2 symmetric matrix.

Symbol-by-symbol notes
$\lambda\lt em>i,\ u\lt /em>i$ — ordering and unit length

Eigenpairs are indexed by decreasing magnitude ∣λ1∣>∣λ2∣≥⋯≥∣λn∣\lvert\lambda_1\rvert > \lvert\lambda_2\rvert \ge \dots \ge \lvert\lambda_n\rvert, not by algebraic value (a large negative eigenvalue can be λ1\lambda_1). Fixing ∥ui∥=1\lVert u_i \rVert = 1 pins the length of each eigenvector but still leaves its sign ±ui\pm u_i free.

$c\lt em>i$ — eigenbasis coordinates of $v\lt /em>0$

Because AA is symmetric, the uiu_i are orthonormal and ci=uiTv0c_i = u_i^{\mathsf T}v_0. The requirement c1≠0c_1 \ne 0 says that the start v0v_0 is not orthogonal to the dominant eigenvector u1u_1.

$e_k$ — sign-aligned vector error

Both +u1+u_1 and −u1-u_1 are valid unit eigenvectors, and vkv_k flips sign every step whenever λ1<0\lambda_1 \lt 0. Choosing the sign in ∥vk∓u1∥\lVert v_k \mp u_1 \rVert to match vkv_k's side of u1u_1 keeps eke_k in [0,2][0, \sqrt{2}] instead of jumping to 22 on a sign flip.

$r$ vs $m,\ d$ — two test families

The slider's r∈[0,1)r \in [0, 1) is the spectral ratio ∣λ2/λ1∣\lvert\lambda_2/\lambda_1\rvert built directly into the 4×44 \times 4 benchmark matrix with eigenvalues 1,r,r/2,r/41, r, r/2, r/4. By contrast, mm (mix) and dd (ratio) are raw entries of the browser kernel's 2×22 \times 2 matrix [1mmd]\begin{bmatrix} 1 & m \\ m & d \end{bmatrix}, not its eigenvalue ratio directly.

Start with v0=(1,1,1)v_0 = (1, 1, 1) and keep multiplying by AA. The entries grow, but their proportions settle, and the stretch factor ∥Av∥/∥v∥\|Av\| / \|v\| settles on the largest eigenvalue, 3+3≈4.73213 + \sqrt 3 \approx 4.7321:

kk Akv0A^k v_0 ∥Ak+1v0∥/∥Akv0∥\lVert A^{k+1}v_0 \rVert / \lVert A^k v_0 \rVert
0 (1, 1, 1) 4.4347
1 (3, 5, 5) 4.6487
2 (11, 23, 25) 4.7012
3 (45, 105, 123) 4.7198
4 (195, 483, 597) 4.7271

Why. Write v0=∑iciuiv_0 = \sum_i c_i u_i in the eigenvectors. Each product multiplies the ii-th component by λi\lambda_i, so

Akv0=λ1k(c1u1+∑i>1ci(λiλ1)kui).A^k v_0 = \lambda_1^k \Big( c_1 u_1 + \sum_{i>1} c_i \Big(\frac{\lambda_i}{\lambda_1}\Big)^k u_i \Big).

Every ratio has magnitude below 1, so after normalising, vk→±u1v_k \to \pm u_1 and the slowest wrong component shrinks by r=∣λ2/λ1∣r = |\lambda_2/\lambda_1| per step. The error ek=∥vk∓u1∥e_k = \|v_k \mp u_1\| obeys ek+1≈r eke_{k+1} \approx r\, e_k: linear convergence.

M01 read an order off the ratio of successive errors; here the same ratio, ek+1/eke_{k+1}/e_k, is the rate, and each step gains −log⁡10r-\log_{10} r digits. Below, a 4×44 \times 4 symmetric matrix has eigenvalues 1,r,r/2,r/41, r, r/2, r/4; set rr and compare it with 0.50.5 and 0.90.9.

Figure 1

Predict first. Moving ∣λ2/λ1∣|\lambda_2/\lambda_1| from 0.50.5 to 0.90.9 multiplies the number of steps to a fixed accuracy by about

Choose a prediction

Check answer (without scripting)

Answer: 6.6. Steps to reach ε\varepsilon are about ln⁡ε/ln⁡r\ln\varepsilon / \ln r, so the factor is ln⁡0.5/ln⁡0.9=6.6\ln 0.5 / \ln 0.9 = 6.6. Near r=1r = 1 it grows like 1/(1−r)1/(1-r).

Reveal result (lock in your prediction above first)
062.212418724910⁻¹⁶10⁻¹²10⁻⁸10⁻⁴10⁰r = 0.5r = 0.9your rstep k‖v_k ∓ u₁‖
run r observed rate steps to 1e-8
r = 0.5 0.5 0.5 27
r = 0.9 0.9 0.9 175
your r 0.75 0.75 65

Measured: 27 steps at r=0.5r = 0.5 and 175 at r=0.9r = 0.9, a factor of 6.5. The observed rate settles on rr exactly: on log axes each run is a straight line of slope log⁡10r\log_{10} r.

The browser's kernel. The book's figure runs this Rust step on the symmetric 2×22 \times 2 matrix [1mmd]\begin{bmatrix} 1 & m \\ m & d \end{bmatrix} (mix =m= m, ratio =d= d). It multiplies, normalises, and reports ∥Avk∥\|Av_k\| as the eigenvalue: for a unit vkv_k that is vkTA2vk\sqrt{v_k^{\mathsf T}A^2v_k}, the Rayleigh quotient of A2A^2, so it converges as fast as §2's estimate but returns only ∣λ1∣|\lambda_1|. Its angle error compares with one eigenvector angle and ignores the sign, so a start with c1<0c_1 \lt 0 settles on −u1-u_1 and reports an error of π\pi.

source: solvers/ot-solve/src/kernels/power.rs:57-139
/// The largest eigenvalue and its eigenvector angle, in closed form.
fn dominant(ratio: f64, mix: f64) -> (f64, f64) {
    let mean = 0.5 * (1.0 + ratio);
    let radius = (0.25 * (1.0 - ratio) * (1.0 - ratio) + mix * mix).sqrt();
    let lambda = mean + radius;
    let angle = (lambda - 1.0).atan2(mix);
    (lambda, angle)
}

fn multiply(x: f64, y: f64, ratio: f64, mix: f64) -> (f64, f64) {
    (x + mix * y, mix * x + ratio * y)
}

pub fn init(a: &mut Arena<'_>) -> Status {
    let ratio = a.params()[P_RATIO];
    let mix = a.params()[P_MIX];
    let angle = a.params()[P_ANGLE];
    if !ratio.is_finite() || !mix.is_finite() || !angle.is_finite() {
        return Status::BadParameter;
    }
    if ratio <= 0.0 || ratio >= 1.0 || mix.abs() >= 1.0 {
        return Status::BadParameter;
    }
    let (lambda_exact, angle_exact) = dominant(ratio, mix);
    let state = a.state_mut();
    state[S_X] = angle.cos();
    state[S_Y] = angle.sin();
    let x = state[S_X];
    let y = state[S_Y];
    let rayleigh = x * (x + mix * y) + y * (mix * x + ratio * y);
    let out = a.out_mut();
    for value in out.iter_mut() {
        *value = 0.0;
    }
    out[O_ANGLE] = angle;
    out[O_LAMBDA] = rayleigh;
    out[O_REFERENCE] = angle_exact;
    out[O_REFERENCE + 1] = lambda_exact;
    let diag = a.diag_mut();
    diag[D_ITER] = 0.0;
    diag[D_LAMBDA] = rayleigh;
    diag[D_ANGLE] = angle;
    diag[D_ERROR] = (angle - angle_exact).abs();
    Status::Ok
}

pub fn step(a: &mut Arena<'_>) -> Status {
    let ratio = a.params()[P_RATIO];
    let mix = a.params()[P_MIX];
    if !ratio.is_finite() || !mix.is_finite() {
        return Status::BadParameter;
    }
    let iteration = a.diag()[D_ITER] as usize;
    let (_, angle_exact) = dominant(ratio, mix);
    let (x, y) = {
        let state = a.state();
        (state[S_X], state[S_Y])
    };
    let (mut next_x, mut next_y) = multiply(x, y, ratio, mix);
    let norm = (next_x * next_x + next_y * next_y).sqrt();
    if !norm.is_finite() || norm == 0.0 {
        return Status::Unstable;
    }
    next_x /= norm;
    next_y /= norm;
    let angle = next_y.atan2(next_x);
    let state = a.state_mut();
    state[S_X] = next_x;
    state[S_Y] = next_y;
    let slot = (iteration + 1).min(HISTORY - 1);
    let out = a.out_mut();
    out[O_ANGLE + slot] = angle;
    out[O_LAMBDA + slot] = norm;
    let diag = a.diag_mut();
    diag[D_ITER] += 1.0;
    diag[D_LAMBDA] = norm;
    diag[D_ANGLE] = angle;
    diag[D_ERROR] = (angle - angle_exact).abs();
    if !next_x.is_finite() || !next_y.is_finite() {
        return Status::Unstable;
    }
    Status::Ok
}
When power iteration breaks
  • Assumes: a strictly dominant eigenvalue, ∣λ1∣>∣λ2∣|\lambda_1| > |\lambda_2|, and a start vector with c1≠0c_1 \ne 0
  • When it fails: with ∣λ1∣=∣λ2∣|\lambda_1| = |\lambda_2| (a pair ±λ\pm\lambda, or a complex pair) the iterate never settles; with a ratio near 1 it crawls, about 2.3/(1−r)2.3/(1 - r) steps per digit
  • Check: measure the observed rate from successive differences of the estimate; if it sits near 1 or does not settle, switch to a shift

2. The Rayleigh quotient

Setting: the problem, its sets and its symbols

Problem. Given a matrix A∈Rn×nA \in \mathbb{R}^{n \times n}, an eigenpair (λ1,u1)(\lambda_1, u_1) and an approximate eigenvector x=u1+εwx = u_1 + \varepsilon w, find the eigenvalue estimate s∈Rs \in \mathbb{R} that minimises ∥Ax−sx∥\lVert Ax - sx \rVert, and how its error ∣ρ(x)−λ1∣\lvert \rho(x) - \lambda_1 \rvert depends on ε\varepsilon, for symmetric AA and for a non-symmetric BB.

Symbol In Meaning
AA Rn×n\mathbb{R}^{n \times n} symmetric, A=ATA = A^{\mathsf T}; the running example, n=3n = 3
BB R3×3\mathbb{R}^{3 \times 3} non-symmetric, B=SΛS−1B = S\Lambda S^{-1} with the same eigenvalues as AA and a fixed invertible SS
λ1, u1\lambda_1,\ u_1 R, Rn\mathbb{R},\ \mathbb{R}^n the eigenpair estimated, ∥u1∥=1\lVert u_1 \rVert = 1
xx Rn∖{0}\mathbb{R}^n \setminus \{0\} the approximate eigenvector
ww Rn\mathbb{R}^n the direction of the error, w⊥u1w \perp u_1, ∥w∥=1\lVert w \rVert = 1
ε\varepsilon R>0\mathbb{R}_{>0} the size of the vector error; the slider sets log⁡10ε\log_{10}\varepsilon
ρ\rho Rn∖{0}→R\mathbb{R}^n \setminus \{0\} \to \mathbb{R} the Rayleigh quotient, ρ(x)=xTAx/xTx\rho(x) = x^{\mathsf T}Ax / x^{\mathsf T}x
∇ρ\nabla \rho Rn∖{0}→Rn\mathbb{R}^n \setminus \{0\} \to \mathbb{R}^n its gradient
How these symbols connect

Starting from an eigenpair (λ1,u1)(\lambda_1, u_1) of AA (symmetric) or BB (non-symmetric with the same spectrum), perturbing u1u_1 by εw\varepsilon w along a unit orthogonal direction w⊥u1w \perp u_1 gives an approximate eigenvector x∈Rn∖{0}x \in \mathbb{R}^n \setminus \{0\}. Evaluating the Rayleigh quotient ρ:Rn∖{0}→R\rho : \mathbb{R}^n \setminus \{0\} \to \mathbb{R} maps xx to the scalar ss minimising ∥Ax−sx∥\lVert Ax - sx \rVert, while its gradient ∇ρ(x)∈Rn\nabla\rho(x) \in \mathbb{R}^n measures how sensitive ρ\rho is to small moves of xx. Every symbol is dimensionless; the slider sweeps log⁡10ε\log_{10}\varepsilon so we can compare ∣ρ(x)−λ1∣\lvert\rho(x) - \lambda_1\rvert for AA and BB as ε\varepsilon shrinks.

Symbol-by-symbol notes
$\rho(x)$ — scale-invariant Rayleigh quotient

Defined on Rn∖{0}\mathbb{R}^n \setminus \{0\} by ρ(x)=xTAx/xTx\rho(x) = x^{\mathsf T}Ax / x^{\mathsf T}x (and likewise with BB). Rescaling x↦αxx \mapsto \alpha x (α≠0\alpha \ne 0) cancels between numerator and denominator, so ρ(x)\rho(x) depends only on the direction of xx and simplifies to xTAxx^{\mathsf T}Ax when ∥x∥=1\lVert x \rVert = 1.

$w$ and $\varepsilon$ — decomposed vector error

Writing x=u1+εwx = u_1 + \varepsilon w with w⊥u1w \perp u_1 and ∥w∥=1\lVert w \rVert = 1 isolates the directional error from any harmless rescaling along u1u_1. Orthogonality gives ∥x∥2=1+ε2\lVert x \rVert^2 = 1 + \varepsilon^2.

$B = S\Lambda S^{-1}$ — same eigenvalues, no symmetry

A similarity transform leaves the spectrum Λ\Lambda unchanged, so BB has the exact same eigenvalues as AA. Because SS is invertible but not orthogonal (S−1≠STS^{-1} \ne S^{\mathsf T}), BT≠BB^{\mathsf T} \ne B and its eigenvectors are not mutually orthogonal.

$\nabla \rho(x)$ — gradient in $\mathbb{R}^n$

The map ∇ρ:Rn∖{0}→Rn\nabla\rho : \mathbb{R}^n \setminus \{0\} \to \mathbb{R}^n collects the partial derivatives of the scalar ρ(x)\rho(x) with respect to the nn coordinates of xx. Its behaviour at x=u1x = u_1 governs how ∣ρ(x)−λ1∣\lvert\rho(x) - \lambda_1\rvert responds to ε\varepsilon.

Given an approximate eigenvector xx, the best eigenvalue estimate in the least-squares sense, min⁡s∈R∥Ax−sx∥\min_{s \in \mathbb{R}} \|Ax - sx\|, is the Rayleigh quotient

ρ(x)=xTAxxTx.\rho(x) = \frac{x^{\mathsf T}Ax}{x^{\mathsf T}x}.

For symmetric AA its gradient is ∇ρ=2xTx(Ax−ρ(x) x)\nabla \rho = \frac{2}{x^{\mathsf T}x}(Ax - \rho(x)\,x), which is zero exactly at the eigenvectors. Near a stationary point a function moves quadratically: with x=u1+εwx = u_1 + \varepsilon w, w⊥u1w \perp u_1, ∥w∥=1\|w\| = 1,

ρ(x)−λ1=ε2(wTAw−λ1)1+ε2=O(ε2).\rho(x) - \lambda_1 = \frac{\varepsilon^2 (w^{\mathsf T}Aw - \lambda_1)}{1 + \varepsilon^2} = O(\varepsilon^2).

For a non-symmetric BB the cross term ε u1TBw\varepsilon\, u_1^{\mathsf T}Bw survives, and the error is O(ε)O(\varepsilon). Move ε\varepsilon: the symmetric error falls two decades per decade, the non-symmetric one only one. The non-symmetric BB below has the same eigenvalues as AA.

ε\varepsilon error of ρ\rho, symmetric AA error of ρ\rho, non-symmetric BB
1.0e-03 1.73e-06 9.69e-04
Reveal result (lock in your prediction above first)
09.7519.529.23910⁻¹⁶10⁻¹²10⁻⁸10⁻⁴10⁰vector, Aquotient, Aquotient, Bstep kerror (eigenvalue error is relative)

Observed rates: vector, A 0.634, quotient, A 0.402, quotient, B 0.634. The square of the vector's rate is 0.402. The symmetric eigenvalue reaches rounding in about half the steps the vector needs.

When the Rayleigh quotient breaks
  • Assumes: a symmetric matrix, so the quotient is stationary at every eigenvector
  • When it fails: for a non-symmetric matrix the error is first order: no doubled digits, and the eigenvalue converges only as fast as the vector
  • Check: compare the eigenvalue's observed rate with the vector's: it should be the square

3. Inverse iteration and shifts

Setting: the problem, its sets and its symbols

Problem. Given a symmetric A∈Rn×nA \in \mathbb{R}^{n \times n} and a shift σ∈R\sigma \in \mathbb{R} that is not an eigenvalue of AA, find the eigenpair (λ,u)(\lambda, u) of AA whose λ\lambda is nearest σ\sigma, by power iteration on (A−σI)−1(A - \sigma I)^{-1} without forming the inverse, and find its rate.

Symbol In Meaning
AA Rn×n\mathbb{R}^{n \times n} symmetric; the running example, eigenvalues 3−3, 3, 3+33 - \sqrt 3,\ 3,\ 3 + \sqrt 3
σ\sigma R∖{λ1,…,λn}\mathbb{R} \setminus \{\lambda_1, \dots, \lambda_n\} the shift, set by the slider
μ\mu R\mathbb{R} an eigenvalue of (A−σI)−1(A - \sigma I)^{-1}; λ=σ+1/μ\lambda = \sigma + 1/\mu
λnear, λnext\lambda_{\text{near}},\ \lambda_{\text{next}} R\mathbb{R} the eigenvalues of AA nearest and next nearest σ\sigma
P, L, UP,\ L,\ U Rn×n\mathbb{R}^{n \times n} permutation, unit lower and upper triangular factors, P(A−σI)=LUP(A - \sigma I) = LU, computed once
vk, wv_k,\ w Rn\mathbb{R}^n the iterate and the solve's result, (A−σI)w=vk(A - \sigma I)w = v_k, vk+1=w/∥w∥v_{k+1} = w / \lVert w \rVert
κ(A−σI)\kappa(A - \sigma I) [1,∞)[1, \infty) the 2-norm condition number (M03)
ρk\rho_k R\mathbb{R} Rayleigh quotient iteration's shift at step kk, ρk=ρ(vk)\rho_k = \rho(v_k), the Rayleigh quotient of §2
How these symbols connect

Choosing a shift σ∈R\sigma \in \mathbb{R} away from the spectrum of symmetric AA defines the invertible shifted matrix A−σIA - \sigma I, whose eigenvalues λi−σ\lambda_i - \sigma invert to μi=1/(λi−σ)\mu_i = 1/(\lambda_i - \sigma) under (A−σI)−1(A - \sigma I)^{-1}. Factorising P(A−σI)=LUP(A - \sigma I) = LU once lets each step solve (A−σI)w=vk(A - \sigma I)w = v_k and normalise vk+1=w/∥w∥v_{k+1} = w/\lVert w \rVert, targeting the eigenvalue λnear\lambda_{\text{near}} closest to σ\sigma against its runner-up λnext\lambda_{\text{next}}. All quantities are dimensionless; κ(A−σI)\kappa(A - \sigma I) tracks the shifted matrix's conditioning as σ\sigma nears an eigenvalue, and ρk=ρ(vk)\rho_k = \rho(v_k) lets the shift update at every step.

Symbol-by-symbol notes
$\sigma$ and $\mu$ — shifting and inverting the spectrum

Excluding {λ1,…,λn}\{\lambda_1, \dots, \lambda_n\} keeps A−σIA - \sigma I non-singular so (A−σI)−1(A - \sigma I)^{-1} exists. An eigenpair (μ,u)(\mu, u) of (A−σI)−1(A - \sigma I)^{-1} maps back to AA via λ=σ+1/μ\lambda = \sigma + 1/\mu with the exact same eigenvector uu.

$\lambda\lt em>{\text{near}},\ \lambda\lt /em>{\text{next}}$ — ordered by distance to $\sigma$

Unlike §1, where eigenvalues were ordered by ∣λi∣\lvert\lambda_i\rvert, here they are ordered by ∣λi−σ∣\lvert\lambda_i - \sigma\rvert: λnear\lambda_{\text{near}} minimises that distance and λnext\lambda_{\text{next}} is second closest. Dragging the σ\sigma slider across the spectrum swaps which eigenvalues of AA play each role.

$P,\ L,\ U$ and $w$ — solve without forming the inverse

The LU factorisation P(A−σI)=LUP(A - \sigma I) = LU (M03) is computed once for a fixed σ\sigma, then reused to solve (A−σI)w=vk(A - \sigma I)w = v_k in O(n2)O(n^2) work per step. Note ww is the unnormalised solve result before rescaling to vk+1=w/∥w∥v_{k+1} = w/\lVert w \rVert.

$\kappa(A - \sigma I)$ and $\rho_k$ — near-singular and moving shifts

For symmetric AA, κ(A−σI)=max⁡i∣λi−σ∣/min⁡i∣λi−σ∣\kappa(A - \sigma I) = \max_i\lvert\lambda_i - \sigma\rvert / \min_i\lvert\lambda_i - \sigma\rvert, which grows arbitrarily large as σ\sigma approaches λnear\lambda_{\text{near}}. Rayleigh quotient iteration replaces the fixed σ\sigma with ρk=ρ(vk)\rho_k = \rho(v_k) from §2 at each step kk, so A−ρkIA - \rho_k I changes and requires a fresh factorisation every step.

Power iteration only reaches the largest ∣λ∣|\lambda|. To reach another, change the matrix, not the method. If Au=λuAu = \lambda u then

(A−σI)−1u=1λ−σ u,(A - \sigma I)^{-1} u = \frac{1}{\lambda - \sigma}\, u,

so the eigenvectors are unchanged and the eigenvalue nearest σ\sigma becomes the largest. Power iteration on (A−σI)−1(A - \sigma I)^{-1} therefore finds it, at the rate

∣λnear−σ∣∣λnext−σ∣,\frac{|\lambda_{\text{near}} - \sigma|}{|\lambda_{\text{next}} - \sigma|},

and λ=σ+1/μ\lambda = \sigma + 1/\mu recovers it from the iteration's eigenvalue μ\mu. The inverse is never formed: each step solves (A−σI) w=v(A - \sigma I)\,w = v. That is M03: factor once, P(A−σI)=LUP(A - \sigma I) = LU for O(n3)O(n^3), then two triangular solves, O(n2)O(n^2), per step. Move σ\sigma across the spectrum 1.27, 3, 4.731.27,\ 3,\ 4.73.

110.820.530.24010⁻¹⁶10⁻¹²10⁻⁸10⁻⁴10⁰inverse iteration at σpower iteration on Astep kvector error
σ\sigma eigenvalue found predicted rate observed rate
2.55 3.0000000000 0.3510 0.3510

Predict first. Put σ=3+10−10\sigma = 3 + 10^{-10}, a hair from the eigenvalue 3. Now A−σIA - \sigma I has condition number about 101010^{10} (M03: expect to lose ten digits in the solve). After one step of inverse iteration the eigenvector's error is about

Choose a prediction

Check answer (without scripting)

Answer: 1e-10, then rounding level a step later. The wanted component grows by 101010^{10} and the rest by about 1, so one step leaves a relative error near 10−1010^{-10}.

Reveal result (lock in your prediction above first)

κ(A−σI)\kappa(A - \sigma I) = 1.73e+10. Eigenvector errors after steps 1, 2, 3: 1.6e-10, 3.5e-16, 3.5e-16; the eigenvalue found is 3.000000000000001. The near-singularity is the point of the method, not a hazard: the closer the shift, the faster it converges. Only an exactly zero pivot fails (at σ=3\sigma = 3 exactly, LU of this matrix has one), and moving σ\sigma by ϵ∥A∥\epsilon\|A\| cures it.

Rayleigh quotient iteration takes this to its end: use the current Rayleigh quotient as the shift at every step. The rate then tends to zero, and for symmetric AA the error is cubed each step: the digits roughly triple. From v0=(1,1,1)v_0 = (1,1,1):

step shift ρk\rho_k error of ρk\rho_k
0 4.333333333333335 4.0e-01
1 4.707417179712695 2.5e-02
2 4.732046272438820 4.5e-06
3 4.732050807568878 8.9e-16
4 4.732050807568877 1.8e-15

The price: a new factorisation every step, since the shift moves, and no control over which eigenvalue it lands on.

When inverse iteration breaks
  • Assumes: a shift strictly nearer the wanted eigenvalue than any other, and a factorisation with no exactly zero pivot
  • When it fails: a shift midway between two eigenvalues gives a rate of 1 and no convergence; a shift exactly on an eigenvalue gives a zero pivot and infinities
  • Check: watch the residual ∥Av−ρv∥\|Av - \rho v\| fall; on a zero pivot, move σ\sigma by about ϵ∥A∥\epsilon\|A\|

4. What symmetry guarantees

Setting: the problem, its sets and its symbols

Problem. Given A∈Rn×nA \in \mathbb{R}^{n \times n} and a perturbation E∈Rn×nE \in \mathbb{R}^{n \times n} with ∥E∥2=δ\lVert E \rVert_2 = \delta, bound the distance from each eigenvalue of A+EA + E to the nearest eigenvalue of AA: for symmetric AA, for diagonalisable A=VΛV−1A = V\Lambda V^{-1}, and for the defective Jordan block JJ.

Symbol In Meaning
AA Rn×n\mathbb{R}^{n \times n} the matrix; when symmetric, A=QΛQTA = Q\Lambda Q^{\mathsf T}, as for the running example
QQ Rn×n\mathbb{R}^{n \times n} orthogonal, QTQ=IQ^{\mathsf T}Q = I; its columns are eigenvectors
Λ\Lambda Cn×n\mathbb{C}^{n \times n} diagonal, the eigenvalues
VV Cn×n\mathbb{C}^{n \times n} invertible eigenvector matrix of a diagonalisable matrix
κ(V)\kappa(V) [1,∞)[1, \infty) ∥V∥2∥V−1∥2\lVert V \rVert_2 \lVert V^{-1} \rVert_2, M03's condition number
EE Rn×n\mathbb{R}^{n \times n} the perturbation: ±δ\pm\delta in AA's (1,3)(1,3) and (3,1)(3,1) entries, or in JJ's (2,1)(2,1) entry
δ\delta R>0\mathbb{R}_{>0} its size; the slider sets log⁡10δ\log_{10}\delta, the switch its sign
JJ R2×2\mathbb{R}^{2 \times 2} the Jordan block below: one eigenvalue, one eigenvector
eje_j Rn\mathbb{R}^n the jj-th standard basis vector
κ(A)\kappa(A) [1,∞)[1, \infty) in the M04 aside, AA's condition number, λmax⁡/λmin⁡\lambda_{\max}/\lambda_{\min} for symmetric positive definite AA
How these symbols connect

Adding a perturbation E∈Rn×nE \in \mathbb{R}^{n \times n} of 2-norm δ\delta to AA (or to the 2×22 \times 2 Jordan block JJ) shifts its eigenvalues in C\mathbb{C} by an amount governed by the matrix's eigendecomposition. For diagonalisable A=VΛV−1A = V\Lambda V^{-1}, the eigenvector condition number κ(V)\kappa(V) enters the bound — collapsing to κ(Q)=1\kappa(Q) = 1 when AA is symmetric (V=QV = Q orthogonal) — whereas JJ has no invertible VV at all. Every quantity is dimensionless; the slider sets log⁡10δ\log_{10}\delta and the switch flips the sign of EE, while κ(A)\kappa(A) ties the spectrum back to M04's gradient-descent rate.

Symbol-by-symbol notes
$Q$ vs $V$ — orthogonal versus general eigenbasis

For real symmetric AA, Q∈Rn×nQ \in \mathbb{R}^{n \times n} satisfies QTQ=IQ^{\mathsf T}Q = I, so Q−1=QTQ^{-1} = Q^{\mathsf T} and κ(Q)=1\kappa(Q) = 1. For a general diagonalisable matrix, V∈Cn×nV \in \mathbb{C}^{n \times n} need only be invertible; nearly parallel columns can make κ(V)\kappa(V) arbitrarily large.

$\Lambda$ in $\mathbb{C}^{n \times n}$

Even when AA and EE have purely real entries, non-symmetric matrices can have complex eigenvalues, so Λ\Lambda and VV live over C\mathbb{C} in general. Symmetry restricts both Λ\Lambda and QQ to Rn×n\mathbb{R}^{n \times n}.

$\kappa(V)$ vs $\kappa(A)$ — two different condition numbers

κ(V)=∥V∥2∥V−1∥2\kappa(V) = \lVert V \rVert_2 \lVert V^{-1} \rVert_2 measures how non-orthogonal the eigenvectors are and controls eigenvalue sensitivity under perturbations EE. By contrast, κ(A)=λmax⁡/λmin⁡\kappa(A) = \lambda_{\max}/\lambda_{\min} (for SPD AA) measures the spread of the eigenvalues themselves and governs linear-solve and gradient-descent behaviour (M03, M04).

$J$ and $e_j$ — a defective matrix and its perturbation

The 2×22 \times 2 Jordan block J=[1101]J = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} has repeated eigenvalue 11 with only a one-dimensional eigenspace, so no invertible VV satisfies J=VΛV−1J = V\Lambda V^{-1}. Its perturbation E=±δe2e1TE = \pm\delta e_2 e_1^{\mathsf T} places ±δ\pm\delta in the (2,1)(2, 1) entry, where eje_j is the jj-th standard basis vector.

$\delta$ and $E$ — magnitude and sign

δ>0\delta > 0 is the 2-norm ∥E∥2\lVert E \rVert_2 set by the log⁡10δ\log_{10}\delta slider. The switch toggles the sign of the perturbed entry (or symmetric corner pair in AA) between +δ+\delta and −δ-\delta.

For real A=ATA = A^{\mathsf T} the spectral theorem gives A=QΛQTA = Q\Lambda Q^{\mathsf T} with QQ orthogonal and Λ\Lambda real: real eigenvalues, and an orthonormal set of eigenvectors even when eigenvalues repeat.

Eigenvalues are well conditioned. For any diagonalisable A=VΛV−1A = V\Lambda V^{-1} and a perturbation EE, each eigenvalue of A+EA + E lies within κ(V) ∥E∥2\kappa(V)\,\|E\|_2 of an eigenvalue of AA (Bauer–Fike). The condition number is M03's, applied to the eigenvector matrix. Symmetric means V=QV = Q, κ(Q)=1\kappa(Q) = 1: an eigenvalue moves no more than the perturbation. A non-symmetric matrix can have κ(V)\kappa(V) huge, or no eigenbasis at all, like the Jordan block and its perturbation

J=[1101],J+[00δ0].J = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}, \qquad J + \begin{bmatrix} 0 & 0 \\ \delta & 0 \end{bmatrix}.

Bauer–Fike says nothing here, since JJ has no VV. Predict before you compute.

Predict first. Perturb one entry of JJ by δ=10−10\delta = 10^{-10}. Its eigenvalues move by about

Choose a prediction

Check answer (without scripting)

Answer: 1e-5. The characteristic polynomial is (1−λ)2−δ(1-\lambda)^2 - \delta, so λ=1±δ\lambda = 1 \pm \sqrt\delta: a perturbation in the tenth digit moves the eigenvalue in the fifth.

Reveal result (lock in your prediction above first)

The characteristic polynomial of J+δe2e1TJ + \delta e_2e_1^{\mathsf T} is (1−λ)2−δ(1 - \lambda)^2 - \delta, so its eigenvalues are 1±δ1 \pm \sqrt\delta.

Real stays real, for symmetric matrices only. With −δ-\delta instead, they become 1±iδ1 \pm i\sqrt{\delta}: a real matrix, nudged in its tenth digit, with complex eigenvalues. A symmetric matrix cannot do that. Below, AA gets δ\delta in its two corner entries (staying symmetric) and JJ gets it in one.

matrix computed eigenvalues largest move
A+δA + \delta (symmetric) 1.267949192464, 2.999999999933, 4.732050807602 6.7e-11
J+δJ + \delta 1.00001000 +0.00000000i, 0.99999000 +0.00000000i 1.0e-05
10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²A (symmetric)J (Jordan block)perturbation δlargest eigenvalue move

Read the slopes as M01 read an order: slope 1 for the symmetric matrix, slope 12\tfrac12 for the Jordan block. A defective eigenvalue has a square-root sensitivity, and no algorithm can remove it: it belongs to the problem.

M04 again. Gradient descent on 12xTAx−bTx\tfrac12 x^{\mathsf T}Ax - b^{\mathsf T}x with the best fixed step contracts by (κ(A)−1)/(κ(A)+1)(\kappa(A) - 1)/(\kappa(A) + 1) per step, where κ(A)=λmax⁡/λmin⁡\kappa(A) = \lambda_{\max}/\lambda_{\min}. Here κ(A)\kappa(A) = 3.7321, rate 0.5774, and the step must stay below 2/λmax⁡2/\lambda_{\max} = 0.4226. Both ends of the spectrum decide an optimiser's speed; power iteration finds the top one cheaply, and inverse iteration at σ=0\sigma = 0 finds the bottom one.

5. What you actually call: eigh and the QR algorithm

Setting: the problem, its sets and its symbols

Problem. Given a dense symmetric A∈Rn×nA \in \mathbb{R}^{n \times n}, find every eigenpair at once: an orthogonal VV and a real diagonal Λ\Lambda with AV=VΛAV = V\Lambda, by orthogonal similarity transforms in O(n3)O(n^3) flops.

Symbol In Meaning
AA Rn×n\mathbb{R}^{n \times n} symmetric and dense; the running example is already tridiagonal, and a random n=200n = 200 matrix tests eigh
QQ Rn×n\mathbb{R}^{n \times n} orthogonal, a product of Householder reflections
TT Rn×n\mathbb{R}^{n \times n} symmetric tridiagonal, T=QTAQT = Q^{\mathsf T}AQ
Tk, AkT_k,\ A_k Rn×n\mathbb{R}^{n \times n} the QR algorithm's iterate after k∈Nk \in \mathbb{N} steps; AkA_k when it starts from AA
Qk, RkQ_k,\ R_k Rn×n\mathbb{R}^{n \times n} orthogonal and upper triangular, Tk=QkRkT_k = Q_kR_k, Tk+1=RkQkT_{k+1} = R_kQ_k
μ\mu R\mathbb{R} the shift, the iterate's bottom-right entry
V, ΛV,\ \Lambda Rn×n\mathbb{R}^{n \times n} eigh's output: eigenvectors viv_i as columns, eigenvalues λi\lambda_i on the diagonal
EE Rn×n\mathbb{R}^{n \times n} the backward error: the computed eigenvalues are exact for A+EA + E
ϵ\epsilon R>0\mathbb{R}_{>0} machine precision, about 10−1610^{-16} in double
How these symbols connect

Given a dense symmetric A∈Rn×nA \in \mathbb{R}^{n \times n}, eigh first applies an orthogonal similarity T=QTAQT = Q^{\mathsf T}AQ to produce a symmetric tridiagonal TT with the same eigenvalues, then runs shifted QR steps Tk−μI=QkRkT_k - \mu I = Q_k R_k, Tk+1=RkQk+μIT_{k+1} = R_k Q_k + \mu I until the off-diagonal entries vanish. Accumulating the orthogonal transforms yields the computed eigenpairs (V,Λ)(V, \Lambda) with AV≈VΛAV \approx V\Lambda, exact for a perturbed matrix A+EA + E whose backward error EE scales with machine precision ϵ\epsilon. All quantities are dimensionless; the slider steps kk through unshifted QR iterates AkA_k on the already-tridiagonal running example AA.

Symbol-by-symbol notes
$Q$ vs $Q_k$ — initial reduction versus QR step

QQ is the single product of Householder reflections that reduces dense AA to tridiagonal T=QTAQT = Q^{\mathsf T}AQ in O(n3)O(n^3) flops before iteration begins. Each QkQ_k is the orthogonal factor from one QR factorisation Tk=QkRkT_k = Q_k R_k (or shifted step) inside the iteration.

$T\lt em>k$ vs $A\lt /em>k$ — iterate notation

Both denote the matrix after kk QR steps: TkT_k emphasises that a dense matrix is first reduced to tridiagonal form (which QR preserves), whereas AkA_k appears in the display below because the running example AA is already tridiagonal so T=AT = A.

$\mu$ — the QR shift

Unlike §3, where μ\mu stood for an eigenvalue of (A−σI)−1(A - \sigma I)^{-1}, here μ∈R\mu \in \mathbb{R} is the scalar shift subtracted before factorising — taken as the iterate's bottom-right entry in the shifted loop below.

$E$ and $\epsilon$ — backward error and machine precision

Backward stability guarantees that the computed eigenvalues in Λ\Lambda are exact for some A+EA + E with ∥E∥2\lVert E \rVert_2 of order ϵ∥A∥2\epsilon\lVert A \rVert_2, where ϵ≈2.2×10−16\epsilon \approx 2.2 \times 10^{-16} is double-precision machine epsilon (M01). Combined with §4's symmetric bound, that turns directly into an eigenvalue accuracy guarantee.

Power iteration finds one eigenpair at a speed set by a gap you do not control. For a dense symmetric matrix, numpy.linalg.eigh (LAPACK) finds all of them:

  1. Reduce to tridiagonal form T=QTAQT = Q^{\mathsf T}AQ with Householder reflections, about 43n3\tfrac43 n^3 flops. A similarity transform keeps the eigenvalues; orthogonal QQ keeps the conditioning.
  2. Iterate on TT. The QR algorithm factors Tk=QkRkT_k = Q_kR_k and forms Tk+1=RkQk=QkTTkQkT_{k+1} = R_kQ_k = Q_k^{\mathsf T}T_kQ_k, another similarity. Each step is power iteration on all columns at once (and inverse iteration on the last), so the subdiagonal entry (i+1,i)(i+1, i) shrinks by ∣λi+1/λi∣|\lambda_{i+1}/\lambda_i| per step.
  3. Shift. With a shift taken from the bottom corner (the Rayleigh quotient of the last column), that last step is Rayleigh quotient iteration, and the corner entry falls cubically. Deflate, repeat on the smaller block.

The result is backward stable: the computed eigenvalues are exact for some A+EA + E with ∥E∥≈ϵ∥A∥\|E\| \approx \epsilon\|A\|, and §4's symmetric bound turns that into an absolute eigenvalue error of about ϵ∥A∥\epsilon\|A\|. Move the slider to run unshifted QR on AA (already tridiagonal).

18.2515.522.83010⁻¹⁸10⁻¹⁴10⁻¹⁰10⁻⁶10⁻²|a₂₁|, no shift|a₃₂|, no shift|a₃₂|, shiftedQR stepoff-diagonal entry
A6=[4.6792070.2979050.0000000.2979053.0524180.0273880.0000000.0273881.268376]A_{6} = \begin{bmatrix} 4.679207 & 0.297905 & 0.000000\\ 0.297905 & 3.052418 & 0.027388\\ 0.000000 & 0.027388 & 1.268376 \end{bmatrix}

Observed rates at step 10: ∣a21∣|a_{21}| 0.6343 against λ2/λ1\lambda_2/\lambda_1 = 0.6340; ∣a32∣|a_{32}| 0.4225 against λ3/λ2\lambda_3/\lambda_2 = 0.4226. The diagonal sorts itself largest first. The shifted corner entry needs a handful of steps, not dozens.

On a random symmetric 200×200200 \times 200 matrix, eigh returns max⁡i∥Avi−λivi∥/∥A∥\max_i \|Av_i - \lambda_i v_i\| / \|A\| = 1.6e-15 and max⁡∣VTV−I∣\max |V^{\mathsf T}V - I| = 2.7e-15: residual and orthogonality both at rounding level, every pair at once, no rate to wait on. Power iteration is still what you write when the matrix is too large to store and you can only multiply by it; scipy.sparse.linalg.eigsh (Lanczos) is the grown-up form, and its sigma= argument is §3's shift-invert.

The trap. Change AA's (1,2)(1,2) entry from 1 to 5, making it non-symmetric, and call eigh: it returns 1.2679, 3.0000, 4.7321, which are AA's eigenvalues, because eigh read only the lower triangle. The true eigenvalues are 0.1049, 3.6027, 5.2924.

When `eigh` breaks
  • Assumes: the matrix really is symmetric; eigh reads only one triangle
  • When it fails: a non-symmetric input returns the eigenvalues of a different matrix, silently
  • Check: np.allclose(A, A.T) before the call, and the residual ∥AV−VΛ∥\|AV - V\Lambda\| after it

6. Natural frequencies and mode shapes

Setting: the problem, its sets and its symbols

Problem. Given masses ms,mu>0m_s, m_u > 0 and stiffnesses ks,kt>0k_s, k_t > 0, find every pair (ω2,x^)∈R×(R2∖{0})(\omega^2, \hat x) \in \mathbb{R} \times (\mathbb{R}^2 \setminus \{0\}) with Kx^=ω2Mx^K\hat x = \omega^2 M\hat x, so that x(t)=x^cos⁡ωtx(t) = \hat x \cos\omega t solves Mx¨+Kx=0M\ddot x + Kx = 0: the natural frequencies and mode shapes of the quarter car.

Symbol In Meaning
ms, mum_s,\ m_u R>0\mathbb{R}_{>0} body (sprung) and wheel (unsprung) masses, kg; ms=250m_s = 250 kg, mum_u by slider
ks, ktk_s,\ k_t R>0\mathbb{R}_{>0} suspension and tyre stiffnesses, N/m; ks=20k_s = 20 kN/m, ktk_t by slider
tt R≥0\mathbb{R}_{\ge 0} time, s
xx C2(R≥0,R2)C^2(\mathbb{R}_{\ge 0}, \mathbb{R}^2) displacements of body and wheel from rest, m
M, KM,\ K R2×2\mathbb{R}^{2 \times 2} mass (kg) and stiffness (N/m) matrices, symmetric, MM positive definite
ω1, ω2\omega_1,\ \omega_2 R≥0\mathbb{R}_{\ge 0} natural angular frequencies, rad/s, ω1≤ω2\omega_1 \le \omega_2; f=ω/2πf = \omega/2\pi in Hz
x^\hat x R2∖{0}\mathbb{R}^2 \setminus \{0\} a mode shape: body and wheel amplitudes, defined up to scale
XX R2×2\mathbb{R}^{2 \times 2} the mode shapes as columns, scaled so XTMX=IX^{\mathsf T}MX = I
LL R2×2\mathbb{R}^{2 \times 2} lower triangular Cholesky factor, M=LLTM = LL^{\mathsf T}
yy R2\mathbb{R}^2 y=LTx^y = L^{\mathsf T}\hat x, the symmetric problem's eigenvector
How these symbols connect

The physical parameters — body and wheel masses ms,mum_s, m_u (kg) and suspension and tyre stiffnesses ks,ktk_s, k_t (N/m) — assemble into the symmetric 2×22 \times 2 mass matrix MM (kg) and stiffness matrix KK (N/m) in Newton's law Mx¨(t)+Kx(t)=0M\ddot x(t) + Kx(t) = 0 for the displacements x(t)x(t) (m). Substituting x(t)=x^cos⁡ωtx(t) = \hat x\cos\omega t converts the differential equation into the generalised eigenproblem Kx^=ω2Mx^K\hat x = \omega^2 M\hat x, where ω2\omega^2 has units (N/m)/kg=s−2(\text{N/m})/\text{kg} = \text{s}^{-2} (ω\omega in rad/s, f=ω/2πf = \omega/2\pi in Hz). Factorising M=LLTM = LL^{\mathsf T} and setting y=LTx^y = L^{\mathsf T}\hat x reduces it to a standard symmetric eigenproblem for L−1KL−TL^{-1}KL^{-\mathsf T}, whose orthonormal eigenvectors map back to the MM-orthogonal mode-shape matrix XX.

Symbol-by-symbol notes
$x(t)$ vs $\hat x$ — motion versus mode shape

x:R≥0→R2x : \mathbb{R}_{\ge 0} \to \mathbb{R}^2 is the time-varying vertical displacement vector (body first, wheel second, in m) from static equilibrium. x^∈R2∖{0}\hat x \in \mathbb{R}^2 \setminus \{0\} is a time-independent amplitude pattern (defined up to non-zero scale) in which both masses oscillate at the same frequency ω\omega.

$\omega\lt em>1,\ \omega\lt /em>2$ vs $f$ — angular and ordinary frequency

The eigenvalue of Kx^=ω2Mx^K\hat x = \omega^2 M\hat x is ω2\omega^2 in (rad/s)2(\text{rad/s})^2, ordered 0≤ω1≤ω20 \le \omega_1 \le \omega_2. Taking ω2\sqrt{\omega^2} gives angular frequency ω\omega in rad/s, and dividing by 2π2\pi converts to ff in Hz (cycles per second).

$X$ — $M$-orthogonal mode shapes

The columns of XX are the two mode shapes x^1,x^2\hat x_1, \hat x_2, scaled by scipy.linalg.eigh(K, M) so that XTMX=IX^{\mathsf T}MX = I (giving XX units of kg−1/2\text{kg}^{-1/2}). They are orthogonal in the mass-weighted inner product x^1TMx^2=0\hat x_1^{\mathsf T}M\hat x_2 = 0, not in the ordinary Euclidean dot product x^1Tx^2\hat x_1^{\mathsf T}\hat x_2.

$L$ and $y$ — symmetrising the generalised problem

Because MM is symmetric positive definite, it has a unique lower-triangular Cholesky factor LL with positive diagonal (M=LLTM = LL^{\mathsf T}; for diagonal MM here, L=diag⁡(ms,mu)L = \operatorname{diag}(\sqrt{m_s}, \sqrt{m_u})). Changing variables to y=LTx^y = L^{\mathsf T}\hat x yields the symmetric eigenproblem (L−1KL−T)y=ω2y(L^{-1}KL^{-\mathsf T})y = \omega^2 y without forming M−1KM^{-1}K.

$k\lt em>s,\ k\lt /em>t$ — kN/m on the slider, N/m in $K$

The tyre slider is in kN/m (103 N/m10^3\text{ N/m}) and ks=20 kN/m=2×104 N/mk_s = 20\text{ kN/m} = 2 \times 10^4\text{ N/m}. Converting to N/m before assembling KK ensures K/MK/M has units s−2\text{s}^{-2} rather than 103 s−210^3\,\text{s}^{-2}.

A quarter car, linearised, is a two-mass chain: the road, the tyre spring ktk_t, the wheel mum_u, the suspension spring ksk_s, the body msm_s. With xx the displacements of body and wheel from rest, Newton's law for each mass gives

Mx¨+Kx=0,M=[ms00mu],K=[ks−ks−ksks+kt].M\ddot x + Kx = 0, \qquad M = \begin{bmatrix} m_s & 0 \\ 0 & m_u \end{bmatrix}, \quad K = \begin{bmatrix} k_s & -k_s \\ -k_s & k_s + k_t \end{bmatrix}.

Try x(t)=x^cos⁡ωtx(t) = \hat x \cos \omega t: then x¨=−ω2x\ddot x = -\omega^2 x and

Kx^=ω2Mx^,K\hat x = \omega^2 M\hat x,

the generalised eigenproblem. Each eigenvalue is a squared natural frequency, each eigenvector a mode shape: a pattern in which every mass moves in step. Both matrices are symmetric and MM is positive definite, so with M=LLTM = LL^{\mathsf T} (Cholesky) and y=LTx^y = L^{\mathsf T}\hat x it becomes the symmetric L−1KL−Ty=ω2yL^{-1}KL^{-\mathsf T}y = \omega^2 y, and §4's guarantees apply: real ω2≥0\omega^2 \ge 0, modes orthogonal in the MM inner product. That is what scipy.linalg.eigh(K, M) does. The body is ms=250m_s = 250 kg on ks=20k_s = 20 kN/m; set the tyre and the wheel.

Predict first. In the lower mode (body bounce, near 1.4 Hz), the wheel moves

Choose a prediction

Check answer (without scripting)

Answer: the same way as the body, but much less. The tyre is ten times stiffer than the suspension spring, so it deflects about a tenth as much: the wheel follows the body at roughly 9% of its travel.

Reveal result (lock in your prediction above first)
bodywheelmassmode shape (largest entry = 1)
bounce wheel hop
eigh(K, M), Hz 1.3565 12.6256
one-mass estimate, Hz 1.3573 12.6182
wheel / body amplitude 0.0920 -77.66

The one-mass estimates treat bounce as the body on the springs in series, kskt/(ks+kt)k_sk_t/(k_s + k_t), and hop as the wheel between both springs with the body still; they are close because the two frequencies are far apart. The modes satisfy x1TMx2x_1^{\mathsf T}Mx_2 = 2.6e-19, but their plain cosine is -0.0788: orthogonal in mass, not in space.

The methods, on the physics. Power iteration on M−1KM^{-1}K finds wheel hop, the largest. Ride engineers want bounce, the smallest, so §3 at σ=0\sigma = 0: solve Kw=MvKw = Mv each step. Its vector rate is ω12/ω22\omega_1^2/\omega_2^2 = 0.0115, and the Rayleigh quotient vTKv/vTMvv^{\mathsf T}Kv / v^{\mathsf T}Mv squares it: relative errors after three steps from (1,1)(1, 1) are 1.3e-03, 1.7e-07, 2.3e-11.

This chain is the bridge to the S track: the quarter car there has these two modes, and the compliant corner adds bush stiffnesses to KK, which moves both.

When the generalised problem $Kx = \omega^2 Mx$ breaks
  • Assumes: KK symmetric and MM symmetric positive definite, so a Cholesky factor of MM exists
  • When it fails: a massless degree of freedom makes MM singular: the Cholesky step fails and the problem has infinite eigenvalues (a constraint, in the book's words)
  • Check: scipy.linalg.eigh(K, M) raises LinAlgError when MM is not positive definite; after it, XTMXX^{\mathsf T}MX should be the identity

Practice

Practice A (steps partly filled). A symmetric matrix has eigenvalues 1010, 99 and 22. Power iteration's rate is r=9/10r = 9/10; the steps to cut the vector error by 10610^{6} are k=ln⁡(10−6)/ln⁡r=  ?k = \ln(10^{-6}) / \ln r = \;? Enter kk.

Worked solution

k=ln⁡(10−6)/ln⁡0.9=−13.82/−0.1054≈131k = \ln(10^{-6})/\ln 0.9 = -13.82 / -0.1054 \approx 131. Each step gains only 0.0460.046 digits; a shift is the cure.

Practice B (with a hint). Inverse iteration on the book's AA (eigenvalues 1.2681.268, 33, 4.7324.732) with shift σ=2.5\sigma = 2.5. Enter the rate at which the vector error falls per step.

Worked solution

Distances from 2.5: ∣3−2.5∣=0.5|3 - 2.5| = 0.5, ∣1.268−2.5∣=1.232|1.268 - 2.5| = 1.232, ∣4.732−2.5∣=2.232|4.732 - 2.5| = 2.232. It converges to 3 at rate 0.5/1.232=0.4060.5 / 1.232 = 0.406, slower than §3's σ=2.9\sigma = 2.9 because the shift sits nearer the halfway point.

Hint 1

The iteration's eigenvalues are 1/(λi−σ)1/(\lambda_i - \sigma); the rate is the second largest magnitude over the largest.

Hint 2

Equivalently ∣λnear−σ∣/∣λnext−σ∣|\lambda_{\text{near}} - \sigma| / |\lambda_{\text{next}} - \sigma|: which eigenvalue is nearest 2.5, and which is next?

Practice C (on your own). A quarter car has ms=300m_s = 300 kg, mu=40m_u = 40 kg, ks=30k_s = 30 kN/m and kt=250k_t = 250 kN/m. Enter its body-bounce frequency in Hz.

Worked solution

det⁡(K−ω2M)=0\det(K - \omega^2 M) = 0 is a quadratic in ω2\omega^2: msmuω4−(ms(ks+kt)+muks)ω2+kskt=0m_sm_u\omega^4 - (m_s(k_s+k_t) + m_uk_s)\omega^2 + k_sk_t = 0. Its smaller root is ω12=89.15\omega_1^2 = 89.15, so f=ω12/2π=1.503f = \sqrt{\omega_1^2}/2\pi = 1.503 Hz (scipy.linalg.eigh(K, M) agrees). The one-mass estimate with the springs in series gives almost the same.

Mixed practice: which method, and why?

1. You need the three lowest natural frequencies of a sparse finite-element model with 10510^5 unknowns. Which method?

Question 1

2. Gradient descent on 12xTAx−bTx\tfrac12 x^{\mathsf T}Ax - b^{\mathsf T}x crawls. Which number predicts the crawl?

Question 2

3. Your power iteration has no exact eigenvalue to compare with. How do you measure its rate?

Question 3

Show answers and explanations

1. Lanczos with shift-invert about zero (eigsh with sigma=0), one sparse factorisation. The lowest are the ones nearest 0, so shift-invert makes them dominant; a sparse LU (M03) is factored once and reused every step.

2. the condition number, largest over smallest eigenvalue. M04: the rate is (κ(A)−1)/(κ(A)+1)(\kappa(A) - 1)/(\kappa(A) + 1), near 1 when κ(A)=λmax⁡/λmin⁡\kappa(A) = \lambda_{\max}/\lambda_{\min} is large.

3. ratio of successive differences of the estimate. M01's idea: λk+1−λk\lambda_{k+1} - \lambda_k carries the same geometric factor as the error, so the ratio of successive differences is the rate.

Check yourself (closed book)

1. Why does the Rayleigh quotient xTAx/xTxx^{\mathsf T}Ax/x^{\mathsf T}x of a symmetric AA carry about twice as many correct digits as the vector xx?

Question 1
How sure?

2. Inverse iteration multiplies by (A−σI)−1(A - \sigma I)^{-1}. Which eigenvalue of AA does it find?

Question 2
How sure?

3. The shift is within 10−1010^{-10} of an eigenvalue, so A−σIA - \sigma I has a condition number near 101010^{10}. One step of inverse iteration gives

Question 3
How sure?

4. Which of these does A=ATA = A^{\mathsf T} (real) guarantee?

Question 4
How sure?

5. You need every eigenvalue of a dense symmetric 300×300300 \times 300 matrix. Why call numpy.linalg.eigh rather than write power iteration with deflation?

Question 5
How sure?

6. For Kx=ω2MxKx = \omega^2 M x with KK symmetric and MM symmetric positive definite, two mode shapes x1x_1, x2x_2 with different frequencies satisfy

Question 6
How sure?

Show answers and explanations

1. Its gradient is zero at every eigenvector, so a first-order error in x moves it only to second order. ∇r=2(Ax−rx)/xTx\nabla r = 2(Ax - r x)/x^{\mathsf T}x vanishes at an eigenvector. Near a stationary point a function changes quadratically, so an O(ε)O(\varepsilon) vector gives an O(ε2)O(\varepsilon^2) eigenvalue.

2. The one nearest sigma. (A−σI)−1(A - \sigma I)^{-1} has eigenvalues 1/(λi−σ)1/(\lambda_i - \sigma), largest for the λi\lambda_i nearest σ\sigma; power iteration on it converges at ∣λnear−σ∣/∣λnext−σ∣|\lambda_{\text{near}} - \sigma| / |\lambda_{\text{next}} - \sigma|.

3. an eigenvector accurate to about the shift's distance, 1e-10. The wanted component is amplified by 101010^{10} and the rest by about 1, so one step leaves an error near 10−1010^{-10}, and the next reaches rounding level.

4. Real eigenvalues, orthonormal eigenvectors, and eigenvalues that move no more than the size of a perturbation. The spectral theorem gives the first two; with κ(V)=1\kappa(V) = 1 the Bauer–Fike bound becomes ∣δλ∣≤∥E∥2|\delta\lambda| \le \|E\|_2.

5. It reduces to tridiagonal form and runs shifted QR: all pairs, backward stable, at a cost that does not depend on the gaps. About 43n3\tfrac{4}{3}n^3 flops for the reduction, then a fast tridiagonal solve. The answer is exact for some A+EA + E with ∥E∥≈ϵ∥A∥\|E\| \approx \epsilon\|A\|.

6. x1 and x2 are orthogonal in the mass inner product, x1 M x2 = 0. x2TKx1=ω12x2TMx1x_2^{\mathsf T}Kx_1 = \omega_1^2 x_2^{\mathsf T}Mx_1 and, by symmetry, =ω22x2TMx1= \omega_2^2 x_2^{\mathsf T}Mx_1; with ω1≠ω2\omega_1 \ne \omega_2 that forces x2TMx1=0x_2^{\mathsf T}Mx_1 = 0.

Keep these:

  1. Power iteration converges linearly at ∣λ2/λ1∣|\lambda_2/\lambda_1|; measure it as the ratio of successive errors, or of successive differences.
  2. For symmetric AA the Rayleigh quotient is stationary at eigenvectors: eigenvalue error is the square of the vector error.
  3. Inverse iteration with shift σ\sigma finds the eigenvalue nearest σ\sigma at rate ∣λnear−σ∣/∣λnext−σ∣|\lambda_{\text{near}} - \sigma|/|\lambda_{\text{next}} - \sigma|; factor once, solve per step. A near-singular shift is good.
  4. Symmetry gives real eigenvalues, orthonormal vectors, and eigenvalues that move no more than the perturbation; a defective matrix moves by its root.
  5. For a dense symmetric matrix call eigh (tridiagonalise, shifted QR); check symmetry first, because it reads one triangle.
  6. Kx=ω2MxKx = \omega^2Mx: squared natural frequencies and MM-orthogonal mode shapes, solved by scipy.linalg.eigh(K, M).

Your connection

Name a system you know that rings, sways or hums. What are its masses and stiffnesses, which mode would you want, and which method in this notebook would you aim at it?

Answers

Practice A. k=ln⁡(10−6)/ln⁡0.9≈131k = \ln(10^{-6})/\ln 0.9 \approx 131 steps.

Practice B. 0.5/1.232≈0.4060.5/1.232 \approx 0.406, converging to the eigenvalue 3.

Practice C. about 1.501.50 Hz, from the smaller root of det⁡(K−ω2M)=0\det(K - \omega^2M) = 0.

Mixed practice. shift-invert Lanczos about 0; the condition number; the ratio of successive differences.

Where the maths is derived

Optional. These notes give the intuition and application; the sources below give the full derivations and proofs.

§1 Power iteration

§2 The Rayleigh quotient

§3 Inverse iteration and shifts

§4 What symmetry guarantees

§5 What you actually call

§6 Natural frequencies and mode shapes


Compiled from notebooks/methods/m05_eigenvalues.py — run locally with cd notebooks && uv run marimo edit methods/m05_eigenvalues.py for live Python scratch cells.

Back to the book: Eigenvalues · Finding a chosen eigenvalue

Settings

Colour scheme

Light or dark pages. Your colour and layout stay the same.

Colour

The paper, ink and lettering. Your layout stays the same.

Quiet colours
Bold colours
Reading offline

Keep this book on this device and read it offline.