Ask Your Question
1

In Sage, how do I check for irreducibility of a polynomial modulo prime.

asked 2022-09-17 07:32:49 +0200

Niladri gravatar image

In particular, I need to check irreducibility of this polynomial, x^8+x^2+1, modulo 3.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-10-06 18:33:04 +0200

dan_fulea gravatar image

This is the same answer as the one of tmonteil, but done when started with a "polynomial expression".

So let us define

var('x');
f = x^8 + x^2 + 1

As declared, f is not a polynomial, an algebraic object, but

sage: f
x^8 + x^2 + 1
sage: type(f)
<class 'sage.symbolic.expression.Expression'>

an expression, so square roots, exponentials, and other non-algebraic operations are allowed. We have to switch to the world of true (sage) polynomials, by building f.polynomial( ... ), and this method asks for a base ring. We pass GF(3) as base ring. So the following does the job:

sage: pol = f.polynomial( GF(3) )
sage: pol.is_irreducible()
False
sage: pol.factor()
(x + 1) * (x + 2) * (x^3 + 2*x + 1) * (x^3 + 2*x + 2)

Note: This works also with an other variable name...

sage: var('y');
sage: f = y^8 + y^2 + 1
sage: pol = f.polynomial( GF(3) )
sage: pol.factor()
(y + 1) * (y + 2) * (y^3 + 2*y + 1) * (y^3 + 2*y + 2)

But note that the y involved in f and the y involved in pol are different objects.

edit flag offensive delete link more
0

answered 2022-09-17 10:17:13 +0200

tmonteil gravatar image

updated 2022-09-17 10:18:00 +0200

The trick is first to define the ring R where your polynomial will live, namely Polynomial Ring in the undeterminate x over the finite field of size 3, $\mathbf{F}_3[x]$:

sage: R.<x> = GF(3)[]

This defines both R and x:

sage: R
Univariate Polynomial Ring in x over Finite Field of size 3

sage: x
x
sage: x.parent()
Univariate Polynomial Ring in x over Finite Field of size 3

Then, you can do:

sage: P = x^8+x^2+1
sage: P.is_irreducible()
False

sage: P.factor()
(x + 1) * (x + 2) * (x^3 + 2*x + 1) * (x^3 + 2*x + 2)
edit flag offensive delete link more

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: 2022-09-17 07:32:49 +0200

Seen: 75 times

Last updated: Oct 06 '22