# Revision history [back]

To fix this, a needs to be defined as the generator of M.

The code in the question only sets a as the display value for this generator.

So, do one of the following.

M.<a> = PolynomialRing(ZZ)


or

M.<a> = ZZ[]


or

M = PolynomialRing(ZZ, 'a')
a = M.gen()


or

M = PolynomialRing(ZZ, 'a')
M.inject_variables()


To fix this, a needs to be defined as the generator of M.

The code in the question only sets a as the display value for this generator.

So, do one of the following.

M.<a> = PolynomialRing(ZZ)


or

M.<a> = ZZ[]


or

M = PolynomialRing(ZZ, 'a')
a = M.gen()


or

M = PolynomialRing(ZZ, 'a')
M.inject_variables()


Note that there is also a shortcut with [[]] for defining a power series rings.

sage: M.<a> = ZZ[]
sage: M
Univariate Polynomial Ring in a over Integer Ring
sage: R.<x, y> = M[[]]
sage: R
Multivariate Power Series Ring in x, y over Univariate Polynomial Ring in a over Integer Ring
sage: f = a*x + y + x*y + O(x,y)^3
sage: f
a*x + y + x*y + O(x, y)^3