Ask Your Question

Revision history [back]

The result of expr.polynomial(RR) is a polynomial ring element. Dividing two such polynomials gives an element of the fraction field of the polynomial ring (whose elements are called rational functions). You can do e.g.

sage: expr = (pi + e*x)/(e + pi*x)
sage: expr.numerator().polynomial(RR) / expr.denominator().polynomial(RR)
(2.71828182845905*x + 3.14159265358979)/(3.14159265358979*x + 2.71828182845905)

You could wrap that into a function, or construct the fraction field by hand so you can use conversion:

sage: K = FractionField(PolynomialRing(RR, 'x'))
sage: K(expr)
(2.71828182845905*x + 3.14159265358979)/(3.14159265358979*x + 2.71828182845905)

The result of expr.polynomial(RR) is a polynomial ring element. Dividing two such polynomials gives an element of the fraction field of the polynomial ring (whose elements (which are called rational functions). You can do e.g.

sage: expr = (pi + e*x)/(e + pi*x)
sage: expr.numerator().polynomial(RR) / expr.denominator().polynomial(RR)
(2.71828182845905*x + 3.14159265358979)/(3.14159265358979*x + 2.71828182845905)

You could wrap that into a function, or Better yet, you can construct the fraction field by hand yourself so you can use conversion:

sage: K = FractionField(PolynomialRing(RR, 'x'))
sage: K(expr)
(2.71828182845905*x + 3.14159265358979)/(3.14159265358979*x + 2.71828182845905)