Ask Your Question
-1

polynomial list, array

asked 2014-06-19 15:30:28 -0500

Hans gravatar image

updated 2014-06-20 04:54:50 -0500

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 flag offensive close merge delete

Comments

please clarify your question

niles gravatar imageniles ( 2014-06-20 01:28:18 -0500 )edit

3 answers

Sort by ยป oldest newest most voted
1

answered 2014-06-19 20:46:53 -0500

Francis Clarke gravatar image

updated 2014-06-19 20:48:39 -0500

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]
edit flag offensive delete link more
1

answered 2014-06-19 20:42:28 -0500

kcrisman gravatar image

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'>
edit flag offensive delete link more
0

answered 2014-06-20 04:55:45 -0500

Hans gravatar image

updated 2014-06-20 04:59:25 -0500

Thanks for the answers posted above. Though not directly resolve my intended question due the unclarity 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).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-06-19 15:30:28 -0500

Seen: 228 times

Last updated: Jun 20 '14