Finding a chosen eigenvalue
What this page answers
The class page says an eigenvalue question asks which values are allowed, and that the cheap method is to keep multiplying by the matrix. That method always finds the largest one. This page shows why, and then shows the one-line change that finds any eigenvalue you name — including the ones a power iteration can never report.
It closes a gap the symptom index already sends readers to: "the answer I want is not the biggest one" has a standard fix, and this is it.
The mathematics
For a matrix with eigenvalues , start from any vector with a component along the first eigenvector and repeat
Write in the eigenvectors. Multiplying once gives , and multiplying times gives
The bracket tends to because every ratio has magnitude below one, so the normalised vector tends to and the Rayleigh quotient tends to . The error falls by per step, which is slow when the two largest eigenvalues are close and instant when they are not. Nothing in that argument says the eigenvalue is the largest — only that it is the one the iteration is drawn to.
The shift. Pick a number and apply the same iteration to
If then . The eigenvectors are unchanged and the eigenvalues are replaced by . So the eigenvalue of nearest becomes the eigenvalue of with the largest magnitude, and two lines earlier proved that this is the one a power iteration finds. Recover it with
where is the eigenvalue of that the iteration returned.
That is the whole of shift-and-invert. Two details make it usable.
- The inverse is never formed. Each step needs one solve of , which costs what a linear solve costs — the subject of the next class page — rather than the of an explicit inverse.
- The shift decides the rate. The error now falls by per step. Choosing close to the wanted eigenvalue makes that ratio small, and choosing it exactly on the eigenvalue makes the matrix singular, which is the one way this method fails loudly rather than slowly.
The check. Take
whose eigenvalues are , and . Power iteration returns . With the shifted iteration returns ; with it returns . The middle eigenvalue is one a power iteration on cannot report at all, and it is found in sixty steps once the shift is right.
The code
The program builds that matrix, runs sixty power iterations on , then runs the same iteration on for two shifts and converts each answer back to an eigenvalue of . Sixty steps is enough for all three to settle at the eight digits printed.
The matrix, the power iteration and two shifted runs
import sympy as sp
A = sp.Matrix([[2, 1, 0], [1, 3, 1], [0, 1, 4]])
print("eigenvalues", sorted(sp.N(v, 6) for v in A.eigenvals()))
def power(M, v, n=60):
v = sp.Matrix(v)
for _ in range(n):
w = M * v
v = w / max(abs(e) for e in w)
return sp.N((v.dot(M * v)) / (v.dot(v)), 8), v
lam, v = power(A, [1, 1, 1])
print("power iteration found", lam)
for sigma in (sp.Rational(3, 2), sp.Rational(7, 2)):
B = (A - sigma * sp.eye(3)).inv()
mu, w = power(B, [1, -1, 1])
value = sp.N(1 / mu + sigma, 8)
print(f"shift {float(sigma):.2f}: eigenvalue", value)
eigenvalues [1.26795, 3.00000, 4.73205]
power iteration found 4.7320508
shift 1.50: eigenvalue 1.2679492
shift 3.50: eigenvalue 3.0000000
Each shift returns the eigenvalue nearest it, and the two shifted answers are the two eigenvalues that are not the largest. The first line is the reference: without it a reader cannot tell a converged answer from a wrong one. The last line is the one worth staring at, because is an eigenvalue that a power iteration on never approaches — the run is still dominated by after sixty steps.
The theory
Three assumptions carry the argument, and each fails in a way worth naming.
- A gap. The convergence rate is a ratio of eigenvalues, so it needs a strict largest one. If — two eigenvalues of opposite sign, or a complex conjugate pair — the normalized iterate does not settle on a single vector, and the Rayleigh quotient oscillates instead of converging.
- An eigenvalue you can name. Shift-and-invert needs a , and knowing which to pick is a property of the application rather than of the method. The usual route is a rational or polynomial filter, or a shift chosen from an approximate eigenvector.
- A solvable shift. If lands on an eigenvalue, is singular and the solve has no unique answer. In exact arithmetic the iteration still converges in one step; in floating point the solve is dominated by rounding, and the answer is noise.
Sensitivity is where the eigenvalue problem differs from a linear system. An eigenvalue's condition number is for its left and right eigenvectors, so a non-symmetric matrix can have an eigenvalue that moves much further than the entries do. The symmetric case is the well-behaved one, and Saad's account of the Arnoldi and Lanczos families is where the non-symmetric version is developed.
What it will not do: it will not find several eigenvalues without a shift for each, and it will not report the whole spectrum. A block method or a deflation-based method is the answer to "all of them", and both are more work than this page.
What this cost
One matrix-vector product per step for the plain iteration: time and memory. The shifted version replaces that product with a linear solve, so each step costs whatever the solver costs. It is once for a dense factorisation and per step after that, or per step for a sparse solver.
Accuracy is limited by the shift: the closer is to the wanted eigenvalue, the faster the convergence and the worse the conditioning of the solve. Efficient variants update the shift as the estimate improves. That is why the method is often met under the name shifted inverse iteration with Rayleigh quotient shifts, rather than by the two lines that define it.
What it will not do: it will not find an eigenvalue you cannot name approximately. It will not separate two eigenvalues that share a magnitude without a shift. And it will not tell you that a clustered pair is clustered — a single estimate hides it.
Back to the map
Eigenvalues is the class page this works under. Error, and what a tolerance is says what the solve inside each step is accurate to. Home is the summary.