TExcelTAD
Home › Spectral Graph Theory & Modern Graph Algorithms › The Courant-Fischer Theorem and Power Iteration

The Courant-Fischer Theorem and Power Iteration

Eigenvalues are defined by an equation, Lx=λxLx = \lambda x, but almost every proof in spectral graph theory uses a different description: as the optimum of an optimization problem over vectors. That view, the Courant-Fischer theorem, turns any well-chosen test vector into a bound on an eigenvalue, and it is also the basis of the simplest algorithm for computing the eigenvectors we need, power iteration.

The Rayleigh quotient

For a symmetric M∈Rn×nM \in \mathbb{R}^{n \times n} and x≠0x \ne 0, the Rayleigh quotient is RM(x)=xTMxxTxR_M(x) = \frac{x^{\mathsf{T}} M x}{x^{\mathsf{T}} x}. By the spectral theorem (Symmetric Diagonalization) MM has an orthonormal eigenbasis v1,…,vnv_1, \ldots, v_n with eigenvalues λ1≤⋯≤λn\lambda_1 \le \cdots \le \lambda_n. Writing x=∑icivix = \sum_i c_i v_i,

RM(x)=∑iλici2∑ici2,R_M(x) = \frac{\sum_i \lambda_i c_i^2}{\sum_i c_i^2},

a weighted average of the eigenvalues with weights ci2c_i^2. So λ1≤RM(x)≤λn\lambda_1 \le R_M(x) \le \lambda_n, with equality at v1v_1 and vnv_n. If x⊥v1x \perp v_1 then c1=0c_1 = 0 and RM(x)≥λ2R_M(x) \ge \lambda_2; this is already the statement we use most.

The theorem

Theorem (Courant-Fischer; Fischer 1905, Courant 1920). For symmetric MM with eigenvalues λ1≤⋯≤λn\lambda_1 \le \cdots \le \lambda_n and every kk,

λk=min⁡S⊆Rndim⁡S=k max⁡x∈S∖{0}RM(x)=max⁡T⊆Rndim⁡T=n−k+1 min⁡x∈T∖{0}RM(x).\lambda_k = \min_{\substack{S \subseteq \mathbb{R}^n \\ \dim S = k}} \ \max_{x \in S \setminus \{0\}} R_M(x) = \max_{\substack{T \subseteq \mathbb{R}^n \\ \dim T = n - k + 1}} \ \min_{x \in T \setminus \{0\}} R_M(x).

Proof of the first equality. Taking S=span⁡(v1,…,vk)S = \operatorname{span}(v_1, \ldots, v_k), every x∈Sx \in S is an average of λ1,…,λk\lambda_1, \ldots, \lambda_k, so the max over SS is λk\lambda_k; hence the min is at most λk\lambda_k. Conversely, any kk-dimensional SS meets the (n−k+1)(n - k + 1)-dimensional span⁡(vk,…,vn)\operatorname{span}(v_k, \ldots, v_n) in a nonzero vector (the dimensions add up to more than nn), and that vector has RM≥λkR_M \ge \lambda_k. So every SS has max at least λk\lambda_k. The second equality follows by applying the first to −M-M. □\square

For a Laplacian, v1=1/nv_1 = \mathbf{1}/\sqrt n, so the case k=2k = 2 reads

λ2(L)=min⁡x≠0, x⊥1∑{u,v}∈Ewuv(xu−xv)2∑vxv2,λn(L)=max⁡x≠0xTLxxTx.\lambda_2(L) = \min_{x \ne 0,\ x \perp \mathbf{1}} \frac{\sum_{\{u,v\} \in E} w_{uv}(x_u - x_v)^2}{\sum_v x_v^2}, \qquad \lambda_n(L) = \max_{x \ne 0} \frac{x^{\mathsf{T}} L x}{x^{\mathsf{T}} x}.

Test vectors give bounds

