# How sage checks the irreducibility of a polynomial?

Hi, given a polynomial we can check whether its irreducibility via .is_irreducible() command. I wonder how sage checks it so fast even though the polynomial has large degree with large coefficients?

edit retag close merge delete

Polynomial in one variable? Over which ring?

( 2019-09-18 11:02:51 +0200 )edit

A univariate polynomial over the integers

( 2019-09-18 13:59:54 +0200 )edit

In this case, a mixture between ntl and pari is used as i explained.

( 2019-09-18 22:36:05 +0200 )edit

Sort by » oldest newest most voted

When such computation is fast, it depends on some optimized library (note that Sage can be seen as a bundle of optimized libraries behind a uniform Python interface), and that one depends on the type of polynomials. If you do:

sage: R.<x> = QQ[]
sage: P = R.random_element()
sage: P.is_irreducible??


You will see that flint is used.

If you do the same by replacing QQ with GF(2), you will see that the gf2x library is used but for GF(p) with p>2, the nmod_poly_is_irreducible function is used and that one relies on flint as well. If you have polynomials over ZZ, then you will see that the factor method is used, and there you will see that pari is used when the degree of the polyomial is between 30 and 300, and ntl is used otherwise, and so on.

So, you have to see the source of the corresponding upstream program to see which algorithm and optimizations they are using.

more

When I replace QQ with GF(p) I am getting "Object P.is_irreducible not found." error. What is the problem?

( 2019-09-18 21:41:20 +0200 )edit

sage: R.<x> = GF(5)[]
sage: P = R.random_element()
sage: P.is_irreducible()
False

( 2019-09-18 22:35:24 +0200 )edit

I think I forgot to add " [] " because it works now, my bad.

( 2019-09-19 09:20:36 +0200 )edit

ok, no pb.

( 2019-09-26 00:29:01 +0200 )edit