On Thursday, August 18, 2016 at 9:30:23 PM UTC+3, clemens novak wrote: > > Hello, > > I try to perform calculations in GF(2^3); e.g. calculate (x^2+x)(x+1) = > x^3 + 2x^2 + x = x^3 + x as polynomial coefficients are modulo-2. Using the > irreducible polynomial x^3 + x + 1 I arrive at (x^2+x)(x+1) = 1. > > I try to do the same in sympy > > > import sympy as sym > import sympy.polys as polys > import sympy.polys.galoistools as gft > > F = polys.domains.FF(2) > # x^2 + x > a = [1, 1, 0] > # x + 1 > b = [1, 1] > > res = gft.gf_mul(a, b, 8, F) > > sym.pprint(res) > > but arrive at [1 mod 2, 0 mod 2, 1 mod 2, 0 mod 2] which I interpret as > x^3 + x. So it seems that the reduction using the irreducible polynomial is > not done - is there a way to do this last step in sympy? > > Thanks & regards - Clemens >
The galoistool functions gf_* are low level functions that are not intended for general use. Instead, one can use the standard polynomial methods as follows, for example: >>> from sympy.abc import x >>> a = (x**2 + x).as_poly(modulus=2) >>> b = (x + 1).as_poly(modulus=2) >>> p = (x**3 + x + 1).as_poly(modulus=2) >>> (a*b).rem(p).as_expr() 1 -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/652ebeef-6c5b-435c-82bc-d9e6235a56a0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.