Upper bounds on λ2\lambda_2. Any x⊥1x \perp \mathbf{1} gives λ2≤RL(x)\lambda_2 \le R_L(x). For the path PnP_n try the linear vector xv=v−n−12x_v = v - \frac{n-1}{2}: every edge contributes 1, so the numerator is n−1n - 1, and ∑vxv2=n(n2−1)12\sum_v x_v^2 = \frac{n(n^2 - 1)}{12}. Hence λ2(Pn)≤12n(n+1)\lambda_2(P_n) \le \frac{12}{n(n+1)}, within a factor 12/π2≈1.2212/\pi^2 \approx 1.22 of the truth ≈π2/n2\approx \pi^2/n^2. A clever test vector is often all a proof needs.

Lower bounds on λn\lambda_n. Any xx gives λn≥RL(x)\lambda_n \ge R_L(x); with x=ev−eux = \mathbf{e}_v - \mathbf{e}_u for an edge uvuv one gets λn≥du+dv+2wuv2\lambda_n \ge \frac{d_u + d_v + 2w_{uv}}{2}, so λn≥dmax⁡\lambda_n \ge d_{\max} for unweighted graphs (take x=evx = \mathbf{e}_v: R=dvR = d_v).

Monotonicity. If HH is GG plus edges (or with larger weights), then xTLHx≥xTLGxx^{\mathsf{T}} L_H x \ge x^{\mathsf{T}} L_G x for all xx, written LH⪰LGL_H \succeq L_G (the Loewner order). Courant-Fischer then gives λk(LH)≥λk(LG)\lambda_k(L_H) \ge \lambda_k(L_G) for every kk, not only the extremes. Adding edges can only make a graph better connected, spectrally.

python · try it yourself
import numpy as np

def laplacian(n, edges):
    L = np.zeros((n, n))
    for u, v in edges:
        L[u, u] += 1; L[v, v] += 1; L[u, v] -= 1; L[v, u] -= 1
    return L

for n in [5, 20, 100]:
    L = laplacian(n, [(i, i + 1) for i in range(n - 1)])
    x = np.arange(n) - (n - 1) / 2                     # linear test vector, orthogonal to 1
    print(f"P_{n:<3}: lambda_2 = {float(np.linalg.eigvalsh(L)[1]):.6f}   R(x) = {float(x @ L @ x / (x @ x)):.6f}"
          f"   12/(n(n+1)) = {12 / (n * (n + 1)):.6f}")

# monotonicity: add edges to a 6-cycle one at a time; every eigenvalue can only go up
n = 6
edges = [(i, (i + 1) % n) for i in range(n)]
print("C_6          ", np.round(np.linalg.eigvalsh(laplacian(n, edges)), 4) + 0.0)
for extra in [(0, 3), (1, 4), (2, 5)]:
    edges.append(extra)
    print(f"+ edge {extra}", np.round(np.linalg.eigvalsh(laplacian(n, edges)), 4) + 0.0)
P_5  : lambda_2 = 0.381966   R(x) = 0.400000   12/(n(n+1)) = 0.400000
P_20 : lambda_2 = 0.024623   R(x) = 0.028571   12/(n(n+1)) = 0.028571
P_100: lambda_2 = 0.000987   R(x) = 0.001188   12/(n(n+1)) = 0.001188
C_6           [0. 1. 1. 3. 3. 4.]
+ edge (0, 3) [0. 1. 2. 3. 3. 5.]
+ edge (1, 4) [0.     1.4384 3.     3.     3.     5.5616]
+ edge (2, 5) [0. 3. 3. 3. 3. 6.]

Every column of the second table is nondecreasing. The last graph, the cycle with its three long diagonals, is the complete bipartite graph K3,3K_{3,3}, with spectrum {0,3,3,3,3,6}\{0, 3, 3, 3, 3, 6\}.

Power iteration

To compute the eigenvector of the largest eigenvalue of a positive semidefinite matrix MM, start from a random x0x_0 and repeat xt+1=Mxt/∥Mxt∥x_{t+1} = Mx_t / \lVert Mx_t \rVert. In the eigenbasis, Mtx0=∑iciλitviM^t x_0 = \sum_i c_i \lambda_i^t v_i, and the top term dominates at a rate (λn−1/λn)t(\lambda_{n-1}/\lambda_n)^t. The Rayleigh quotient converges even faster, at rate (λn−1/λn)2t(\lambda_{n-1}/\lambda_n)^{2t}.

