Revision history [back]

There are several ways to go depending whether the result should be a polynomial with coefficients in $\mathbb{Z}$ or a polynomial with coefficients in $\mathbb{Z}/6\mathbb{Z}$.

Here is an illustration for both options.

Define a polynomial ring and a polynomial:

sage: ZP.<x> = ZZ[]
sage: p = (x+1)^4
sage: p
x^4 + 4*x^3 + 6*x^2 + 4*x + 1
sage: p.parent()
Univariate Polynomial Ring in x over Integer Ring


Mod out by 6, keeping coefficients in the integers:

sage: q = p % 6
sage: q
x^4 + 4*x^3 + 4*x + 1
sage: q.parent()
Univariate Polynomial Ring in x over Integer Ring


Move to coefficients in modular integers:

sage: r = p.change_ring(Zmod(6))
sage: r
x^4 + 4*x^3 + 4*x + 1
sage: r.parent()
Univariate Polynomial Ring in x over Ring of integers modulo 6


There are several ways to go depending whether the result should be a polynomial with coefficients in $\mathbb{Z}$ or a polynomial with coefficients in $\mathbb{Z}/6\mathbb{Z}$.

Here is an illustration for both options.

Define a polynomial ring and a polynomial:

sage: ZP.<x> = ZZ[]
sage: p = (x+1)^4
sage: p
x^4 + 4*x^3 + 6*x^2 + 4*x + 1
sage: p.parent()
Univariate Polynomial Ring in x over Integer Ring


Mod out by 6, keeping coefficients in the integers:

sage: q = p % 6
sage: q
x^4 + 4*x^3 + 4*x + 1
sage: q.parent()
Univariate Polynomial Ring in x over Integer Ring


Move to coefficients in modular integers:

sage: r = p.change_ring(Zmod(6))
sage: r
x^4 + 4*x^3 + 4*x + 1
sage: r.parent()
Univariate Polynomial Ring in x over Ring of integers modulo 6


The difference is apparent when you keep working with the modded out polynomial. Compare:

sage: 3 * q
3*x^4 + 12*x^3 + 12*x + 3

sage: 3 * r
3*x^4 + 3