Definition SIM. Similar Matrices.
Suppose and are two square matrices of size Then and are similar if there exists a nonsingular matrix of size such that
Equivalently, we can require that
.is_similar()
. However, computationally this can be a very difficult proposition, so support in Sage is incomplete now, though it will always return a result for matrices with rational entries. Here are examples where the two matrices are, and are not, similar. Notice that the keyword option transformation=True
will cause a pair to be returned, such that if the matrices are indeed similar, the matrix effecting the similarity transformation will be in the second slot of the pair.xxxxxxxxxx
A = matrix(QQ, [[ 25, 2, -8, -1, 11, 26, 35],
[ 28, 2, -15, 2, 6, 34, 31],
[ 1, -17, -25, 28, -44, 26, -23],
[ 36, -2, -24, 10, -1, 50, 39],
[ 0, -7, -13, 14, -21, 14, -11],
[-22, -17, -16, 27, -51, 1, -53],
[ -1, 10, 17, -18, 28, -18, 15]])
B = matrix(QQ, [[-89, -16, -55, -23, -104, -48, -67],
[-15, 1, -20, -21, -20, -60, -26],
[ 48, 6, 37, 25, 59, 64, 46],
[-96, -16, -49, -16, -114, -23, -67],
[ 56, 10, 33, 13, 67, 29, 37],
[ 10, 2, 2, -2, 12, -9, 4],
[ 28, 6, 13, 1, 32, -4, 16]])
is_sim, trans = A.is_similar(B, transformation=True)
is_sim
trans
. We convert the entries to numerical approximations, clip very small values (less than trans
all by itself.xxxxxxxxxx
trans.change_ring(RDF).zero_at(10^-5).round(3)
C
is not similar to A
(and hence not similar to B
by Theorem SER), so we illustrate the return value when we do not request the similarity matrix (since it does not even exist).xxxxxxxxxx
C = matrix(QQ, [[ 16, -26, 19, -56, 26, 8, -49],
[ 20, -43, 36, -102, 52, 23, -65],
[-18, 29, -21, 62, -30, -9, 56],
[-17, 31, -27, 73, -37, -16, 49],
[ 18, -36, 30, -82, 43, 18, -54],
[-32, 62, -56, 146, -77, -35, 88],
[ 11, -19, 17, -44, 23, 10, -29]])
C.is_similar(A)
.eigenmatrix_right()
(and the analogous .eigenmatrix_left()
). It always returns two square matrices of the same size as the original matrix. The first matrix of the output is a diagonal matrix with the eigenvalues of the matrix filling the diagonal entries of the matrix. The second matrix has eigenvectors in the columns, in the same order as the corresponding eigenvalues. For a single eigenvalue, these columns/eigenvectors form a linearly independent set.is_diagonalizable()
.xxxxxxxxxx
A = matrix(QQ, [[ 2, -18, -68, 64, -99, -87, 83],
[ 4, -10, -41, 34, -58, -57, 46],
[ 4, 16, 59, -60, 86, 70, -72],
[ 2, -15, -65, 57, -92, -81, 78],
[-4, -7, -32, 31, -45, -31, 41],
[ 2, -6, -22, 20, -32, -31, 26],
[ 0, 7, 30, -27, 42, 37, -36]])
D, S = A.eigenmatrix_right()
D
xxxxxxxxxx
S
xxxxxxxxxx
S.inverse()*A*S == D
xxxxxxxxxx
A.is_diagonalizable()
xxxxxxxxxx
B = matrix(QQ, [[ 37, -13, 30, 81, -74, -13, 18],
[ 6, 26, 21, -11, -46, -48, 19],
[ 16, 10, 29, 16, -42, -39, 26],
[-24, 8, -24, -53, 54, 13, -15],
[ -8, 3, -8, -20, 24, 4, -5],
[ 31, 12, 46, 48, -97, -56, 35],
[ 8, 5, 16, 12, -34, -20, 11]])
D, S = B.eigenmatrix_right()
D
xxxxxxxxxx
S
xxxxxxxxxx
B*S == S*D
xxxxxxxxxx
B.is_diagonalizable()