Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Conversion fraction field(QQ[X]) to fraction field(ZZ[X])

How to I convert an element of the fraction field of QQ[X] to the fraction field of ZZ[X]?

sage: R.<x> = ZZ[]
sage: F = R.fraction_field()
sage: e = (1/2)/(x+1)
sage: e.parent()
Fraction Field of Univariate Polynomial Ring in x over Rational Field
sage: F(e)
Traceback (most recent call last):
...
TypeError: no conversion of this rational to integer

In my use case, e is the result of a lengthy computation where at some point beyond my control the result was coerced into QQ[X]. In my particular case, I prefer the fraction field of ZZ[X] because the output is nicer.