# 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.

edit retag close merge delete

( 2014-06-20 08:28:18 +0200 )edit

Thanks 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).

( 2014-06-20 11:55:45 +0200 )edit

Sort by ยป oldest newest most voted

But 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]

more

By 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'>

more