Find the eigenvalue nearest a shift with inverse power iteration
Why it matters Inverse iteration finds the smallest or a targeted eigenpair, used in spectral clustering (smallest Laplacian eigenvectors) and in vibration and stability analysis.
Power iteration finds the largest eigenvalue. Inverse iteration with a shift finds the eigenvalue closest to any number you choose, which is how solvers refine single eigenpairs.
Write inverse_power(A, shift, x0, n_iter). A is a symmetric (d, d) matrix. Starting from x = x0 / ||x0||, repeat n_iter times: solve (A - shift I) y = x, then x = y / ||y||. Then flip the sign of x so its entry with the largest absolute value is positive, and return (lam, x) where lam = x^T A x (the Rayleigh quotient) as a float.
def inverse_power(A, shift, x0, n_iter)Example
A [[2, 0, 0], [0, 5, 0], [0, 0, 9]], shift 4.5, x0 [1, 1, 1], n_iter 20 gives lam 5.0 and x [0, 1, 0] (up to tiny rounding).
Understand the idea
Power iteration keeps multiplying a vector by A, and the direction with the biggest eigenvalue takes over. Inverse iteration uses the same trick on (A - shift I)^-1. That matrix has eigenvalues 1 / (lambda - shift), so the eigenvalue of A closest to the shift becomes the biggest one and wins.
Worked example: A has eigenvalues 2, 5 and 9, and the shift is 4.5. The inverse shifted values are 1 / (2 - 4.5) = -0.4, 1 / (5 - 4.5) = 2 and 1 / (9 - 4.5) = 0.22. After each solve, the 5 direction grows about 5 times faster than the next one, so after a few steps x points along the eigenvector of 5, and x^T A x = 5.
Rule: repeat { solve (A - shift I) y = x; x = y / ||y|| }, then lambda = x^T A x.
With shift 0 this finds the smallest eigenvalue, which spectral clustering needs from a graph Laplacian. A shift close to the target makes convergence very fast.