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.Fri, 20 Jun 2014 11:55:45 +0200polynomial list, arrayhttps://ask.sagemath.org/question/11065/polynomial-list-array/I would like to store polynomials in an array/list in Sage. How do I do this?
-------
I am editing my question due to the confusion expressed below.
I would like to generate a list of polynomials from a loop. Thu, 19 Jun 2014 22:30:28 +0200https://ask.sagemath.org/question/11065/polynomial-list-array/Comment by niles for <p>I would like to store polynomials in an array/list in Sage. How do I do this?</p>
<hr/>
<p>I am editing my question due to the confusion expressed below.</p>
<p>I would like to generate a list of polynomials from a loop. </p>
https://ask.sagemath.org/question/11065/polynomial-list-array/?comment=16145#post-id-16145please clarify your questionFri, 20 Jun 2014 08:28:18 +0200https://ask.sagemath.org/question/11065/polynomial-list-array/?comment=16145#post-id-16145Comment by Hans for <p>I would like to store polynomials in an array/list in Sage. How do I do this?</p>
<hr/>
<p>I am editing my question due to the confusion expressed below.</p>
<p>I would like to generate a list of polynomials from a loop. </p>
https://ask.sagemath.org/question/11065/polynomial-list-array/?comment=16131#post-id-16131Thanks for the answers posted above. Though not directly resolving my intended question due to the confusing statement of my original post, they made me realize I need to declare the list first, like p = [], just like in Python, then append the polynomials or anything else for that matter, one by one, with say p.append(polynomial).Fri, 20 Jun 2014 11:55:45 +0200https://ask.sagemath.org/question/11065/polynomial-list-array/?comment=16131#post-id-16131Answer by kcrisman for <p>I would like to store polynomials in an array/list in Sage. How do I do this?</p>
<hr/>
<p>I am editing my question due to the confusion expressed below.</p>
<p>I would like to generate a list of polynomials from a loop. </p>
https://ask.sagemath.org/question/11065/polynomial-list-array/?answer=16078#post-id-16078By making a list of polynomials?
sage: R.<t> = QQ[]
sage: L = [t^2+1, t^3+1, t^4+t^2-5]
sage: type(L[2])
<type 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'>
Here I assume you mean real polynomials, and not symbolic expressions that happen to be polynomials, like
sage: x^2+1
x^2 + 1
sage: type(_)
<type 'sage.symbolic.expression.Expression'>
Fri, 20 Jun 2014 03:42:28 +0200https://ask.sagemath.org/question/11065/polynomial-list-array/?answer=16078#post-id-16078Answer by Francis Clarke for <p>I would like to store polynomials in an array/list in Sage. How do I do this?</p>
<hr/>
<p>I am editing my question due to the confusion expressed below.</p>
<p>I would like to generate a list of polynomials from a loop. </p>
https://ask.sagemath.org/question/11065/polynomial-list-array/?answer=16079#post-id-16079But maybe you meant:
sage: R.<x> = ZZ[]
sage: f = R.random_element(); f
-10*x^5 + 2*x^4 + 6*x^3 + x^2 + x + 4
sage: f.list()
[4, 1, 1, 6, 2, -10]
or
sage: list(f)
[4, 1, 1, 6, 2, -10]
Fri, 20 Jun 2014 03:46:53 +0200https://ask.sagemath.org/question/11065/polynomial-list-array/?answer=16079#post-id-16079