Not a "maths" why, but I know anything which uses singular currently returns -1 because of the following snippet
cdef long singular_polynomial_deg(poly *p, poly *x, ring *r) noexcept: cdef long _deg, deg cdef int dummy deg = -1 _deg = -1 if p == NULL: return -1 ... I don't know the history of this choice or what we should be doing generally. -1 for polynomials with only positive degree seems like a computer science workaround, but for the LaurentPolynomialRing it just seems wrong? On Wednesday, February 28, 2024 at 3:29:25 PM UTC Dima Pasechnik wrote: > in the polynomial case, the usual convention is deg(0)=-infinity > I don't know why Sage uses -1 instead: > R.<x,y>=QQ[] > f=0*x*y > f.degree() > > gives -1. > > On Wed, Feb 28, 2024 at 1:50 PM 'Martin R' via sage-devel < > sage-...@googlegroups.com> wrote: > >> Sorry, I confused it with valuation, but I guess it is still a related >> question. >> On Wednesday 28 February 2024 at 14:36:35 UTC+1 Giacomo Pope wrote: >> >>> This is not what I see on the current beta: >>> >>> sage: R.<x> = LaurentSeriesRing(QQ) >>> sage: R.zero().degree() >>> -1 >>> sage: R.<x> = LazyLaurentSeriesRing(QQ) >>> sage: R.zero().degree() >>> >>> --------------------------------------------------------------------------- >>> AttributeError Traceback (most recent call >>> last) >>> Cell In[4], line 1 >>> ----> 1 R.zero().degree() >>> >>> File ~/sage/sage/src/sage/structure/element.pyx:489, in >>> sage.structure.element.Element.__getattr__() >>> 487 AttributeError: >>> 'LeftZeroSemigroup_with_category.element_class' object has no attribute >>> 'blah_blah'... >>> 488 """ >>> --> 489 return self.getattr_from_category(name) >>> 490 >>> 491 cdef getattr_from_category(self, name) noexcept: >>> >>> File ~/sage/sage/src/sage/structure/element.pyx:502, in >>> sage.structure.element.Element.getattr_from_category() >>> 500 else: >>> 501 cls = P._abstract_element_class >>> --> 502 return getattr_from_other_class(self, cls, name) >>> 503 >>> 504 def __dir__(self): >>> >>> File ~/sage/sage/src/sage/cpython/getattr.pyx:357, in >>> sage.cpython.getattr.getattr_from_other_class() >>> 355 dummy_error_message.cls = type(self) >>> 356 dummy_error_message.name = name >>> --> 357 raise AttributeError(dummy_error_message) >>> 358 cdef PyObject* attr = instance_getattr(cls, name) >>> 359 if attr is NULL: >>> >>> AttributeError: 'LazyLaurentSeriesRing_with_category.element_class' >>> object has no attribute 'degree' >>> >>> On Wednesday, February 28, 2024 at 12:05:32 PM UTC Martin R wrote: >>> >>>> LazyLaurentSeriesRing(QQ) currently gives +Infinity. >>>> >>>> On Wednesday 28 February 2024 at 12:50:45 UTC+1 Giacomo Pope wrote: >>>> >>>>> While chasing various bugs which appeared in the CI, I ended up adding >>>>> a small method for computing random elements for the >>>>> LaurentPolynomialRing >>>>> class. >>>>> >>>>> When writing randomised testing I got myself confused about the degree >>>>> of the zero polynomial. For the univariate and multivariate polynomial >>>>> rings, we currently use that the degree for 0 (both R(0).degree() as well >>>>> as R(0).degree(x)) is -1. This is unambiguous for the case of these types. >>>>> >>>>> However for the LaurentPolynomialRings, a polynomial with negative >>>>> valuation is very natural. For example the following code snippet shows >>>>> the >>>>> ambiguity. >>>>> >>>>> sage: L.<x> = LaurentPolynomialRing(QQ) >>>>> sage: f = (1/x); f >>>>> x^-1 >>>>> sage: f.degree() >>>>> -1 >>>>> sage: L.zero().degree() >>>>> -1 >>>>> >>>>> I don't feel familiar enough with the mathematics here and the usual >>>>> use cases in sage to offer a PR "fixing" this, or whether it even needs >>>>> fixing. However, I got confused so I thought maybe others might get >>>>> confused and someone on this list might have a suggestion. >>>>> >>>>> I think the "usual" suggestion would be to have the degree as -infty, >>>>> but then there's a question about whether this should be done for other >>>>> polynomial rings... >>>>> >>>>> I made an issue for this on GitHub too: >>>>> >>>>> https://github.com/sagemath/sage/issues/37491 >>>>> >>>> -- >> You received this message because you are subscribed to the Google Groups >> "sage-devel" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to sage-devel+...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sage-devel/c9c805f9-fbd0-4591-8729-002f3ad90fa1n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/sage-devel/c9c805f9-fbd0-4591-8729-002f3ad90fa1n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/3df08680-f56f-4c11-89a2-00bb3d93d9abn%40googlegroups.com.