# Evaluating discriminant of a polynomial in Z_n[x]/<x^r-1>

Consider the following code

Zn=Zmod(n)
R = PolynomialRing(Zn,'x')
F = R.quotient((x**r)-1)
y=F((x+1))
f=F(y**n)


Clearly f will be a polynomial in xbar , I want to consider this polynomial as a polynomial in $\mathbb{Z}[x]$ and evaluate its discriminant.

I tried "f.polynomial()" but it is not working. Any suggestions ?

edit retag close merge delete

Sort by » oldest newest most voted

The method you are looking for is called lift:

sage: g = f.lift()
sage: g
7*x^9 + 9*x^8 + 9*x^7 + 7*x^6 + 8*x^5 + 8*x^4 + 8*x + 8
sage: g.parent()
Univariate Polynomial Ring in x over Ring of integers modulo 14
sage: g.discriminant()
0


As a side comment: I created Zn = Zmod(14). If you want to work in a finite field with p elements, you should better use K = GF(p) than Zn = Zmod(p) since you are telling Sage that K is a field.

EDIT: If you want the polynomial over $\mathbb{Z}$, you can do the following:

sage: h = g.change_ring(ZZ)
sage: h.discriminant()
19634094616613079744512

more

Nice answer. Note that this gives a polynomial over Zn, and its discriminant is computed modulo n.

( 2016-06-22 09:09:58 +0100 )edit

Thanks a lot ! Can you kindly help me with this question also.

( 2016-06-22 09:51:52 +0100 )edit

Your friend here is the list method, which will give you the coefficients of f as a polynomial in xbar.

Then you will be able to take its discriminant.

Let us illustrate this step by step.

To begin with, for reference, here is the Sage version used below.

sage: version()
'SageMath version 7.2, Release Date: 2016-05-15'


Let us set some values for n and r so that the code works and others can try it out.

sage: n = 13
sage: r = 7


Now define Zn, R, F, y, f as you did.

sage: Zn = Zmod(n)
sage: R = PolynomialRing(Zn, 'x')
sage: F = R.quotient(x**r-1)
sage: y = F(x+1)
sage: f = F(y**n)


We get:

sage: f
xbar^6 + 1


Get the coefficients:

sage: f.list()
[1, 0, 0, 0, 0, 0, 1]


Define the ring of polynomials over ZZ:

sage: Zx = PolynomialRing(ZZ, 'x')


The polynomial corresponding to f:

sage: ff = Zx(f.list())
sage: ff
x^6 + 1


The discriminant of this polynomial:

sage: ff.discriminant()
-46656

more