Ask Your Question
1

Polynomial division on non usual ring.

asked 2022-02-15 04:47:11 +0200

rafael gravatar image

updated 2022-02-15 09:47:58 +0200

slelievre gravatar image

Hello everyone, I hope you are well.

I'm trying to do the algorithm of division between polynomials in an unusual ring and I'm having problems. I searched in some forums and couldn't find anything on the subject.

The idea is to do the division in the following ring R:

UCF = UniversalCyclotomicField()
R.<x,y> = PolynomialRing(UCF,2,'x','y', order='lex')

The idea is to get the coefficient between $f/g=q$, with $f$, $g \in R[x,y]$.

But overall the result of $f/g$ is just giving $f/g$, even in the case where $f=g$.

I try this method in Ask Sage question 50406 but Sage can't do the math.

Thank you for your attention.

edit retag flag offensive close merge delete

Comments

Do you just want q = f // g? Note the double slashes.

rburing gravatar imagerburing ( 2022-02-15 05:03:20 +0200 )edit

i dont know what the // double slashes do. Anyway, this return a error: KeyError: '_PolynomialRing_singular_repr__singular'

rafael gravatar imagerafael ( 2022-02-15 05:30:31 +0200 )edit

Please give us a concrete example.

FrédéricC gravatar imageFrédéricC ( 2022-02-15 11:23:41 +0200 )edit

for example, when i try to do:

UCF = UniversalCyclotomicField() R.<x,y> = PolynomialRing(UCF,2,'x','y', order='lex')

(E(3)x+y)/(E(3)x+y)

the output is symbolic: (E(3)x+y)/(E(3)x+y)

and i need the output: 1.

rafael gravatar imagerafael ( 2022-02-15 19:39:53 +0200 )edit

Can you illustrate how "Sage can't do the math" ?

Max Alekseyev gravatar imageMax Alekseyev ( 2022-02-15 20:53:46 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2022-02-15 21:28:31 +0200

FrédéricC gravatar image

Here is the traceback

sage: UCF = UniversalCyclotomicField()
sage: R.<x,y> = PolynomialRing(UCF,order='lex')
sage: a=(E(3)*x+y)/(E(3)*x+y)
sage: a.reduce()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/structure/category_object.pyx in sage.structure.category_object.CategoryObject.getattr_from_category (build/cythonized/sage/structure/category_object.c:7152)()
    838         try:
--> 839             return self.__cached_methods[name]
    840         except KeyError:

KeyError: '_PolynomialRing_singular_repr__singular'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/rings/polynomial/polynomial_singular_interface.py in _singular_(self, singular)
    210         try:
--> 211             R = self.__singular
    212             if not (R.parent() is singular):

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/structure/category_object.pyx in sage.structure.category_object.CategoryObject.__getattr__ (build/cythonized/sage/structure/category_object.c:7071)()
    832         """
--> 833         return self.getattr_from_category(name)
    834 

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/structure/category_object.pyx in sage.structure.category_object.CategoryObject.getattr_from_category (build/cythonized/sage/structure/category_object.c:7237)()
    847 
--> 848             attr = getattr_from_other_class(self, cls, name)
    849             self.__cached_methods[name] = attr

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/cpython/getattr.pyx in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2630)()
    355         dummy_error_message.name = name
--> 356         raise AttributeError(dummy_error_message)
    357     cdef PyObject* attr = instance_getattr(cls, name)

AttributeError: 'MPolynomialRing_polydict_domain_with_category' object has no attribute '_PolynomialRing_singular_repr__singular'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/rings/fraction_field_element.pyx in sage.rings.fraction_field_element.FractionFieldElement.reduce (build/cythonized/sage/rings/fraction_field_element.c:3823)()
    198             if not g.is_unit():
--> 199                 self.__numerator //= g
    200                 self.__denominator //= g

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__floordiv__ (build/cythonized/sage/structure/element.c:13680)()
   1836         if HAVE_SAME_PARENT(cl):
-> 1837             return (<Element>left)._floordiv_(right)
   1838         if BOTH_ARE_ELEMENT(cl):

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/structure/element.pyx in sage.structure.element.Element._floordiv_ (build/cythonized/sage/structure/element.c:13940)()
   1873         else:
-> 1874             return python_op(other)
   1875 

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/rings/polynomial/multi_polynomial_element.py in _floordiv_(self, right)
   1616 
-> 1617         Q, _ = self.quo_rem(right)
   1618         return Q

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/structure/element.pyx in sage.structure.element.coerce_binop.new_method (build/cythonized/sage/structure/element.c:28122)()
   4422         if have_same_parent(self, other):
-> 4423             return method(self, other, *args, **kwargs)
   4424         else:

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/rings/qqbar_decorators.py in wrapper(*args, **kwds)
     95                    and isinstance(a.ring().base_ring(), AlgebraicField_common) for a in args):
---> 96             return func(*args, **kwds)
     97 

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/rings/polynomial/multi_polynomial_element.py in quo_rem(self, right)
   1986         try:
-> 1987             R._singular_().set_ring()
   1988         except TypeError:

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/rings/polynomial/polynomial_singular_interface.py in _singular_(self, singular)
    225         except (AttributeError, ValueError):
--> 226             return self._singular_init_(singular)
    227 

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/rings/polynomial/polynomial_singular_interface.py in _singular_init_(self, singular)
    242         if not can_convert_to_singular(self):
--> 243             raise TypeError("no conversion of this ring to a Singular ring defined")
    244 

TypeError: no conversion of this ring to a Singular ring defined

During handling of the above exception, another exception occurred:

ArithmeticError                           Traceback (most recent call last)
<ipython-input-14-8982e4e20a4a> in <module>
----> 1 a.reduce()

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/rings/fraction_field_element.pyx in sage.rings.fraction_field_element.FractionFieldElement.reduce (build/cythonized/sage/rings/fraction_field_element.c:4260)()
    162         return codomain.coerce(nnum/nden)
    163 
--> 164     cpdef reduce(self):
    165         """
    166         Reduce this fraction.

~/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/rings/fraction_field_element.pyx in sage.rings.fraction_field_element.FractionFieldElement.reduce (build/cythonized/sage/rings/fraction_field_element.c:3937)()
    203             raise ArithmeticError("unable to reduce because lack of gcd or quo_rem algorithm")
    204         except TypeError:
--> 205             raise ArithmeticError("unable to reduce because gcd algorithm doesn't work on input")
    206         except NotImplementedError:
    207             raise ArithmeticError("unable to reduce because gcd algorithm not implemented on input")

ArithmeticError: unable to reduce because gcd algorithm doesn't work on input
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-02-15 04:47:11 +0200

Seen: 171 times

Last updated: Feb 15 '22