- galois.FieldArray.characteristic_poly() Poly
Computes the characteristic polynomial of a finite field element \(a\) or a square matrix \(\mathbf{A}\).
Important
This function may only be invoked on a single finite field element (scalar 0-D array) or a square \(n \times n\) matrix (2-D array).
- Returns¶
For scalar inputs, the degree-\(m\) characteristic polynomial \(c_a(x)\) of \(a\) over \(\mathrm{GF}(p)\). For square \(n \times n\) matrix inputs, the degree-\(n\) characteristic polynomial \(c_A(x)\) of \(\mathbf{A}\) over \(\mathrm{GF}(p^m)\).
Notes¶
An element \(a\) of \(\mathrm{GF}(p^m)\) has characteristic polynomial \(c_a(x)\) over \(\mathrm{GF}(p)\). The characteristic polynomial when evaluated in \(\mathrm{GF}(p^m)\) annihilates \(a\), that is \(c_a(a) = 0\). In prime fields \(\mathrm{GF}(p)\), the characteristic polynomial of \(a\) is simply \(c_a(x) = x - a\).
An \(n \times n\) matrix \(\mathbf{A}\) has characteristic polynomial \(c_A(x) = \textrm{det}(x\mathbf{I} - \mathbf{A})\) over \(\mathrm{GF}(p^m)\). The constant coefficient of the characteristic polynomial is \(\textrm{det}(-\mathbf{A})\). The \(x^{n-1}\) coefficient of the characteristic polynomial is \(-\textrm{Tr}(\mathbf{A})\). The characteristic polynomial annihilates \(\mathbf{A}\), that is \(c_A(\mathbf{A}) = \mathbf{0}\).
References¶
Examples¶
The characteristic polynomial of the element \(a\).
In [1]: GF = galois.GF(3**5) In [2]: a = GF.Random(); a Out[2]: GF(48, order=3^5) In [3]: poly = a.characteristic_poly(); poly Out[3]: Poly(x^5 + x^3 + x + 1, GF(3)) # The characteristic polynomial annihilates a In [4]: poly(a, field=GF) Out[4]: GF(0, order=3^5)
The characteristic polynomial of the square matrix \(\mathbf{A}\).
In [5]: GF = galois.GF(3**5) In [6]: A = GF.Random((3,3)); A Out[6]: GF([[194, 108, 213], [127, 96, 121], [133, 212, 144]], order=3^5) In [7]: poly = A.characteristic_poly(); poly Out[7]: Poly(x^3 + 172x^2 + 28x + 159, GF(3^5)) # The x^0 coefficient is det(-A) In [8]: poly.coeffs[-1] == np.linalg.det(-A) Out[8]: True # The x^n-1 coefficient is -Tr(A) In [9]: poly.coeffs[1] == -np.trace(A) Out[9]: True # The characteristic polynomial annihilates the matrix A In [10]: poly(A, elementwise=False) Out[10]: GF([[0, 0, 0], [0, 0, 0], [0, 0, 0]], order=3^5)