-
galois.Poly.derivative(k: int =
1
) Poly Computes the \(k\)-th formal derivative \(\frac{d^k}{dx^k} f(x)\) of the polynomial \(f(x)\).
Notes¶
For the polynomial
\[f(x) = a_d x^d + a_{d-1} x^{d-1} + \dots + a_1 x + a_0\]the first formal derivative is defined as
\[f'(x) = (d) \cdot a_{d} x^{d-1} + (d-1) \cdot a_{d-1} x^{d-2} + \dots + (2) \cdot a_{2} x + a_1\]where \(\cdot\) represents scalar multiplication (repeated addition), not finite field multiplication. The exponent that is “brought down” and multiplied by the coefficient is an integer, not a finite field element. For example, \(3 \cdot a = a + a + a\).
References¶
Examples¶
Compute the derivatives of a polynomial over \(\mathrm{GF}(2)\).
In [1]: f = galois.Poly.Random(7); f Out[1]: Poly(x^7 + x^4 + x^3, GF(2)) In [2]: f.derivative() Out[2]: Poly(x^6 + x^2, GF(2)) # p derivatives of a polynomial, where p is the field's characteristic, will always result in 0 In [3]: f.derivative(GF.characteristic) Out[3]: Poly(0, GF(2))
Compute the derivatives of a polynomial over \(\mathrm{GF}(7)\).
In [4]: GF = galois.GF(7) In [5]: f = galois.Poly.Random(11, field=GF); f Out[5]: Poly(3x^11 + 4x^10 + x^9 + 4x^7 + 5x^6 + 5x^5 + 3x^4 + 3x^3 + 4x^2 + 6x + 5, GF(7)) In [6]: f.derivative() Out[6]: Poly(5x^10 + 5x^9 + 2x^8 + 2x^5 + 4x^4 + 5x^3 + 2x^2 + x + 6, GF(7)) In [7]: f.derivative(2) Out[7]: Poly(x^9 + 3x^8 + 2x^7 + 3x^4 + 2x^3 + x^2 + 4x + 1, GF(7)) In [8]: f.derivative(3) Out[8]: Poly(2x^8 + 3x^7 + 5x^3 + 6x^2 + 2x + 4, GF(7)) # p derivatives of a polynomial, where p is the field's characteristic, will always result in 0 In [9]: f.derivative(GF.characteristic) Out[9]: Poly(0, GF(7))
Compute the derivatives of a polynomial over \(\mathrm{GF}(3^5)\).
In [10]: GF = galois.GF(3**5) In [11]: f = galois.Poly.Random(7, field=GF); f Out[11]: Poly(226x^7 + 59x^6 + 45x^5 + 84x^4 + 8x^3 + 207x^2 + 6x + 41, GF(3^5)) In [12]: f.derivative() Out[12]: Poly(226x^6 + 63x^4 + 84x^3 + 144x + 6, GF(3^5)) In [13]: f.derivative(2) Out[13]: Poly(63x^3 + 144, GF(3^5)) # p derivatives of a polynomial, where p is the field's characteristic, will always result in 0 In [14]: f.derivative(GF.characteristic) Out[14]: Poly(0, GF(3^5))