Ask Your Question

Revision history [back]

The problem comes from using a symbolic variable.

This means f and g as defined in your code live in Sage's SymbolicRing.

To work with polynomials, better work in the polynomial ring you define.

Achieve that by defining x as the generator of the polynomial ring R.

from sage.all import *
R = ZZ['x']
x = R.gen()
f = 3*x**2 - 3*x**8
g = x**2 - 1
h = f.mod(x**2 - 1)
print f.quo_rem(g)

Now x is the generator of R and everything works as expected.