For the Fiedler vector we need the second smallest eigenvalue of LL. Flip the spectrum with M=cI−LM = cI - L for some c≥λnc \ge \lambda_n (say c=2dmax⁡c = 2d_{\max}), whose largest eigenvalue cc belongs to 1\mathbf{1}, and deflate: subtract the mean from xx after every step so that it stays orthogonal to 1\mathbf{1}. Then the iteration converges to the eigenvector of c−λ2c - \lambda_2, which is the Fiedler vector, at rate c−λ3c−λ2=1−λ3−λ2c−λ2\frac{c - \lambda_3}{c - \lambda_2} = 1 - \frac{\lambda_3 - \lambda_2}{c - \lambda_2} per step.

text
fiedler_power(L, c, iterations)
1  x ← random vector; x ← x − mean(x)·1; x ← x / ‖x‖
2  repeat iterations times
3      y ← c·x − L x                 (one matrix-vector product: O(m) time)
4      y ← y − mean(y)·1             (deflate the eigenvector 1)
5      x ← y / ‖y‖
6  return x, xᵀ L x                  (vector and its Rayleigh quotient)

Each step costs one multiplication by LL, O(m)O(m) time for a sparse graph. The catch is the rate: when λ2\lambda_2 and λ3\lambda_3 are close relative to cc, convergence is slow. Production codes use the Lanczos method (or LOBPCG), which builds a Krylov subspace from the same matrix-vector products and needs roughly the square root of the number of iterations; scipy.sparse.linalg.eigsh calls ARPACK's implicitly restarted Lanczos.

python · try it yourself
import numpy as np

def laplacian(n, edges):
    L = np.zeros((n, n))
    for u, v in edges:
        L[u, u] += 1; L[v, v] += 1; L[u, v] -= 1; L[v, u] -= 1
    return L

def fiedler_power(L, iterations, seed=0):
    c = 2 * L.diagonal().max()                   # c >= lambda_n
    x = np.random.default_rng(seed).standard_normal(len(L))
    for _ in range(iterations):
        x = c * x - L @ x
        x -= x.mean()                            # stay orthogonal to the all-ones vector
        x /= np.linalg.norm(x)
    return x, float(x @ L @ x)

# two 5-cliques joined by a path of length 3
edges = [(a + s, b + s) for s in (0, 7) for a in range(5) for b in range(a + 1, 5)] + [(4, 5), (5, 6), (6, 7)]
L = laplacian(12, edges)
vals, vecs = np.linalg.eigh(L)
exact = vecs[:, 1] if vecs[0, 1] > 0 else -vecs[:, 1]
print("exact lambda_2 =", round(float(vals[1]), 6), " lambda_3 =", round(float(vals[2]), 6))
for it in [10, 50, 200]:
    x, rq = fiedler_power(L, it)
    x = x if x[0] > 0 else -x
    print(f"{it:5} iterations: Rayleigh quotient {rq:.6f}, distance to the exact vector {float(np.linalg.norm(x - exact)):.2e}")
print("Fiedler vector:", np.round(exact, 3) + 0.0)
exact lambda_2 = 0.117979  lambda_3 = 1.0
   10 iterations: Rayleigh quotient 0.554771, distance to the exact vector 7.53e-01
   50 iterations: Rayleigh quotient 0.118447, distance to the exact vector 2.30e-02
  200 iterations: Rayleigh quotient 0.117979, distance to the exact vector 1.87e-08
Fiedler vector: [ 0.32   0.32   0.32   0.32   0.283  0.098 -0.098 -0.283 -0.32  -0.32
 -0.32  -0.32 ]

The Rayleigh quotient is accurate long before the vector is, as predicted. The Fiedler vector is positive on one clique, negative on the other, and passes through zero along the connecting path.

In C++

