![]() | Text provided under a Creative Commons Attribution license, CC-BY. All code is made available under the FSF-approved MIT license. (c) Kyle T. Mandli |
Note: This material largely follows the text “Numerical Linear Algebra” by Trefethen and Bau (SIAM, 1997) and is meant as a guide and supplement to the material presented there.
from __future__ import print_function
%matplotlib inline
import matplotlib.pyplot as plt
import numpyEigenproblems¶
Overview¶
We will now consider eigenproblems of the form
where , and . The vector is known as the eigenvector and the eigenvalue. The set of all eigenvalues is called the spectrum of .
We can then state the following theorem regarding the zeros of and the eigenvalues of :
Theorem: is an eigenvalue of if and only if .
Eigenvalue Decomposition¶
Similar to QR factorization, an eigendecomposition is possible such that can be written as
where is the matrix formed by the eigenvectors as its columns and is a diagonal matrix with the eigenvalues along its diagonal.
This equation comes from the similar equation which is of course related to the original problem statement. This latter equation can be written out as
Here we note that the eigenpair are matched as the th column of and the th element of on the diagonal.
Algebraic multiplicity is the number of times overall an eigenvalue repeats itself.
Geometric multiplicity is defined as the number of linearly independent eigenvectors that belong to each eigenvalue.
If the algebraic multiplicity is equal to the geometric multiplicity for all then we can say that there is a full eigenspace.
Example: Computing Multiplicities¶
Compute the geometric and algebraic multiplicities for the following matrices. What is the relationship between the algebraic and geometric multiplicities?
The characteristic polynomial of is
so the eigenvalues are all so we know the algebraic multiplicity is 3 of this eigenvalue. The geometric multiplicity is determined by the number of linearly independent eigenvectors. For this matrix we have three eigenvectors that are all linearly independent which happen to be the unit vectors in each direction (check!). This means that the geometric multiplicity is also 3.
The characteristic polynomial of is the same as so again we know but now we need to be a bit careful about the eigenvectors. In this case the only eigenvector is a scalar multiple of so the geometric multiplicity is 1.
Interpretations of the Eigenspace¶
One way to interpret the eigenproblem is that of one that tries to find the subspaces of which act like scalar multiplication by . The eigenvectors associated with one eigenvalue then form a subspace of .
When an eigenvalue has algebraic multiplicity that equals its geometric then it is called non-defective and otherwise defective. This property is also inherited to the matrix so in the above example and are non-defective and defective matrices respectively.
Determinant and Trace¶
Two important properties of matrices have important relationships with their eigenvalues, namely the determinant and trace. The determinant we have seen, the trace is defined as the sum of the elements on the diagonal of a matrix, in other words
The relationship between the determinant and the eigenvalues is not difficult to guess due to the nature of the characteristic polynomial. The trace of a diagonal matrix is clear and provides another suggestion to the relationship.
Theorem: The determinant and trace are equal to the product and sum of the eigenvalues of respectively counting algebraic multiplicity.
Similarity Transformations¶
The relationship between a matrix’s eigenvalues and its determinant and trace are due to the special relationship between the eigenvalue decomposition and what is called similarity transformations. A similarity transformation is defined as a transformation that takes A and maps it to (assuming is non-singular). Two matrices are said to be similar if there is a similarity transformation between them.
The most important property of similar matrices is that they have the same characteristic polynomial, eigenvalues, and multiplicities.
This allows us to relate geometric and algebraic multiplicity as
Theorem: The algebraic multiplicity of an eigenvalue is at least as great as its geometric multiplicity.
Schur Factorization¶
A Schur factorization of a matrix is defined as
where is unitary and is upper-triangular. In particular note that due do the structure of the resulting characteristic polynomial that and have identical eigenvalues.
Why is this?
What relationship does this have to similarity transformations?
The characteristic polynomials of and are identical.
The Schur factorization is a similarity transformation due to being unitary.
Theorem: Every matrix has a Schur factorization.
Note that the above results imply the following
An eigen-decomposition exists if and only if is non-defective (it has a complete set of eigenvectors)
A unitary transformation exists if and only if is normal ()
A Schur factorization always exists
Note that each of these lead to a means for isolating the eigenvalues of a matrix and will be useful when considering algorithms for finding them.
Condition Number of a Simple Eigenvalue¶
Before we discuss a number of approaches to computing eigenvalues it good to consider what the condition number of a given eigenproblem is.
Let
define the eigenvalue problem in question. Here we will introduce a related problem
where is the left eigenvector and from before is the right eigenvector. These vectors also can be shown to have the relationship for a simple eigenvalue.
Now consider the perturbed problem
Expanding this and throwing out quadratic terms and removing the eigenproblem we have
Multiple both sides of the above by the left eigenvector and use to find
where we again use the slightly different definition of the eigenproblem. We can then solve for to find
meaning that the ratio between the dot-product of the left and right eigenvectors and the conjugate dot-product of the matrix then form a form of bound on the expected error in the simple eigenvalue.
Computing Eigenvalues¶
The most obvious approach to computing eigenvalues is a direct computation of the roots of the characteristic polynomial. Unfortunately the following theorem suggests this is not a good way to compute eigenvalues:
Theorem: For an there is a polynomial of degree with rational coefficients that has a real root with the property that cannot be written using any expression involving rational numbers, addition, subtraction, multiplication, division, and th roots.
Not all is lost however, we just cannot use any direct methods to solve for the eigenvalues. Instead we must use an iterative approach, in other words we want to construct a sequence that converges to the eigenvalues. How does this relate to how we found roots previously?
Almost all approaches to computing eigenvalues do so through the computation of the Schur factorization. The Schur factorization, as we have seen, will preserve the eigenvalues. The steps to compute the Schur factorization are usually broken down into two steps
Directly transform into a Hessenberg matrix, a matrix that contains zeros below its first sub-diagonal, directly using Householder reflections.
Use an iterative method to change the sub-diagonal into all zeros
Hessenberg and Tridiagonal form¶
What we want to do is construct a sequence of unitary matrices that turns into a Hessenberg matrix to start. We can use Householder reflections to do this with the important distinction that we only want to remove zeros below the first sub-diagonal. The sequence would look something like
so we have the sequence . Note we need both to preserve the entries of the first column that are not being transformed to zeros.
One important special case of this sequence of transformations is that if the matrix is hermitian (the matrix is its own conjugate transpose, , or symmetric in the real case) then the Hessenberg matrix is tridiagonal.
We now will focus on how to formulate the iteration step of the eigenproblem. We will also restrict our attention to symmetric, real matrices. This implies that all eigenvalues will be real and have a complete set of orthogonal eigenvectors. Generalizations can be made of many of the following algorithms but is beyond the scope of this class.
Rayleigh Quotient and Inverse Iteration¶
There are a number of classical approaches to computing the iterative step above which we will review here. Inverse power iteration in particular is today still the dominant means of finding the eigenvectors once the eigenvalues are known.
Rayleigh Quotient¶
The Rayleigh quotient of a vector is the scalar
The importance of the Rayleigh quotient is made clear when we evaluate at an eigenvector. When this is the case the quotient evaluates to the corresponding eigenvalue.
The Rayleigh quotient can be motivated by asking the question, given an eigenvector , what value acts most like an eigenvalue in an sense:
This can be reformulated as a least-squares problem noting that is the “matrix”, is the unknown vector (scalar) and is the right-hand side so we have
which can be solved so that
Power Iteration¶
Power iteration is a straight forward approach to finding the eigenvector of the largest eigenvalue of . The basic idea is that the sequence
will converge (although very slowly) to the desired eigenvector.
We implement this method by initializing the algorithm with some vector with . We then apply the sequence of multiplications.
The reason why this works can be seen by considering the initial vector as a linear combination of the orthonormal eigenvectors (which we have assumed exist) such that
Multiplying by then leads to
where is some constant due to the fact the eigenvectors are not uniquely specified. Repeating this times we have
Since for all then in the limit the terms will approach zero.
Inverse Iteration¶
Inverse iteration uses a similar approach with the difference being that we can use it to find any of the eigenvectors for the matrix .
Consider the matrix
the eigenvectors of this matrix are the same as with the eigenvalues
where are the eigenvalues of .
If is close to a particular , say , then
will be larger than any of the other . In this way we effectively have picked out the eigenvalue we want to consider in the power iteration!
Rayleigh Quotient Iteration¶
By themselves the above approaches are not particularly useful but combining them we can iterate back and forth to find the eigenvalue, eigenvector pair:
Compute the Rayleigh quotient and find an estimate for
Compute one step of inverse iteration to approximate
Repeat...
m = 3
A = numpy.array([[2, 1, 1], [1, 3, 1], [1, 1, 4]])
num_steps = 10
v = numpy.empty((num_steps, m))
lam = numpy.empty(num_steps)
v[0, :] = numpy.array([1, 1, 1])
v[0, :] = v[0, :] / numpy.linalg.norm(v[0, :], ord=2)
lam[0] = numpy.dot(v[0, :], numpy.dot(A, v[0, :]))
for k in range(1, num_steps):
w = numpy.linalg.solve(A - lam[k - 1] * numpy.identity(m), v[k - 1, :])
v[k, :] = w / numpy.linalg.norm(w, ord=2)
lam[k] = numpy.dot(v[k, :], numpy.dot(A, v[k, :]))
fig = plt.figure()
axes = fig.add_subplot(1, 1, 1)
axes.semilogy(range(10), numpy.abs(lam - numpy.linalg.eigvals(A)[0]), "o")
axes.set_title("Convergence of eigenvalue")
axes.set_xlabel("Step")
axes.set_ylabel("Error")
plt.show()QR Algorithm¶
The most basic use of a factorization to find eigenvalues is to iteratively compute the factorization and multiply the resulting and in the reverse order. This sequence will eventually converge to the Schur decomposition of the matrix .
Code this up and see what happens.
%precision 6
m = 3
A = numpy.array([[2, 1, 1], [1, 3, 1], [1, 1, 4]])
MAX_STEPS = 10
for i in range(MAX_STEPS):
Q, R = numpy.linalg.qr(A)
A = numpy.dot(R, Q)
print()
print("A(%s) =" % (i))
print(A)
print()
print("True eigenvalues: ")
print(numpy.linalg.eigvals(A))
print()
print("Computed eigenvalues: ")
for i in range(m):
print(A[i, i])So why does this work? The first step is to find the factorization of which is equivalent to finding
and multiplying on the right leads to
In this way we can see that this is a similarity transformation of the matrix since the is an orthogonal matrix (). This of course is not a great idea to do directly but works great in this case as we iterate to find the upper triangular matrix which is exactly where the eigenvalues appear.
In practice this basic algorithm is modified to include a few additions:
Before starting the iteration is reduced to tridiagonal form.
Motivated by the inverse power iteration we observed we instead consider a shifted matrix for factoring. The picked is related to the estimate given by the Rayleigh quotient. Here we have
Deflation is used to reduce the matrix into smaller matrices once (or when we are close to) finding an eigenvalue to simplify the problem.
This has been the standard approach until recently for finding eigenvalues of a matrix.
Alternatives¶
Jacobi¶
Jacobi iteration employs the idea that we know the eigenvalues of a matrix of size equal to or less than 4 (we know the roots of the characteristic polynomial directly). Jacobi iteration therefore attempts to break the matrix down into at most 4 by 4 matrices along the diagonal via a series of similarity transformations based on only diagonalizing sub-matrices 4 by 4 or smaller.
Bisection¶
It turns out if you do not want all of the eigenvalues of a matrix that using a bisection method to find some subset of the eigenvalues is often the most efficient way to get these. This avoids the pitfall of trying to find the eigenvalues via other root-finding approaches by only needing evaluations of the function and if a suitable initial guess is provided can find the eigenvalue quickly that is closest to the initial bracket provided.
Divide-and-conquer¶
This algorithm is actually the one used most often used if both eigenvalues and eigenvectors are needed and performs up to twice as fast as the approach. The basic idea is to split the matrix into two pieces at every iteration by introducing zeros on the appropriate off-diagonals which neatly divides the problem into two pieces.
Arnoldi and Lanczos Iteration¶
Krylov subspace methods (which we will unfortunately not cover) are another approach to finding eigenvalues of a matrix. These methods generally use some piece of the approach outlined above and are extremely effective at finding the “extreme” eigenvalues of the matrix.
