Ask Your Question

# Revision history [back]

lcm seems to work correctly on RR and QQ:

sage: R.<s> = PolynomialRing(RR); R
Univariate Polynomial Ring in s over Real Field with 53 bits of precision
sage: lcm([(s+5)**2, s])
s^3 + 10.0000000000000*s^2 + 25.0000000000000*s

sage: R.<s> = PolynomialRing(QQ); R
Univariate Polynomial Ring in s over Rational Field
sage: lcm([(s+5)**2, s])
s^3 + 10*s^2 + 25*s


But gcd works on RDF but not on RR:

sage: R.<s> = PolynomialRing(RDF); R
Univariate Polynomial Ring in s over Real Double Field
sage: gcd([(s+5)**2, s])
1.0

sage: R.<s> = PolynomialRing(RR); R
Univariate Polynomial Ring in s over Real Field with 53 bits of precision
sage: gcd([(s+5)**2, s])
TypeError: 'MinusInfinity' object cannot be interpreted as an index


This looks weird. If your polynomials have rational (or integers) coefficients, you can use QQ instead of RDF.

lcm seems to work correctly on RR and QQ:

sage: R.<s> = PolynomialRing(RR); R
Univariate Polynomial Ring in s over Real Field with 53 bits of precision
sage: lcm([(s+5)**2, s])
s^3 + 10.0000000000000*s^2 + 25.0000000000000*s

sage: R.<s> = PolynomialRing(QQ); R
Univariate Polynomial Ring in s over Rational Field
sage: lcm([(s+5)**2, s])
s^3 + 10*s^2 + 25*s


But gcd works on RDF but not on RR:

sage: R.<s> = PolynomialRing(RDF); R
Univariate Polynomial Ring in s over Real Double Field
sage: gcd([(s+5)**2, s])
1.0

sage: R.<s> = PolynomialRing(RR); R
Univariate Polynomial Ring in s over Real Field with 53 bits of precision
sage: gcd([(s+5)**2, s])
TypeError: 'MinusInfinity' object cannot be interpreted as an index


But:

sage: ((s+5)**2).gcd(s)
1.00000000000000


This looks weird. If your polynomials have rational (or integers) coefficients, you can use QQ instead of RDF.