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)$$.

Parameters:
k: int = 1

The number of derivatives to compute. 1 corresponds to $$p'(x)$$, 2 corresponds to $$p''(x)$$, etc. The default is 1.

Returns:

The $$k$$-th formal derivative of the polynomial $$f(x)$$.

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$$.

Examples

Compute the derivatives of a polynomial over $$\mathrm{GF}(2)$$.

In : f = galois.Poly.Random(7); f
Out: Poly(x^7 + x^6 + x^5 + x^4 + 1, GF(2))

In : f.derivative()
Out: Poly(x^6 + x^4, GF(2))

# p derivatives of a polynomial, where p is the field's characteristic, will always result in 0
In : f.derivative(GF.characteristic)
Out: Poly(0, GF(2))


Compute the derivatives of a polynomial over $$\mathrm{GF}(7)$$.

In : GF = galois.GF(7)

In : f = galois.Poly.Random(11, field=GF); f
Out: Poly(6x^11 + 4x^10 + 4x^8 + x^7 + 2x^6 + 2x^4 + 2x^3 + 3x, GF(7))

In : f.derivative()
Out: Poly(3x^10 + 5x^9 + 4x^7 + 5x^5 + x^3 + 6x^2 + 3, GF(7))

In : f.derivative(2)
Out: Poly(2x^9 + 3x^8 + 4x^4 + 3x^2 + 5x, GF(7))

In : f.derivative(3)
Out: Poly(4x^8 + 3x^7 + 2x^3 + 6x + 5, GF(7))

# p derivatives of a polynomial, where p is the field's characteristic, will always result in 0
In : f.derivative(GF.characteristic)
Out: Poly(0, GF(7))


Compute the derivatives of a polynomial over $$\mathrm{GF}(3^5)$$.

In : GF = galois.GF(3**5)

In : f = galois.Poly.Random(7, field=GF); f
Out: Poly(118x^7 + 91x^6 + 116x^5 + 63x^4 + 32x^3 + 19x^2 + 50x + 71, GF(3^5))

In : f.derivative()
Out: Poly(118x^6 + 220x^4 + 63x^3 + 11x + 50, GF(3^5))

In : f.derivative(2)
Out: Poly(220x^3 + 11, GF(3^5))

# p derivatives of a polynomial, where p is the field's characteristic, will always result in 0
In : f.derivative(GF.characteristic)
Out: Poly(0, GF(3^5))