gcd on polynomials over ZZ [closed]

asked 2021-10-29 23:45:23 +0100

Max Alekseyev gravatar image

updated 2021-10-29 23:47:50 +0100

In Sage 9.4, in the following code:

P.<x> = QQ[]
pol = 2*x^2 + 4*x + 6
print( gcd(pol) )
print( gcd(pol.change_ring(ZZ)) )

The first gcd works fine, while the second gcd results in

TypeError: object of type 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint' has no len()

There is a workaround by using gcd(pol.coefficients()), but I wonder if above error is a bug.

PS. This gcd is essentially what is called the content of a polynomial. Surprisingly, .content() is defined for multivariate polynomials but not for univariate ones.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Max Alekseyev
close date 2023-05-07 17:44:44.158436

Comments

1

This smells of an implementation oversight which, IMHO, should be filed as a bug...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-10-30 10:53:15 +0100 )edit
1

It works for me on 9.5.beta4:

sage: P.<x> = QQ[]
....: pol = 2*x^2 + 4*x + 6
....: print( gcd(pol) )
....: print( gcd(pol.change_ring(ZZ)) )
2
2
tmonteil gravatar imagetmonteil ( 2021-10-30 12:12:16 +0100 )edit

That is good to know. Does 9.5 have .content() defined for univariate polynomials by any chance?

Max Alekseyev gravatar imageMax Alekseyev ( 2021-10-31 03:17:27 +0100 )edit