Foundations to Frontier
Tests
A. Mathematical Foundations › A2 Linear Algebra › Advanced linear algebra

Quadratic Forms and the Rayleigh Quotient

The expression xᵀAx measures energy, curvature, variance and cost. Its normalized version, the Rayleigh quotient, turns "find the eigenvalues" into "find the best direction". That idea powers PCA, spectral clustering, LDA and structural vibration analysis.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

The stiffest and the floppiest direction

Push on a rubber block. In some directions it’s very stiff, and in others it gives easily. If you test every direction, the stiffest and the floppiest ones are special. They are the block’s natural directions, and their stiffness numbers are its eigenvalues.

The Rayleigh quotient is the “stiffness in direction x” score. Sweep a direction around a circle and watch the score: its highest and lowest values are exactly the eigenvalues.

The Rayleigh quotient: sweep a direction, find the eigenvalues
θ = 0°180°
R(x) = xᵀSx = 3.409 · λ₁ = 3.414, λ₂ = 0.586
Solid = x, orange = Sx, dashed = eigen-directions. The purple curve R(θ) always stays between λ₂ and λ₁ and touches them exactly at the eigen-directions, where its slope is zero.
Why engineers care

A bridge, an aircraft wing or a satellite boom vibrates most easily in its “floppiest” shape. Lord Rayleigh found in the 1870s that you can estimate that shape’s frequency by guessing a shape and computing this score. Engineers still use the idea, now inside every finite-element program.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A block stretches 4× one way and 2× another. Its smallest stretch over all directions?
  2. 2. The highest score over all directions equals…
  3. 3. Can any direction score above the largest eigenvalue?

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

Quadratic forms

A quadratic form is

q(x)=x⊤Ax=∑i,jaijxixjq(\mathbf x) = \mathbf x^\top A\mathbf x = \sum_{i,j}a_{ij}x_ix_j

Example. For A=(2113)A = \begin{pmatrix}2&1\\1&3\end{pmatrix} and x=(1,2)\mathbf x = (1,2): 2⋅1+2⋅1⋅2+3⋅4=182\cdot1 + 2\cdot1\cdot2 + 3\cdot4 = 18. In coordinates, q=2x2+2xy+3y2q = 2x^2 + 2xy + 3y^2. The off-diagonal entry appears twice.

The Rayleigh quotient

R(x)=x⊤Axx⊤xR(\mathbf x) = \frac{\mathbf x^\top A\mathbf x}{\mathbf x^\top\mathbf x}

Scaling x\mathbf x doesn’t change it, so only the direction matters. For the example, R=18/5=3.6R = 18/5 = 3.6. For A=diag⁡(3,1)A = \operatorname{diag}(3,1), RR ranges from 1 (along yy) to 3 (along xx).

📝 Quick check (Level 1)
0/3 answered
  1. 1. xᵀAx for A = diag(3, 1), x = (1, 1)?
  2. 2. R(x) for the same?
  3. 3. Max of R for diag(5, 2, −1)?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Only the symmetric part matters

Write A=S+KA = S + K with S=A+A⊤2S = \frac{A + A^\top}2 symmetric and KK skew-symmetric. Since x⊤Kx=0\mathbf x^\top K\mathbf x = 0, we get x⊤Ax=x⊤Sx\mathbf x^\top A\mathbf x = \mathbf x^\top S\mathbf x. So we always assume AA is symmetric. Then it has real eigenvalues λ1≥⋯≥λn\lambda_1\ge\dots\ge\lambda_n and an orthonormal eigenbasis (A2.3-2).

The Rayleigh quotient is trapped

Expand x=∑ciqi\mathbf x = \sum c_i\mathbf q_i in the eigenbasis:

R(x)=∑iλici2∑ici2R(\mathbf x) = \frac{\sum_i\lambda_ic_i^2}{\sum_ic_i^2}

This is a weighted average of the eigenvalues, so λmin⁡≤R(x)≤λmax⁡\lambda_{\min}\le R(\mathbf x)\le\lambda_{\max}. The extremes are reached at the eigenvectors. The gradient is

∇R(x)=2x⊤x(Ax−R(x) x)\nabla R(\mathbf x) = \frac{2}{\mathbf x^\top\mathbf x}\big(A\mathbf x - R(\mathbf x)\,\mathbf x\big)

It vanishes exactly at eigenvectors. Eigenvectors are the critical points of RR.

🐍 Exercise 1: the Rayleigh quotient is trapped
Implement R(x). Sample 20,000 random directions and check they all land in [λmin, λmax], with the extremes at eigenvectors.

