Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SymPy polynomials over finite fields

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?

like image 853
Kevin Johnson Avatar asked May 01 '15 02:05

Kevin Johnson


1 Answers

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)
like image 142
iacob Avatar answered Sep 22 '22 17:09

iacob