Adjoint matrix: adjoint_matrix

### 6.48.10 Adjoint matrix: adjoint_matrix

The comatrix of a square matrix A of size n is the matrix B defined by A× B=det(A)× I. The adjoint matrix Q(x) of A is the comatrix of xI−A. It is a polynomial of degree n−1 in x having matrix coefficients and satisfies:

(xI−A)Q(x) = det(xI−A)I= P(x)× I

where P(x) is the characteristic polynomial of A. Since the polynomial P(x)× I−P(A) (with matrix coefficients) is also divisible by x× I−A (by algebraic identities), this means that P(A)=0. We also have Q(x) = I× xn−1+…+B0 where B0= is the comatrix of A (times -1 if n is odd).

The adjoint_matrix command finds the characteristic polynomial and adjoint of a given matrix.

- adjoint_matrix takes one argument:
  A, a square matrix.
- adjoint_matrix(A) returns the list of the coefficients of P(x) (the characteristic polynomial of A), and the list of the matrix coefficients of Q(x) (the adjoint matrix of A).

Examples.

- Input:
  adjoint_matrix([[4,1,-2],[1,2,-1],[2,1,0]])
  Output:

  ⎡ ⎢ ⎢ ⎣ | ⎡ ⎣ | 1,−6,12,−8 | ⎤ ⎦ | , | ⎡ ⎢ ⎢ ⎣ | ⎡ ⎢ ⎢ ⎣ |
  1 | 0 | 0
  0 | 1 | 0
  0 | 0 | 1
  | ⎤ ⎥ ⎥ ⎦ | , | ⎡ ⎢ ⎢ ⎣ |
  −2 | 1 | −2
  1 | −4 | −1
  2 | 1 | −6
  | ⎤ ⎥ ⎥ ⎦ | , | ⎡ ⎢ ⎢ ⎣ |
  1 | −2 | 3
  −2 | 4 | 2
  −3 | −2 | 7
  | ⎤ ⎥ ⎥ ⎦ | ⎤ ⎥ ⎥ ⎦ | ⎤ ⎥ ⎥ ⎦

  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−2 x+1 | x−2 | −2 x+3
  x−2 | x2−4 x+4 | −x+2
  2 x−3 | x−2 | x2−6 x+7
  | ⎤ ⎥ ⎥ ⎦

- Input:
  adjoint_matrix([[4,1],[1,2]])
  Output:

  ⎡ ⎢ ⎣ | ⎡ ⎣ | 1,−6,7 | ⎤ ⎦ | , | ⎡ ⎢ ⎣ | ⎡ ⎢ ⎣ |
  1 | 0
  0 | 1
  | ⎤ ⎥ ⎦ | , | ⎡ ⎢ ⎣ |
  −2 | 1
  1 | −4
  | ⎤ ⎥ ⎦ | ⎤ ⎥ ⎦ | ⎤ ⎥ ⎦

  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
  | ⎤ ⎥ ⎦