On 11/01/2012 03:58 AM, Jori Mantysalo wrote:
> For example
>
> (x^5 + x^2+ (5*a)*x^3).collect(x)
>
> returns
>
> x^5 + 5*a*x^3 + x^2
>
> as I expected, but
>
> (x^5 + x^2+ (5*a)*x^3 + (10*a^2 + 6*a + 5)*x).collect(x)
>
> returns
>
> x^5 + 5*a*x^3 + (10*a^2 + 6*a + 5)*x + x^2
>
> How to order polynomial as "normal", i.e. descending exponents of x?
>
This kind-of works, but I think the ordering of the terms in the string
is baked in at a low level.
sage: a = var('a')
sage: f = (x^5 + x^2+ (5*a)*x^3 + (10*a^2 + 6*a + 5)*x)
sage: f.expand().collect(x^5).collect(x^4)...collect(x)
x^5 + 5*a*x^3 + (10*a^2 + 6*a + 5)*x + x^2
For best results, call expand() before collect() (see the trac ticket
below). After that, try collect()ing the terms that you care about
one-at-a-time.
>
> Documentation for collect-function is also almost missing, there is no
> explanation at all.
>
I have tried to remedy this here:
http://trac.sagemath.org/sage_trac/ticket/11839
If you're up to it, you could create a trac account and help review it.
As a documentation patch, it mostly needs a proofread and someone to
look over the new tests.
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.