ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 27 Dec 2020 20:52:44 +0100Translating a list of polynomials using sagehttps://ask.sagemath.org/question/54958/translating-a-list-of-polynomials-using-sage/I have a list of polynomials in Sage as follows:
n=5
W=[P.coxeter_polynomial() for P in posets(n)]
Now I want to have the list of all such polynomials as polynomials in `R.<x> = PolynomialRing(ComplexField(100))` .
My question is:
Is there an easy way to translate the above list W so that Sage views every polynomial in that list as a polynomial in `R.<x> = PolynomialRing(ComplexField(100))`?Sun, 27 Dec 2020 19:11:04 +0100https://ask.sagemath.org/question/54958/translating-a-list-of-polynomials-using-sage/Comment by FrédéricC for <p>I have a list of polynomials in Sage as follows:</p>
<pre><code>n=5
W=[P.coxeter_polynomial() for P in posets(n)]
</code></pre>
<p>Now I want to have the list of all such polynomials as polynomials in <code>R.<x> = PolynomialRing(ComplexField(100))</code> .</p>
<p>My question is:
Is there an easy way to translate the above list W so that Sage views every polynomial in that list as a polynomial in <code>R.<x> = PolynomialRing(ComplexField(100))</code>?</p>
https://ask.sagemath.org/question/54958/translating-a-list-of-polynomials-using-sage/?comment=54963#post-id-54963Side remark : `sage: P.is_cyclotomic_product()` is useful to recognize polynomials with all their roots on the unit circle.Sun, 27 Dec 2020 20:52:44 +0100https://ask.sagemath.org/question/54958/translating-a-list-of-polynomials-using-sage/?comment=54963#post-id-54963Answer by Juanjo for <p>I have a list of polynomials in Sage as follows:</p>
<pre><code>n=5
W=[P.coxeter_polynomial() for P in posets(n)]
</code></pre>
<p>Now I want to have the list of all such polynomials as polynomials in <code>R.<x> = PolynomialRing(ComplexField(100))</code> .</p>
<p>My question is:
Is there an easy way to translate the above list W so that Sage views every polynomial in that list as a polynomial in <code>R.<x> = PolynomialRing(ComplexField(100))</code>?</p>
https://ask.sagemath.org/question/54958/translating-a-list-of-polynomials-using-sage/?answer=54961#post-id-54961Yes, there is.
This can be done either as post-treatment after you
have already built the list of polynomials,
or at the time of building the list.
If you already have the list `W` defined as in the question, you can write:
C = ComplexField(100)
W = [w.change_ring(C) for w in W]
Or you could regenerate the list to directly get polynomials in the desired ring:
n = 5
C = ComplexField(100)
W = [P.coxeter_polynomial().change_ring(C) for P in posets(n)]
or
n = 5
R.<x> = PolynomialRing(ComplexField(100))
W = [R(P.coxeter_polynomial()) for P in posets(n)]Sun, 27 Dec 2020 20:44:17 +0100https://ask.sagemath.org/question/54958/translating-a-list-of-polynomials-using-sage/?answer=54961#post-id-54961