The same deflated power iteration with a sparse adjacency list, so each step is O(n+m)O(n + m).

cpp · try it yourself
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <random>
#include <vector>

using Graph = std::vector<std::vector<int>>;

// y = c x - L x for the unweighted Laplacian, from adjacency lists
void apply(const Graph& g, double c, const std::vector<double>& x, std::vector<double>& y) {
    for (std::size_t v = 0; v < g.size(); ++v) {
        double s = (c - double(g[v].size())) * x[v];
        for (int u : g[v]) s += x[u];
        y[v] = s;
    }
}

int main() {
    const int n = 12;
    Graph g(n);
    auto add = [&](int a, int b) { g[a].push_back(b); g[b].push_back(a); };
    for (int s : {0, 7})
        for (int a = 0; a < 5; ++a)
            for (int b = a + 1; b < 5; ++b) add(a + s, b + s);
    add(4, 5); add(5, 6); add(6, 7);

    double c = 0;
    for (auto& nb : g) c = std::max(c, 2.0 * double(nb.size()));
    std::mt19937 rng(1);                            // a random start, uniform in [-0.5, 0.5)
    std::vector<double> x(n), y(n);
    for (double& v : x) v = double(rng()) / 4294967296.0 - 0.5;
    for (int it = 1; it <= 1000; ++it) {
        apply(g, c, x, y);
        double mean = 0, norm = 0;
        for (double v : y) mean += v / n;
        for (double& v : y) { v -= mean; norm += v * v; }
        for (int i = 0; i < n; ++i) x[i] = y[i] / std::sqrt(norm);
        if (it == 10 || it == 100 || it == 1000) {
            apply(g, 0.0, x, y);                     // y = -L x
            double rq = 0;
            for (int i = 0; i < n; ++i) rq -= x[i] * y[i];
            std::printf("%4d iterations: lambda_2 estimate %.6f\n", it, rq);
        }
    }
    double sign = x[0] > 0 ? 1.0 : -1.0;
    std::printf("Fiedler vector:");
    for (double v : x) std::printf(" %.3f", sign * v + 0.0);
    std::printf("\n");
}
  10 iterations: lambda_2 estimate 0.215155
 100 iterations: lambda_2 estimate 0.117979
1000 iterations: lambda_2 estimate 0.117979
Fiedler vector: 0.320 0.320 0.320 0.320 0.283 0.098 -0.098 -0.283 -0.320 -0.320 -0.320 -0.320

Test yourself

By Courant-Fischer, which expression equals λ2(L)\lambda_2(L) for a graph Laplacian?

  1. max⁡x⊥1xTLxxTx\max_{x \perp \mathbf{1}} \frac{x^{\mathsf{T}} L x}{x^{\mathsf{T}} x}
  2. min⁡x≠0, x⊥1xTLxxTx\min_{x \ne 0,\ x \perp \mathbf{1}} \frac{x^{\mathsf{T}} L x}{x^{\mathsf{T}} x}
  3. min⁡x≠0xTLxxTx\min_{x \ne 0} \frac{x^{\mathsf{T}} L x}{x^{\mathsf{T}} x}
  4. tr⁡(L)/n\operatorname{tr}(L)/n

A vector x⊥1x \perp \mathbf{1} has Rayleigh quotient 0.3 for a graph's Laplacian. What follows?

  1. λ2=0.3\lambda_2 = 0.3
  2. λ2≤0.3\lambda_2 \le 0.3
  3. λ2≥0.3\lambda_2 \ge 0.3
  4. Nothing

You add an edge to a graph. What happens to the Laplacian eigenvalues?

  1. Only λn\lambda_n can grow
  2. Each λk\lambda_k stays the same or grows
  3. They can move in either direction
  4. Only λ2\lambda_2 changes

Deflated power iteration on cI−LcI - L converges to the Fiedler vector at which rate per step?

  1. λ2/λ3\lambda_2/\lambda_3
  2. c−λ3c−λ2\frac{c - \lambda_3}{c - \lambda_2}
  3. 12\frac{1}{2}
  4. λ2/c\lambda_2/c