Ask Your Question
-2

polynomial list, array

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

Hans gravatar image

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

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

Hans gravatar imageHans ( 2014-06-20 04:55:45 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

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

Francis Clarke gravatar image

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

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 -0600

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

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 -0600

Seen: 532 times

Last updated: Oct 30