SymPy polynomials over finite fields
Asked Answered
P

1

12
import sympy as S 
F = S.FiniteField(101)

When I call f = S.poly(y ** 2 - x ** 3 - x - 1,F) I get the following error:

'FiniteField' object has no attribute 'is_commutative'

But finite fields are commutative by definition! So I'm not really sure what this error is supposed to mean!

Has anyone come across this before? How do you declare polynomials over a finite field?

Presence answered 1/5, 2015 at 2:15 Comment(1)
From my experiments you can make polynomials over finite fields with, eg., sympy.poly(x**2 + y - 1, x, y, domain=sympy.FF(101)). However, this seems to fail to cooperate with other sympy functionality, such as solving equations. I have opened an issue here: github.com/sympy/sympy/issues/9821Actinomycin
C
1

is_commutative is an attribute of operators generally. It is not implemented for domains (unlike is_numeric etc).

e.g.

>>> F = sympy.RealField() #returns the same error
>>> f = sympy.poly(y ** 2 - x ** 3 - x - 1, F)

AttributeError: 'RealField' object has no attribute 'is_commutative'

Hence, poly is interpreting your positional argument as something other than the domain. To get the intended behaviour with poly (and factor etc) you must use the domain (or equivalent) kwarg i.e:

f = sympy.poly(y ** 2 - x ** 3 - x - 1, domain=F)
Chatterjee answered 6/4, 2021 at 11:24 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.