Thanks --- I wrote my own function but thought it would be much better to use built in one if there exists any. Yours is much nicer and shorter than mine too.
On Jul 20, 5:32 pm, Mike Hansen <[email protected]> wrote: > On Tue, Jul 20, 2010 at 4:26 PM, tvn <[email protected]> wrote: > > Is there a built in function that given n variables and d degree, > > compute all the terms from degree 0 to d of all those n variables > > combined ? The # of terms = bionomial(n+d,d) > > Not built in exactly, but here is one way: > > sage: vars = (1,) + var('y, q, d, x, dd, r') > sage: degree = 2 > sage: [prod(vars[i] for i in indices) for indices in > MultichooseNK(len(vars),degree)] > [1, y, q, d, x, dd, r, y^2, q*y, d*y, x*y, dd*y, r*y, q^2, d*q, q*x, > dd*q, q*r, d^2, d*x, d*dd, d*r, x^2, dd*x, r*x, dd^2, dd*r, r^2] > > --Mike -- 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 URL: http://www.sagemath.org
