Reduce multivariate polynomial coefficients to 1
I'm new to Python and SAGE and would like to ask a question: I have a multivariate polynomial, of a degree 3, i.e:
g.<x1,x2,x3>=x1^2 + 2x1x2 + x2^2 + 2x1x3 + 2x2x3 + x3^2 + 2x1 + 2x2 + 2*x3 + 1 Its type is <type 'sage.rings.polynomial.multi_polynomial_libsingular.mpolynomial_libsingu\="" lar'="">
The question is how can I reduce all its leading coefficients to 1, i.e. transform ig to:
g.<x1,x2,x3>=x1^2 + x1x2 + x2^2 + x1x3 + x2x3 + x3^2 + *x1 + *x2 + *x3 + 1
I tried to get the coefficients of the polynomial (which is a list), iterate through its items, and set the values of the items to 1, i.e.
for s in g.coefficients(): if s==2: s=1
I think that the problem is that list items can't be cast to integer (TypeError).
How could I solve this? Is there a more efficient way to do this? Thank you for your responses! Regards, Natassa