x=Symbol('x')
M=Matrix([[1,x],[x^2,x^3]])
s=M.det()
f=lambdify(x,s)
I need to know f(2)=? in GF(2^8),the caculate rules obey the GF(2^8)
x=Symbol('x')
M=Matrix([[1,x],[x^2,x^3]])
s=M.det()
f=lambdify(x,s)
I need to know f(2)=? in GF(2^8),the caculate rules obey the GF(2^8)
It's not exactly clear what you're asking to do, but here are some tools to assist. I created a Python package galois that extends NumPy arrays over Galois fields. All finite fields GF(p^m)
are supported. Linear algebra and polynomials, among much more, are also supported.
Here is an example computing the matrix determinant and polynomial evaluation you alluded to.
In [1]: import numpy as np
In [2]: import galois
# Create a Galois field class
In [3]: GF = galois.GF(2**8)
# The irreducible polynomial is the one you specified in your comment
In [4]: print(GF.properties)
GF(2^8):
characteristic: 2
degree: 8
order: 256
irreducible_poly: x^8 + x^4 + x^3 + x^2 + 1
is_primitive_poly: True
primitive_element: x
# Create an array from its polynomials over GF(2) with degree < 8
In [5]: M = GF([[1, "x"], ["x^2", "x^3"]]); M
Out[5]:
GF([[1, 2],
[4, 8]], order=2^8)
# Compute the determinant of the matrix
In [6]: np.linalg.det(M)
Out[6]: GF(0, order=2^8)
# Construct the polynomial x^2 + x as you mentioned in your comment
In [7]: f = galois.Poly([1, 1, 0], field=GF); f
Out[7]: Poly(x^2 + x, GF(2^8))
# Evaluate the polynomial at x = 2
In [8]: f(2)
Out[8]: GF(6, order=2^8)
In GF(2^8), the elements are usually represented as formal polynomials of degree 7, which are sums of monic monomials. E.g. x² + x, which can be written in the compact form 00000110 (this is not to be taken as an ordinary binary number).
Evaluating the polynomial at some x does not make sense and is not made, especially as x should not be other than 0 or 1. (You might be tempted to say that 0²+0=0 and 1²+1=0, but this is irrelevant.)