Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Apply modulus to polynomial coefficients

I want to apply mod operator to a polynomial and get the expanded result. For example

$$ (x+1)^4 \bmod 6 $$ should give $$ x^4 + 4 x^3 + 4 x + 1 $$

What I've tried:

sage: ZP.<x> = ZZ[]
sage: ( (x+1)^4 ).factor_mod(6)
ValueError: p must be prime

sage: Mod( (x+1)^4 , 6)
TypeError: not a constant polynomial

and

a,b,c=var('a,b,c')
sage: ((a+b+c)^3).expand()
a^3 + 3*a^2*b + 3*a*b^2 + b^3 + 3*a^2*c + 6*a*b*c + 3*b^2*c + 3*a*c^2 + 3*b*c^2 + c^3
sage: (a+b+c)^3 % 3
TypeError: unsupported operand parent(s) for %: 'Symbolic Ring' and 'Symbolic Ring'