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^4 + x + 1, GF(2))

In : f.derivative()
Out: Poly(x^6 + 1, 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 + x^10 + x^7 + 6x^6 + 5x^5 + 5x^4 + 2x^3 + 4x^2 + 3x + 3, GF(7))

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

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

In : f.derivative(3)
Out: Poly(4x^8 + 6x^7 + 6x^3 + 6x^2 + x + 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(230x^7 + 91x^6 + 196x^5 + 135x^4 + 188x^3 + 161x^2 + 124x + 237, GF(3^5))

In : f.derivative()
Out: Poly(230x^6 + 140x^4 + 135x^3 + 202x + 124, GF(3^5))

In : f.derivative(2)
Out: Poly(140x^3 + 202, 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))