First time here? Check out the FAQ!

Ask Your Question
1

lcm and gcd of polynomials over the irrationals

asked 11 years ago

gundamlh gravatar image

Dear all,

I want to calculate the least common multiple of a list of polynomials with coefficients defined over RR or RDF in SAGE. Is it possible?

sage: R.<s> = PolynomialRing(RDF); R
Univariate Polynomial Ring in s over Real Double Field
sage: H = matrix(1,2, [(s+5)**2, s]); H
[s^2 + 10.0*s + 25.0                   s]
sage: lcm(H[0,0], H[0,1])
TypeError: Singular error:
   ? not implemented
   ? error occurred in or before poly.lib::lcm line 852: `           q=gcd(p,i[k]);`
   ? leaving poly.lib::lcm
   skipping text from `;` error at token `)`

Thanks in advance!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 11 years ago

tmonteil gravatar image

updated 11 years ago

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.

Preview: (hide)
link

Comments

Thanks! But if some coef. is sqrt(2) or pi ...

gundamlh gravatar imagegundamlh ( 11 years ago )

for the gcd, working in the symbolic ring `SR` works, not for the lcm (lack of conversion to the singular lib).

tmonteil gravatar imagetmonteil ( 11 years ago )

OK, perhaps it is not implemented in those cases. Oh, can we call NumPy or Maxima to do it instead?

gundamlh gravatar imagegundamlh ( 11 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 11 years ago

Seen: 1,922 times

Last updated: Nov 26 '13