Where quadratic forms and Rayleigh quotients appear

Field Quadratic form Rayleigh-quotient problem
PCA (D9) variance along w\mathbf w: w⊤Σw\mathbf w^\top\Sigma\mathbf w first PC maximizes w⊤Σw/w⊤w\mathbf w^\top\Sigma\mathbf w/\mathbf w^\top\mathbf w
Mechanics kinetic energy 12q˙⊤Mq˙\tfrac12\dot{\mathbf q}^\top M\dot{\mathbf q}, strain energy 12u⊤Ku\tfrac12\mathbf u^\top K\mathbf u natural frequencies: ω2=u⊤Ku/u⊤Mu\omega^2 = \mathbf u^\top K\mathbf u/\mathbf u^\top M\mathbf u
Optimization (A6) the Hessian term 12d⊤Hd\tfrac12\mathbf d^\top H\mathbf d sharpness = λmax⁡(H)\lambda_{\max}(H)
Graphs x⊤Lx=∑ijwij(xi−xj)2\mathbf x^\top L\mathbf x = \sum_{ij}w_{ij}(x_i - x_j)^2 spectral clustering (Fiedler vector)
Classification between- and within-class scatter Fisher LDA maximizes w⊤SBw/w⊤SWw\mathbf w^\top S_B\mathbf w/\mathbf w^\top S_W\mathbf w
Control LQR cost x⊤Qx+u⊤Ru\mathbf x^\top Q\mathbf x + \mathbf u^\top R\mathbf u Lyapunov functions V=x⊤PxV = \mathbf x^\top P\mathbf x

The generalized Rayleigh quotient x⊤Ax/x⊤Bx\mathbf x^\top A\mathbf x/\mathbf x^\top B\mathbf x (with B≻0B\succ0) is extremized by the generalized eigenproblem Ax=λBxA\mathbf x = \lambda B\mathbf x.

To see the shape of a 2-D quadratic form (bowl, saddle or valley), use this explorer:

The shape of xᵀSx: bowl, valley, saddle or dome?
S = [[2.0, 0.8], [0.8, 1.0]] · eigenvalues 2.44, 0.56 · det 1.36 → positive definite: a bowl, unique minimum at 0
Blue = positive, orange = negative; stripes are level sets. Positive definite ⇔ both eigenvalues > 0 ⇔ a > 0 and det > 0.
📝 Quick check (Level 2)
0/3 answered
  1. 1. For A = [[2, 1], [1, 2]], max R = ?
  2. 2. The symmetric part of [[1, 4], [0, 1]] has off-diagonal…
  3. 3. The gradient of R vanishes at…

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

Courant–Fischer min–max

Theorem (Courant–Fischer)

For symmetric AA with λ1≥⋯≥λn\lambda_1\ge\dots\ge\lambda_n:

λk=max⁡dim⁡V=k min⁡x∈V∖0R(x)=min⁡dim⁡V=n−k+1 max⁡x∈V∖0R(x)\lambda_k = \max_{\dim V = k}\ \min_{\mathbf x\in V\setminus0}R(\mathbf x) = \min_{\dim V = n-k+1}\ \max_{\mathbf x\in V\setminus0}R(\mathbf x)

Proof idea (first form). Choosing V=span⁡(q1..qk)V = \operatorname{span}(\mathbf q_1..\mathbf q_k) gives a minimum of λk\lambda_k, so the max is ≥λk\ge\lambda_k. Any kk-dimensional VV meets the (n−k+1)(n-k+1)-dimensional span⁡(qk..qn)\operatorname{span}(\mathbf q_k..\mathbf q_n) in a nonzero vector, by counting dimensions. On that span, R≤λkR\le\lambda_k, so every VV’s minimum is ≤λk\le\lambda_k. ∎ Every eigenvalue is a solution to an optimization problem. That’s why eigenvalues behave well under perturbation (A2.4-4) and why interlacing theorems hold.

Eigenvalue estimates are second-order accurate

If x=q+ϵ\mathbf x = \mathbf q + \boldsymbol\epsilon with ∥ϵ∥=δ\lVert\boldsymbol\epsilon\rVert = \delta, then R(x)=λ+O(δ2)R(\mathbf x) = \lambda + O(\delta^2), because ∇R(q)=0\nabla R(\mathbf q) = 0. A 1% error in the vector gives about a 0.01% error in the eigenvalue. This is why Rayleigh’s method works so well, and why Rayleigh quotient iteration, which shifts by the current RR, converges cubically for symmetric matrices.

