Is it possible to reset a PolynomialRing variable after you give it a value?

32 views Asked by At
sage: R17.<x> = PolynomialRing(GF(17))
sage: f1 = R17(x + 10)
sage: f1 = x + 10
sage: f1
sage: x + 10

So now f1 is a polynomial.

But I then give a value to x

sage: x = 25

Then I try to define another polynomial f2 in the same way I defined f1

sage: f2 = R17(x + 15)
sage: f2
6

But because I have given a value 25 to x, sage doesn't seem to treat the statement as a polynomial definition.

When I try to evaluate f2 at x = 1, it doesn't do that.

sage: f2(1)
6

I have to redefine the ring before I can get further

sage: R17.<x> = PolynomialRing(GF(17))
sage: f2 = R17(x + 15)
sage: f2
x + 15
sage: f2(1)
16

Is there a simpler way to 'reset' x - i.e. remove the value it's been given, so it's treated as a variable again?

1

There are 1 answers

0
MvG On BEST ANSWER

You should be able to use inject_variables:

sage: R17.inject_variables()

This should reset x to be the generator of the ring. As an alternative you should also be able to use

sage: x = R17.gens()[0]

to explicitly reset the variable x to refer to the first generator of the ring.