Definition EEM. Eigenvalues and Eigenvectors of a Matrix.
Suppose that is a square matrix of size is a vector in and is a scalar in Then we say is an eigenvector of with eigenvalue if
.eigenvalues()
and .eigenvectors_right()
will produce what you expect, though the format of the eigenvector output requires some explanation. Here is Example SEE from the start of this chapter.xxxxxxxxxx
A = matrix(QQ, [[ 204, 98, -26, -10],
[-280, -134, 36, 14],
[ 716, 348, -90, -36],
[-472, -232, 60, 28]])
A.eigenvalues()
xxxxxxxxxx
A.eigenvectors_right()
eigenvalues()
, though for some reason the eigenvalue eigenvectors_right()
method is a list of triples. Each triple begins with an eigenvalue. This is followed by a list of eigenvectors for that eigenvalue. Notice the first eigenvector is identical to the one we described in Example SEE. The eigenvector for lambda
has a special purpose in Sage, so do not try to use this as a name for your eigenvalues..charpoly()
and .characteristic_polynomial()
do exactly the same thing. We will use the longer name just to be more readable, you may prefer the shorter.xxxxxxxxxx
A = matrix(QQ, [[-24, 6, 0, -1, 31, 7],
[ -9, -2, -8, -17, 24, -29],
[ 4, -10, 1, 1, -12, -36],
[-19, 11, -1, -4, 33, 29],
[-11, 6, 2, 3, 14, 21],
[ 5, -1, 2, 5, -11, 4]])
A.characteristic_polynomial()
xxxxxxxxxx
A.characteristic_polynomial().factor()
xxxxxxxxxx
B = A.change_ring(QQbar)
B.characteristic_polynomial()
xxxxxxxxxx
B.characteristic_polynomial().factor()
QQ
, the factorization of the characteristic polynomial does not “leave” that number system, only factoring “far enough” to retain factors with rational coefficients. The solutions to QQbar
to the rescue. Since this number system contains the roots of every possible polynomial with integer coefficients, we can totally factor any characteristic polynomial that results from a matrix with entries from QQbar
. A common situation will be to begin with a matrix having rational entries, yet the matrix has a characteristic polynomial with roots that are complex numbers.extend
keyword option, which tells Sage whether or not to expand the number system to contain the eigenvalues.xxxxxxxxxx
A.eigenvalues(extend=False)
xxxxxxxxxx
A.eigenvalues(extend=True)
QQ
, the default behavior is to extend to QQbar
when necessary. But for other number systems, you may need to explicitly use the extend=True
option.QQbar
, which is not strictly necessary for this simple matrix.xxxxxxxxxx
A = matrix(QQ, [[204, 98, -26, -10],
[-280, -134, 36, 14],
[716, 348, -90, -36],
[-472, -232, 60, 28]])
A.characteristic_polynomial().roots(QQbar)
CDF
as our number system). This is Example EMMS4, both as an exact matrix with entries from QQbar
and as an approximate matrix with entries from CDF
.xxxxxxxxxx
A = matrix(QQ, [[-2, 1, -2, -4],
[12, 1, 4, 9],
[ 6, 5, -2, -4],
[ 3, -4, 5, 10]])
A.eigenvalues()
xxxxxxxxxx
B = A.change_ring(CDF)
B.eigenvalues()
.eigenvectors_right()
will return a list of eigenvectors that is a basis for the associated eigenspace. The method .eigenspaces_right()
will return an eigenspace (in other words, a vector space, rather than a list of vectors) for each eigenvalue. There are also eigenmatrix
methods which we will describe at the end of the chapter in Sage MD..eigenvectors_right()
(or equivalently the matrix method .right_eigenvectors()
) produces a list of triples, one triple per eigenvalue. Each triple has an eigenvalue, a list, and then the algebraic multiplicity of the eigenvalue. The list contains vectors forming a basis for the eigenspace. Notice that the length of the list of eigenvectors will be the geometric multiplicity (and there is no easier way to get this information).xxxxxxxxxx
A = matrix(QQ, [[-5, 1, 7, -15],
[-2, 0, 5, -7],
[ 1, -5, 7, -3],
[ 4, -7, 3, 4]])
A.eigenvectors_right()
QQbar
to get the complex eigenvalues..eigenspaces_right()
(equal to .right_eigenspaces()
) produces a list of pairs, one pair per eigenvalue. Each pair has an eigenvalue, followed by the eigenvalue’s eigenspace. Notice that the basis matrix of the eigenspace may not have the same eigenvectors you might get from other methods. Similar to the eigenvectors
method, the dimension of the eigenspace will yield the geometric multiplicity (and there is no easier way to get this information). If you need the algebraic multiplicities, you can supply the keyword option algebraic_multiplicity=True
to get back triples with the algebraic multiplicity in the third entry of the triple. We will recycle the example above, and not demonstrate the algebraic multiplicity option. (We have formatted the one-row basis matrices over QQbar
across several lines.)xxxxxxxxxx
A.eigenspaces_right()
xxxxxxxxxx
A = matrix(QQ, [[-5, 1, 7, -15],
[-2, 0, 5, -7],
[ 1, -5, 7, -3],
[ 4, -7, 3, 4]])
# eigenvalues
A.characteristic_polynomial()
xxxxxxxxxx
A.characteristic_polynomial().factor()
xxxxxxxxxx
A.characteristic_polynomial().roots(QQbar)
xxxxxxxxxx
# eigenspaces, rational
(A-3*identity_matrix(4)).right_kernel(basis='pivot')
xxxxxxxxxx
# eigenspaces, complex
B = A.change_ring(QQbar)
evalue = QQbar(2*I)
(B-evalue*identity_matrix(4)).right_kernel(basis='pivot')
xxxxxxxxxx
evalue = QQbar(-2*I)
(B-evalue*identity_matrix(4)).right_kernel(basis='pivot')
basis='pivot'
keyword option so that bases for the eigenspaces look more like the bases described in Theorem BNS.basis='echelon'
option)..eigenvalues()
method not come in left and right versions? The upcoming Theorem ETM can be used to show that the two versions would have identical output, so there is no need.