Quotient rings of polynomial rings over finite fields

30 views
Skip to first unread message

Ryan Schwiebert

unread,
Mar 13, 2018, 9:03:26 PM3/13/18
to sympy
I've been having some trouble working with quotient rings. I can't even seem to instantiate an element:


import sympy
from sympy.abc import x, yfrom sympy.polys.domains.quotientring import QuotientRingElement

k
= sympy.FF(2)R = FF(2).old_poly_ring(x,y)
I
= FF(2).old_poly_ring(x,y).ideal(x**2, x*y, y**2)
S
= R/I

X
= QuotientRingElement(S, x)
X
+X

Traceback (most recent call last):
 
File "<stdin>", line 1, in <module>
 
File "/usr/local/lib/python3.6/site-packages/sympy/polys/domains/quotientring.py", line 41, in __add__
 
return self.ring(self.data + om.data)
 
File "/usr/local/lib/python3.6/site-packages/sympy/polys/domains/domain.py", line 84, in __call__
 
return self.new(*args)
 
File "/usr/local/lib/python3.6/site-packages/sympy/polys/domains/quotientring.py", line 139, in new
 a
= self.ring(a)
 
File "/usr/local/lib/python3.6/site-packages/sympy/polys/domains/domain.py", line 84, in __call__
 
return self.new(*args)
 
File "/usr/local/lib/python3.6/site-packages/sympy/polys/domains/old_polynomialring.py", line 56, in new
 
return self.dtype(element, self.dom, len(self.gens) - 1, ring=self)
 
File "/usr/local/lib/python3.6/site-packages/sympy/polys/polyclasses.py", line 155, in __init__
 rep
= dmp_ground(dom.convert(rep), lev)
 
File "/usr/local/lib/python3.6/site-packages/sympy/polys/domains/domain.py", line 145, in convert
 
return self.from_sympy(element)
 
File "/usr/local/lib/python3.6/site-packages/sympy/polys/domains/finitefield.py", line 71, in from_sympy
 
raise CoercionFailed("expected an integer, got %s" % a)
sympy
.polys.polyerrors.CoercionFailed: expected an integer, got 2*x


Is there another idiomatic way I should be doing this? Or are quotients of polynomial rings over finite fields not well-supported? I was hoping to do a couple quotients of free modules too...

Thanks in advance for advice.

Leonid Kovalev

unread,
Mar 13, 2018, 11:11:47 PM3/13/18
to sympy
I think QuotientRingElement is not meant to be instantiated directly like that. The docstring of QuotientRing discourages that, and I suppose the same applies to QuotientRingElement.  Using S.from_sympy(x) works better. Example: 

>>> S = FF(2).old_poly_ring(x, y)/[x**2, x*y, y**2]
>>> S
GF
(2)[x,y]/<x**2,x*y,y**2>
>>> X = S.from_sympy(x)
>>> Y = S.from_sympy(y)
>>> print(X + X)
0 + <x**2,x*y,y**2>
>>> print(X + Y)
x
+ y + <x**2,x*y,y**2>
>>> print((X+Y)**2)
0 + <x**2,x*y,y**2>



Leonid Kovalev

unread,
Mar 13, 2018, 11:25:29 PM3/13/18
to sympy
But it's better to avoid using variable name S, as S is heavily used in SymPy, in two ways: https://stackoverflow.com/a/41867990 
Reply all
Reply to author
Forward
0 new messages