On Tue, Nov 4, 2008 at 7:23 AM, mai <[EMAIL PROTECTED]> wrote:
>
> Hi all,
> is there in SAGE a function similar to Mathematica's Collect ?
>
> Thanks a lot,
> -- Mai
>

Mathematica's Collect is described here:
    http://reference.wolfram.com/mathematica/ref/Collect.html

Sage's coeffs function does something similar.

sage: var('a,x')
(a, x)
sage: f = ((1+a+x)^4)
sage: f.coeffs(x)
[[(a + 1)^4, 0], [4*(a + 1)^3, 1], [6*(a + 1)^2, 2], [4*(a + 1), 3], [1, 4]]

Using sum we get exactly what mathematica's collect gives:
sage: sum(c*x^i for c, i in f.coeffs(x))
x^4 + 4*(a + 1)*x^3 + 6*(a + 1)^2*x^2 + 4*(a + 1)^3*x + (a + 1)^4

You could in the above example also get something similar from taylor:

sage: f.taylor(x,0,5)
1 + 4*a + 6*a^2 + 4*a^3 + a^4 + (4*a^3 + 12*a^2 + 12*a + 4)*x + (6*a^2
+ 12*a + 6)*x^2 + (4*a + 4)*x^3 + x^4

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to