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.Thu, 24 Jul 2014 15:15:39 +0200create polynomial from list of coefficientshttps://ask.sagemath.org/question/23561/create-polynomial-from-list-of-coefficients/ Hey,
I created a polynomial ring object:
R.<x,y>=QQbar[]
and now I wonder how should I create a polynomial from a list of coefficients: assume that I have something like `[{x: 5, y: 4}, {x: 2, y: 0}]`. How to transform it to "x^5 y^4 + x^2"?Thu, 24 Jul 2014 13:25:49 +0200https://ask.sagemath.org/question/23561/create-polynomial-from-list-of-coefficients/Answer by FrédéricC for <p>Hey,</p>
<p>I created a polynomial ring object:</p>
<pre><code> R.<x,y>=QQbar[]
</code></pre>
<p>and now I wonder how should I create a polynomial from a list of coefficients: assume that I have something like <code>[{x: 5, y: 4}, {x: 2, y: 0}]</code>. How to transform it to "x^5 y^4 + x^2"?</p>
https://ask.sagemath.org/question/23561/create-polynomial-from-list-of-coefficients/?answer=23563#post-id-23563 Here is a way:
sage: R.<x,y>=QQbar[]
sage: R({(1,1):2})
2*x*y
sage: R({(1,1):2,(3,4):77})
77*x^3*y^4 + 2*x*y
Thu, 24 Jul 2014 13:52:20 +0200https://ask.sagemath.org/question/23561/create-polynomial-from-list-of-coefficients/?answer=23563#post-id-23563Comment by xyzzyz for <p>Here is a way:</p>
<pre><code>sage: R.<x,y>=QQbar[]
sage: R({(1,1):2})
2*x*y
sage: R({(1,1):2,(3,4):77})
77*x^3*y^4 + 2*x*y
</code></pre>
https://ask.sagemath.org/question/23561/create-polynomial-from-list-of-coefficients/?comment=23567#post-id-23567I see, thanks! It would be nice if it was made clear in documentation.Thu, 24 Jul 2014 15:15:39 +0200https://ask.sagemath.org/question/23561/create-polynomial-from-list-of-coefficients/?comment=23567#post-id-23567