# RuntimeError: Use ** for exponentiation, not '^', which means xor in Python, and has the wrong precedence.

when running this code

x = PolynomialRing(ZZ.quo(N*ZZ), 'x').gen()
e = 3
f = (u1*x + u1*u1)^e - c1
g = (u2*x + u2*u2)^e - c2


I get the error: RuntimeError: Use ** for exponentiation, not '^', which means xor in Python, and has the wrong precedence.

edit retag close merge delete

Sort by ยป oldest newest most voted

As the error message says, python uses the double star for exponentiation, as in 2**3 = 8. Sage mostly hides this from the user, but you seem to have something executing in python that is not pre-parsed by Sage.

When I try to copy/paste your code, I get errors that N, u1, u2, c1, c2 are not defined. What values are you using for those? When I tried giving those some integer values, your code ran without error.

sage: N = 11
sage: u1 = 3
sage: u2 = 7
sage: c1 = 1
sage: c2 = -1
sage: x = PolynomialRing(ZZ.quo(N*ZZ), 'x').gen()
sage: e = 3
sage: f = (u1*x + u1*u1)^e - c1
sage: g = (u2*x + u2*u2)^e - c2
sage: f*g
10*x^6 + 3*x^5 + 9*x^3 + 3*x^2 + 9*x + 10

more
more