Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The problem is change_ring(). You must give the new ring of the coefficients instead of the new ring of f. The code below works.

def roots(f, q): # return list of roots of f in finite field of q elements K = GF(q) r = [ ] g = f.change_ring(K) for a in K: if g(a) == 0: r.append(a) return r

"""EXAMPLE R.<x>=QQ['x'] roots(2*x+1,7) """