Ask Your Question

Revision history [back]

From your data, you can get the list of indeterminates and make a new polynomial ring from them:

sage: R = PolynomialRing(QQ, P.gens()+S.gens())
sage: R(poly)
c0*t0
sage: R(poly).parent()
Multivariate Polynomial Ring in c0, c1, c2, c3, c4, c5, t0, t1, t2, t3, t4, t5 over Rational Field

If you want to only use S, you can replace P.gens() with S.base_ring().gens()

From your data, you can get the list of indeterminates and make a new polynomial ring from them:

sage: R = PolynomialRing(QQ, P.gens()+S.gens())
sage: R(poly)
c0*t0
sage: R(poly).parent()
Multivariate Polynomial Ring in c0, c1, c2, c3, c4, c5, t0, t1, t2, t3, t4, t5 over Rational Field

If you want to only use S, you can replace recover P.gens()P with from S.base_ring().gens()S.base_ring(), and get the desired flattening:

sage: PolynomialRing(QQ, S.base_ring().gens()+S.gens())
Multivariate Polynomial Ring in c0, c1, c2, c3, c4, c5, t0, t1, t2, t3, t4, t5 over Rational Field

From your data, you can get the list of indeterminates and make a new polynomial ring from them:

sage: R = PolynomialRing(QQ, P.gens()+S.gens())
sage: R(poly)
c0*t0
sage: R(poly).parent()
Multivariate Polynomial Ring in c0, c1, c2, c3, c4, c5, t0, t1, t2, t3, t4, t5 over Rational Field

If you want to only use S, you can recover P from S.base_ring(), and get the desired flattening:

sage: PolynomialRing(QQ, S.base_ring().gens()+S.gens())
Multivariate Polynomial Ring in c0, c1, c2, c3, c4, c5, t0, t1, t2, t3, t4, t5 over Rational Field

If you want to directly build a polynomial ring from a list of strings with two prefixes, you can also do:

sage: PolynomialRing(QQ,["c{}".format(i) for i in range(6)]+["t{}".format(i) for i in range(6)])
Multivariate Polynomial Ring in c0, c1, c2, c3, c4, c5, t0, t1, t2, t3, t4, t5 over Rational Field