# Revision history [back]

Since the whole expression is a polynomial with rational coefficients, the following works:

sage: R = PolynomialRing(PolynomialRing(QQ, names='E_mu, E_xi3, ISP, T, V_mu, V_xi3, Z, m, n_I, n_P, xi_1'), names='mu, xi_3')
sage: map(SR, R(AN).monomials())
[mu^2, mu*xi_3, mu, xi_3, 1]
sage: map(SR, R(AN).coefficients())
[T^2*m^6 + 4*T^2*m^5*n_I + 4*T^2*m^4*n_I^2 + 2*T^2*m^5*n_P + 6*T^2*m^4*n_I*n_P + 4*T^2*m^3*n_I^2*n_P + T^2*m^4*n_P^2 + 2*T^2*m^3*n_I*n_P^2 + T^2*m^2*n_I^2*n_P^2 + 2*T*V_mu*m^4*n_I + 2*T*V_xi3*m^4*n_I + 4*T*V_mu*m^3*n_I^2 + 4*T*V_xi3*m^3*n_I^2 + ...

For expressions involving fractions you would want to replace the inner PolynomialRing by wrapping it in FractionField(...).

Since the whole expression is a polynomial with rational coefficients, the following works:

sage: R = PolynomialRing(PolynomialRing(QQ, names='E_mu, E_xi3, ISP, T, V_mu, V_xi3, Z, m, n_I, n_P, xi_1'), names='mu, xi_3')
sage: map(SR, R(AN).monomials())
[mu^2, mu*xi_3, mu, xi_3, 1]
sage: map(SR, R(AN).coefficients())
[T^2*m^6 + 4*T^2*m^5*n_I + 4*T^2*m^4*n_I^2 + 2*T^2*m^5*n_P + 6*T^2*m^4*n_I*n_P + 4*T^2*m^3*n_I^2*n_P + T^2*m^4*n_P^2 + 2*T^2*m^3*n_I*n_P^2 + T^2*m^2*n_I^2*n_P^2 + 2*T*V_mu*m^4*n_I + 2*T*V_xi3*m^4*n_I + 4*T*V_mu*m^3*n_I^2 + 4*T*V_xi3*m^3*n_I^2 + ...

For expressions involving fractions you would want to replace the inner PolynomialRing by wrapping it in FractionField(...)., like this:

sage: R = PolynomialRing(FractionField(PolynomialRing(QQ, names='E_mu, E_xi3, ISP, T, V_mu, V_xi3, Z, m, n_I, n_P, xi_1')), names='mu, xi_3')