How should polynomials be defined in a given polynomial ring?
Using SageMath 10.5, if I enter
R.<x,y>=PolynomialRing(QQ); f(x,y)=x+y; f in R
I would expect "f in R" to return either True or False. Instead it gives me a runtime error (message copied below). Is there a fix or workaround for this?
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-3-b05dc0c8ff91> in <module>
----> 1 f in R
/usr/lib/python3/dist-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__contains__ (build/cythonized/sage/structure/parent.c:10491)()
1162 try:
1163 x2 = self(x)
-> 1164 EQ = (x2 == x)
1165 if EQ is True:
1166 return True
/usr/lib/python3/dist-packages/sage/structure/element.pyx in sage.structure.element.Element.__richcmp__ (build/cythonized/sage/structure/element.c:10491)()
1110 return (<Element>self)._richcmp_(other, op)
1111 else:
-> 1112 return coercion_model.richcmp(self, other, op)
1113
1114 cpdef _richcmp_(left, right, int op):
/usr/lib/python3/dist-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.richcmp (build/cythonized/sage/structure/coerce.c:20582)()
1971 # Coerce to a common parent
1972 try:
-> 1973 x, y = self.canonical_coercion(x, y)
1974 except (TypeError, NotImplementedError):
1975 pass
/usr/lib/python3/dist-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.canonical_coercion (build/cythonized/sage/structure/coerce.c:12602)()
1330 if x_elt._parent is y_elt._parent:
1331 return x_elt,y_elt
-> 1332 self._coercion_error(x, x_map, x_elt, y, y_map, y_elt)
1333
1334 cdef bint x_numeric = isinstance(x, (int, long, float, complex))
/usr/lib/python3/dist-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel._coercion_error (build/cythonized/sage/structure/coerce.c:21337)()
2029 <class 'str'> 'g'
2030 """
-> 2031 raise RuntimeError("""There is a bug in the coercion code in Sage.
2032 Both x (=%r) and y (=%r) are supposed to have identical parents but they don't.
2033 In fact, x has parent '%s'
RuntimeError: There is a bug in the coercion code in Sage.
Both x (=x + y) and y (=(x, y) |--> x + y) are supposed to have identical parents but they don't.
In fact, x has parent 'Symbolic Ring'
whereas y has parent 'Callable function ring with arguments (x, y)'
Original elements x + y (parent Multivariate Polynomial Ring in x, y over Rational Field) and (x, y) |--> x + y (parent Callable function ring with arguments (x, y)) and maps
<class 'sage.structure.coerce_maps.DefaultConvertMap_unique'> (map internal to coercion system -- copy before use)
Coercion map:
From: Multivariate Polynomial Ring in x, y over Rational Field
To: Callable function ring with arguments (x, y)
<class 'NoneType'> None