1 | initial version |
Ther is not coercion (see the doc) defined between the two polynomial rings, so you have to construct a common parent by yourself and convert the polynomials. Here is a possible way:
First, you can get the names of the variables of both polynomial rings as follows:
sage: R_1.variable_names() + R_2.variable_names()
('z1', 'z2', 'x1', 'x2')
Then you can construct the polynomial ring with this new list of variable names:
sage: R = PolynomialRing(K, R_1.variable_names() + R_2.variable_names())
sage: R
Multivariate Polynomial Ring in z1, z2, x1, x2 over Finite Field in a of size 2^2
Then, you can convert a polynomial from R_1
to R
:
sage: pp
(a)*z1^2 + (a)*z2^2 + z1 + z2
sage: pp.parent()
Multivariate Polynomial Ring in z1, z2 over Finite Field in a of size 2^2
sage: R(pp)
(a)*z1^2 + (a)*z2^2 + z1 + z2
sage: R(pp).parent()
Multivariate Polynomial Ring in z1, z2, x1, x2 over Finite Field in a of size 2^2
Now, you can add the converted polynomials within the new larger parent:
sage: R(pp) + R(qq)
(a)*z1^2 + (a)*z2^2 + (a)*x1^2 + x1*x2 + (a + 1)*x2^2 + z1 + z2 + 1
sage: rr = R(pp) + R(qq)
sage: rr
(a)*z1^2 + (a)*z2^2 + (a)*x1^2 + x1*x2 + (a + 1)*x2^2 + z1 + z2 + 1
sage: rr.parent()
Multivariate Polynomial Ring in z1, z2, x1, x2 over Finite Field in a of size 2^2