Sylvester’s law of inertia

Theorem (Sylvester)

For invertible SS, S⊤ASS^\top AS has the same number of positive, negative and zero eigenvalues as AA.

A change of variables x=Sy\mathbf x = S\mathbf y can bend a bowl into a different bowl, but never into a saddle. The signature (the inertia) is the coordinate-free part of a quadratic form. It classifies critical points (A3) and underlies the LDLᵀ test of definiteness.

Exercise 3.1: Show that xᵀKx = 0 when K is skew-symmetric

x⊤Kx\mathbf x^\top K\mathbf x is a scalar, so it equals its own transpose x⊤K⊤x=−x⊤Kx\mathbf x^\top K^\top\mathbf x = -\mathbf x^\top K\mathbf x. Hence it is 0.

📝 Quick check (Level 3)
0/3 answered
  1. 1. λ₂ of diag(5, 3, 1) via Courant–Fischer?
  2. 2. Eigenvector error 10⁻³ ⇒ Rayleigh eigenvalue error about…
  3. 3. SᵀAS (S invertible) always keeps…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Rayleigh quotient iteration

μk=R(xk),xk+1=(A−μkI)−1xk∥(A−μkI)−1xk∥\mu_k = R(\mathbf x_k), \qquad \mathbf x_{k+1} = \frac{(A - \mu_kI)^{-1}\mathbf x_k}{\lVert(A - \mu_kI)^{-1}\mathbf x_k\rVert}

Inverse iteration with an adaptive shift converges cubically for symmetric AA, so the number of correct digits roughly triples each step (Parlett, 1998). It is one ingredient of the shifted QR algorithm that every eigen-solver uses.

🐍 Exercise 2 (research): power iteration vs Rayleigh quotient iteration
On a 50×50 matrix with a small eigenvalue gap (10 vs 9.5), compare the error histories. Power iteration crawls linearly; RQI hits machine precision in about 3 steps.

Rayleigh quotients in modern research

  • Spectral clustering and multi-robot networks. Minimizing x⊤Lx/x⊤x\mathbf x^\top L\mathbf x/\mathbf x^\top\mathbf x over x⊥1\mathbf x\perp\mathbf 1 relaxes the NP-hard balanced graph cut (Shi and Malik, 2000; von Luxburg, 2007). The value λ2\lambda_2 (the algebraic connectivity, Fiedler 1973) sets how fast a robot swarm reaches consensus, and how close a communication network is to splitting.
  • Sharpness in deep learning. The top Hessian eigenvalue max⁡dd⊤Hd/d⊤d\max_{\mathbf d}\mathbf d^\top H\mathbf d/\mathbf d^\top\mathbf d governs training stability. Gradient descent drives it to 2/η2/\eta (“edge of stability”, Cohen et al., 2021), and SAM optimizes against the worst direction nearby (Foret et al., 2021). It is computed by power iteration on Hessian–vector products.
  • Structural dynamics. The Rayleigh–Ritz method restricts R(u)=u⊤Ku/u⊤MuR(\mathbf u) = \mathbf u^\top K\mathbf u/\mathbf u^\top M\mathbf u to a subspace, which gives upper bounds on natural frequencies. It is the foundation of finite-element modal analysis and of spacecraft modal surveys before launch.
  • Fisher LDA and CCA are generalized Rayleigh quotients (D3, D9).

References

  1. Lord Rayleigh (1877). The Theory of Sound, Vol. 1. Macmillan.
  2. R. Courant (1920). “Über die Eigenwerte bei den Differentialgleichungen der mathematischen Physik.” Mathematische Zeitschrift, 7.
  3. M. Fiedler (1973). “Algebraic connectivity of graphs.” Czechoslovak Mathematical Journal, 23.
  4. B. Parlett (1998). The Symmetric Eigenvalue Problem. SIAM. Chapter 4.
  5. J. Shi, J. Malik (2000). “Normalized cuts and image segmentation.” IEEE TPAMI, 22(8).
  6. U. von Luxburg (2007). “A tutorial on spectral clustering.” Statistics and Computing, 17.
  7. J. Cohen, S. Kaur, Y. Li, J. Z. Kolter, A. Talwalkar (2021). “Gradient descent on neural networks typically occurs at the edge of stability.” ICLR.
  8. P. Foret, A. Kleiner, H. Mobahi, B. Neyshabur (2021). “Sharpness-aware minimization for efficiently improving generalization.” ICLR.