Ask Your Question
1

lcm and gcd of polynomials over the irrationals

asked 2013-11-26 06:10:45 +0100

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-11-26 06:41:35 +0100

tmonteil gravatar image

updated 2013-11-26 06:44:24 +0100

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.

edit flag offensive delete link more

Comments

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

gundamlh gravatar imagegundamlh ( 2013-11-26 07:20:29 +0100 )edit

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

tmonteil gravatar imagetmonteil ( 2013-11-26 07:31:05 +0100 )edit

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

gundamlh gravatar imagegundamlh ( 2013-11-26 08:18:04 +0100 )edit

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: 2013-11-26 06:10:45 +0100

Seen: 1,776 times

Last updated: Nov 26 '13