adjoint_matrix takes as argument a square matrix
A of size n.
adjoint_matrix returns the list of the coefficients of P
(the characteristic polynomial of A), and
the list of the matrix coefficients of Q (the adjoint matrix
of A).
The comatrix of a square matrix A of size n is the matrix B defined by A× B=det(A)× I. The adjoint matrix of A is the comatrix of xI−A. It is a polynomial of degree n−1 in x having matrix coefficients. The following relation holds:
P(x)× I=det(xI−A)I=(xI−A)Q(x) |
Since the polynomial P(x)× I−P(A) (with matrix coefficients) is also divisible by x× I−A (by algebraic identities), this proves that P(A)=0. We also have Q(x) = I× xn−1+...+B0 where B0= is the comatrix of A (up to the sign if n is odd). Input :
Output :
Hence the characteristic polynomial is :
P(x)=x3−6*x2+12*x−8 |
The determinant of A is equal to −P(0)=8. The comatrix of A is equal to :
B=Q(0)=[[1,−2,3],[−2,4,2],[−3,−2,7]] |
Hence the inverse of A is equal to :
1/8*[[1,−2,3],[−2,4,2],[−3,−2,7]] |
The adjoint matrix of A is :
[[x2−2x+1,x−2,−2x+3],[x−2,x2−4x+4,−x+2],[2x−3,x−2,x2−6x+7]] |
Input :
Output :
Hence the characteristic polynomial P is :
P(x)=x2−6*x+7 |
The determinant of A is equal to +P(0)=7. The comatrix of A is equal to
Q(0)= −[[−2,1],[1,−4]] |
Hence the inverse of A is equal to :
−1/7*[[−2,1],[1,−4]] |
The adjoint matrix of A is :
−[[x−2,1],[1,x−4]] |