galois.Poly.derivative(k: int = 1) Poly

Computes the k-th formal derivative dkdxkf(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).

Notes

For the polynomial

f(x)=adxd+ad1xd1++a1x+a0

the first formal derivative is defined as

f(x)=(d)adxd1+(d1)ad1xd2++(2)a2x+a1

where 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, 3a=a+a+a.

References

Examples

Compute the derivatives of a polynomial over GF(2).

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

In [2]: f.derivative()
Out[2]: Poly(x^6, 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 GF(7).

In [4]: GF = galois.GF(7)

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

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

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

In [8]: f.derivative(3)
Out[8]: Poly(2x^8 + 6x^7 + 6x^3 + 3x + 2, 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 GF(35).

In [10]: GF = galois.GF(3**5)

In [11]: f = galois.Poly.Random(7, field=GF); f
Out[11]: Poly(78x^7 + 58x^6 + 145x^5 + 46x^4 + 125x^3 + 127x^2 + 199x + 10, GF(3^5))

In [12]: f.derivative()
Out[12]: Poly(78x^6 + 209x^4 + 46x^3 + 227x + 199, GF(3^5))

In [13]: f.derivative(2)
Out[13]: Poly(209x^3 + 227, 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))