1 | initial version |

You can see your first polynomial as a polynomial with variable `x`

, whose coefficients belong to the polynomial ring in `u`

with coefficients in the polynomial ring with variables `ai`

:

```
sage: R = PolynomialRing(QQ,'a',17) ; R
Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 over Rational Field
sage: R.inject_variables()
Defining a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16
sage: S = PolynomialRing(R,'u') ; S
Univariate Polynomial Ring in u over Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 over Rational Field
sage: S.inject_variables()
Defining u
sage: T = PolynomialRing(S,'x') ; T
Univariate Polynomial Ring in x over Univariate Polynomial Ring in u over Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 over Rational Field
sage: T.inject_variables()
Defining x
sage: D = (a1*u^3+a2*u^2+a3*u+a4)*x^4+(a5*u^3+a6*u^2+a7*u+a8)*x^3+(a9*u^3+a10*u^2+a11*u+a12)*x^2+(a13*u^3+a14*u^2+a15*u+a16)*x
sage: D
(a1*u^3 + a2*u^2 + a3*u + a4)*x^4 + (a5*u^3 + a6*u^2 + a7*u + a8)*x^3 + (a9*u^3 + a10*u^2 + a11*u + a12)*x^2 + (a13*u^3 + a14*u^2 + a15*u + a16)*x
sage: D.parent()
Univariate Polynomial Ring in x over Univariate Polynomial Ring in u over Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 over Rational Field
```

Now, your second polynomial is a polynomial with variable `u`

whose coefficients belong to the polynomial ring with variable `x`

and with coefficients in the polynomial ring with variables `ai`

:

```
sage: S2 = PolynomialRing(R,'x') ; S2
Univariate Polynomial Ring in x over Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 over Rational Field
sage: T2 = PolynomialRing(S2,'u') ; T2
Univariate Polynomial Ring in u over Univariate Polynomial Ring in x over Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 over Rational Field
```

Unfortunately, Sage seems **NOT** able to do the conversion between those two polynomial rings correctly (and gives a somewhat unexpected result):

```
sage: T2(D)
(a1*x^3 + a2*x^2 + a3*x + a4)*u^4 + (a5*x^3 + a6*x^2 + a7*x + a8)*u^3 + (a9*x^3 + a10*x^2 + a11*x + a12)*u^2 + (a13*x^3 + a14*x^2 + a15*x + a16)*u
sage: T2(D).parent()
Univariate Polynomial Ring in u over Univariate Polynomial Ring in x over Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 over Rational Field
```

But you can use an intermediate polynomial ring from which the conversion is correct:

```
sage: M = PolynomialRing(R,'u,x') ; M
Multivariate Polynomial Ring in u, x over Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 over Rational Field
sage: M(D)
a1*u^3*x^4 + a5*u^3*x^3 + a2*u^2*x^4 + a9*u^3*x^2 + a6*u^2*x^3 + a3*u*x^4 + a13*u^3*x + a10*u^2*x^2 + a7*u*x^3 + a4*x^4 + a14*u^2*x + a11*u*x^2 + a8*x^3 + a15*u*x + a12*x^2 + a16*x
sage: T2(M(D))
(a1*x^4 + a5*x^3 + a9*x^2 + a13*x)*u^3 + (a2*x^4 + a6*x^3 + a10*x^2 + a14*x)*u^2 + (a3*x^4 + a7*x^3 + a11*x^2 + a15*x)*u + a4*x^4 + a8*x^3 + a12*x^2 + a16*x
```

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.