Polynomial comparison

48 views
Skip to first unread message

Rob H.

unread,
Jun 27, 2020, 5:38:09 AM6/27/20
to sage-support


Hi all,

So I was surprised to find out that asking if a polynomial is > 0 doesn't raise an error. Now, maybe there's a good reason why it returns True and I'm too tired to think about why. At the very least, here is some disturbing behaviour.

sage: R.<x> = PolynomialRing(QQ)
sage
: x > x-1
True
sage
: R.<x,y> = PolynomialRing(QQ)
sage
: x > x-1
False
sage
: x+1 > x
True

I'm hoping someone can tell me why this behaviour is correct, or confirm that it's wrong.

Dima Pasechnik

unread,
Jun 27, 2020, 6:40:54 AM6/27/20
to sage-support
On Sat, Jun 27, 2020 at 10:38 AM Rob H. <robert...@gmail.com> wrote:
>
>
>
> Hi all,
>
> So I was surprised to find out that asking if a polynomial is > 0 doesn't raise an error.

many Sage objects compare in a totally non-mathematical way, just to
be able to sort them.
Polynomials are no exception.

One day we might have a way to test global nonnegativity/positivity of
polynomials with coefficients in
an ordered field, but we're far from this now.

> Now, maybe there's a good reason why it returns True and I'm too tired to think about why. At the very least, here is some disturbing behaviour.
>
> sage: R.<x> = PolynomialRing(QQ)
> sage: x > x-1
> True
> sage: R.<x,y> = PolynomialRing(QQ)
> sage: x > x-1
> False
> sage: x+1 > x
> True
>
> I'm hoping someone can tell me why this behaviour is correct, or confirm that it's wrong.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/c7609632-1d79-4298-8daf-cc9682ff6664o%40googlegroups.com.

Rob H.

unread,
Jun 28, 2020, 6:34:36 AM6/28/20
to sage-support
I mean, I know about this, I guess it's just jarring to see it in action (especially when the truth of x > x-1 depends on how many variables your polynomial ring has). I feel like it goes against duck-typing. If I write code that I want to work as long as there's a well-defined notion of positivity, checking if something is > 0 feels like the right duck-typing thing to do. I guess I'll try some other way.


On Saturday, June 27, 2020 at 12:40:54 AM UTC-10, Dima Pasechnik wrote:
On Sat, Jun 27, 2020 at 10:38 AM Rob H. <robert...@gmail.com> wrote:
>
>
>
> Hi all,
>
> So I was surprised to find out that asking if a polynomial is > 0 doesn't raise an error.

many Sage objects compare in a totally non-mathematical way, just to
be able to sort them.
Polynomials are no exception.

One day we might have a way to test global nonnegativity/positivity of
polynomials with coefficients in
an ordered field, but we're far from this now.

> Now, maybe there's a good reason why it returns True and I'm too tired to think about why. At the very least, here is some disturbing behaviour.
>
> sage: R.<x> = PolynomialRing(QQ)
> sage: x > x-1
> True
> sage: R.<x,y> = PolynomialRing(QQ)
> sage: x > x-1
> False
> sage: x+1 > x
> True
>
> I'm hoping someone can tell me why this behaviour is correct, or confirm that it's wrong.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-s...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages