I recently reviewed cases in the sympy polys code that handle the
degree of a zero polynomial:
https://github.com/sympy/sympy/pull/25784

My conclusion is that it is sometimes useful that deg(0) < deg(p) for
p != 0 but otherwise it is not really possible to use the value of
deg(0) for anything meaningful in practice. Generally if deg(p) is
needed then the zero polynomial needs special handling that no
particular value of deg(0) helps with. I would prefer that deg(0) = -1
just so that the deg() function has a well defined type.

For Laurent polynomials I am not sure that I would define a degree()
method or if I did that it would be defined as the exponent of the
leading term. It isn't clear to me when that notion of degree would be
useful: it doesn't seem like it would generalise the ways that degree
is  typically used for ordinary polynomials.

On Thu, 29 Feb 2024 at 10:57, Giacomo Pope <giacomop...@gmail.com> wrote:
>
> There seem to be two things we could do here:
>
> 1. Have some form of vote / discussion on whether the degree of the zero 
> polynomial should *ever* be -1
> 2. Modify the degree calls for the LaurentSeries and LaurentPolynomialRing 
> (maybe other Laurent* which I am unfamiliar with) to have the zero polynomial 
> have degree -Infinity.
>
> Option 1 may be cleaner in the long run, but I assume will cause issues for 
> more people in the short term. Option 2 seems fairly harmless and there's no 
> good argument for degree -1 in this case.
>
> If anyone is interested in option 2, I will find time to make a PR to do 
> this, but I will not start this work without other people's input as this is 
> not code I am familiar with using and so I don't know what people could be 
> relying on.
> On Wednesday, February 28, 2024 at 6:41:48 PM UTC Dima Pasechnik wrote:
>>
>> On Wed, Feb 28, 2024 at 5:00 PM Nils Bruin <nbr...@sfu.ca> wrote:
>>>
>>> On Wednesday 28 February 2024 at 08:03:45 UTC-8 Giacomo Pope wrote:
>>>
>>>
>>> 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?
>>>
>>>
>>> I think it's more than just a CS workaround. It has its roots in dimension 
>>> considerations: the space of polynomials of degree at most d is 
>>> (d+1)-dimensional. WIth that convention, 0 having degree -1 makes perfect 
>>> sense.
>>
>>
>> well, it's the convention used in Singular.
>> But GAP and Macaulay2 use -infinity.
>>
>> The arguments for -infinity:
>>
>> 1) degree of the product should be the sum of degrees; so it's got to be 
>> infinite.
>> 2) it should be -infinity, to make sense of the rule that if you do division 
>> f/g with remainder r,
>> the degree of the remainder should be less than the deg(r)<=deg(f), but if 
>> r=0 then the only way
>> to get this is to use -infinity.
>>
>> Dima
>>
>>>
>>>
>>> For deg = - ord_infty it should definitely be -oo, though, and for Laurent 
>>> polynomials the dimension argument doesn't work.
>>>
>>> --
>>>
>>> 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/ac40d2e7-5e71-43e1-8914-869081f9bdd9n%40googlegroups.com.
>
> --
> 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/6d95b253-fb17-4e2f-a61c-c723737774e8n%40googlegroups.com.

-- 
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/CAHVvXxRe119u%3Dy-xk1O-BvWH_f1xxnHsuQCzZm_4xYRD-_NEFw%40mail.gmail.com.

Reply via email to