Ask Your Question

# Finding irreducible polynomials in Sage Math

I'm new to Sage and I'm asked to find out all the monic polynomials (of the form x^m+q) that are irreducible in the finite field $\mathbb{Z}/p\mathbb{Z}$. My idea is to vary q from 0 to p-1 and m from 1 to n, where n is the highest order of polynomials given by the user, and I want to create a function that works for all integer fields. However, my codes don't work and Sage tells me

positive characteristic not allowed in symbolic computations What does this mean?

def irr(p,n):
R.<x>=PolynomialRing(Integers(p),'x')
for m in range(n+1):
for q in Integers(p):
R(f)=x^m+q
if R(f).is_irreducible():
return R(f)

edit retag close merge delete

## Comments

By "of the form $x^m + q$" do you mean

• of the form $x^m + q$ where $q$ is an element in $\mathbb{Z} / p \mathbb{Z}$ or
• of the form $x^m + q$ where $q$ is a polynomial over $\mathbb{Z} / p \mathbb{Z}$ of degree less than $m$?
( 2021-01-27 13:24:30 +0100 )edit

## 1 Answer

Sort by » oldest newest most voted

R(f)=x^m+q is trying to build a symbolic function named R with argument f. Just f = x^m+q would work

more

## Comments

Okay, I changed R(f) to f, but now Sage always returns x. I want to find all the irreducible polynomials under a certain degree. How can I do this?

( 2020-11-04 14:42:30 +0100 )edit

create a list, append to the list, and return the list at the end

( 2020-11-04 15:43:10 +0100 )edit

## Your Answer

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

Add Answer

## Stats

Asked: 2020-10-29 08:35:03 +0100

Seen: 912 times

Last updated: Oct 31 '20