1 | initial version |
In your example, having defined
sage: R1.<a,b,c,t> = PolynomialRing(QQ)
sage: L = (a*t^2+b*t+c).subs(a=2,b=3,c=4)
we get
sage: L
2*t^2 + 3*t + 4
(did you mean L = a*t^2+b*t+c
without substituting values for a
, b
, c
?)
Having then defined
sage: R2.<A,B,C,D,t> = PolynomialRing(QQ)
sage: p = (A*t+B)^2+(C*t+D)^2
you can convert polynomials from one ring to the other
sage: R2(L)
2*D^2 + 3*D + 4
Here, the order of the variables matters, more than their names:
t
, the fourth variable in R1
, is mapped to D
, the fourth variable in R2
.
If you want a
, b
,c
, t
to be mapped to A
, B
, C
, t
, you might
want to include an extra variable d
in R1
and not use it.
Or you could compare string representations of your polynomials, applying
string replacements as necessary. Or you could use p.monomials()
and p.coefficients()
.
You could also define a ring homomorphism from R1
to R2
mapping the variables to the variables of your choice, see the reference manual.