1 | initial version |

Define `R2`

as a multivariate polynomial ring in 1 variable:

```
sage: R2.<z> = PolynomialRing(QQ, 1)
sage: Q = z + 5
sage: for c,t in Q: print c,t
1 z
5 1
```

This ring (and its elements) will have different methods than the ordinary univariate ring (elements).

Alternatively: keep your original ring, define `R3 = PolynomialRing(QQ, 1, name='z')`

and use `R3(Q)`

.

2 | No.2 Revision |

Define `R2`

as a multivariate polynomial ring in 1 variable:

```
sage: R2.<z> = PolynomialRing(QQ, 1)
sage: Q = z + 5
sage: for c,t in Q: print c,t
1 z
5 1
```

This ring (and its elements) will have different methods than the ordinary univariate ring (elements).

Alternatively: keep your original ring, define `R3 = PolynomialRing(QQ, 1, name='z')`

and use `R3(Q)`

.

An answer to the new question:

```
def to_multivariate_poly(expr, base_ring):
vars = expr.variables()
if len(vars) == 0:
vars = ['x']
R = PolynomialRing(base_ring, len(vars), names=vars)
return R(expr)
```

Then you can do:

```
sage: x,y,z = var('x,y,z')
sage: P = to_multivariate_poly(x + 2*y + x*y + 3, QQ)
sage: for c,t in P: print c,t
1 x*y
1 x
2 y
3 1
sage: Q = to_multivariate_poly(z + 5, QQ)
sage: for c,t in Q: print c,t
1 z
5 1
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.