Possible bug, weird base field change when working with polynomial rings

83 views
Skip to first unread message

Henry Talbott

unread,
Jun 14, 2019, 2:17:23 PM6/14/19
to sage-devel
The following code produces the weird result:

sage: R.<c>=QQ[]
sage: S.<x,y>=R[]
sage: u=FractionField(S)(x^2+y^2)
sage: v = u.numerator()/u.denominator()
sage: print u.numerator().parent()
sage: print v.numerator().parent()

Output:

Multivariate Polynomial Ring in x, y over Univariate Polynomial Ring in c over Rational Field
Multivariate Polynomial Ring in x, y over Fraction Field of Univariate Polynomial Ring in c over Rational Field

Since u.denominator()=1, I expected v to be equal to u, and certainly for their numerators to be over the same base field. I think the base field change may be an issue with the method inverse_of_unit in rings/polynomial/multi_polynomial_element.py.

Any advice would be greatly appreciated! This base field change was causing an error with the dynatomic_polynomial method.


Travis Scrimshaw

unread,
Jun 15, 2019, 11:32:42 PM6/15/19
to sage-devel
The general rule is that anytime you do division, it pushes itself out to the ring where it makes sense. You can even see this with integers. The reason for this is because checking if something is a unit or is exactly divisible by the denominator is generally expensive.

Best,
Travis

Samuel Lelievre

unread,
Jun 16, 2019, 1:33:16 PM6/16/19
to sage-devel
Workaround: use // instead of / to do division without remainder in the ring.

```
sage: R.<c> = QQ[]
sage: S.<x, y> = R[]
sage: u = FractionField(S)(x^2 + y^2)
sage: v = u.numerator()//u.denominator()
sage: print(u.numerator().parent())
Multivariate Polynomial Ring in x, y over Univariate Polynomial Ring in c over Rational Field
sage: print(v.numerator().parent())
```

Henry Talbott

unread,
Jun 16, 2019, 6:15:52 PM6/16/19
to sage-devel
Ok, thank you!

Ben Hutz

unread,
Jun 17, 2019, 12:41:30 PM6/17/19
to sage-devel
Actually, I think the issue here is that there isn't actually a division happening, rather, it *is* doing the unit check and inverse of unit calculation within numerator(); but still moves to the fractionfield. When numerator(), on the fractionfield element is called, eventually the function inverse_of_unit() is getting called and that is causing the base ring to change to the fraction field of the base ring. It seems like the whole point of calculating the inverse of a unit in a ring would be to stay within the ring.
Reply all
Reply to author
Forward
0 new messages