> Can I do this in Sage?

Sure. Here you have some tips:

{{{id=1|
#Create n variables with names x1, x2 ... xn
#and store them in a list vs
n = 5
vs = var(' '.join('x%d'%j for j in range(5)))
vs
///
(x0, x1, x2, x3, x4)
}}}

{{{id=6|
def pot(vs,ds):
    return prod(v^d for v,d in zip(vs,ds))

pot(vs,[1,2,3])
///
x0*x1^2*x2^3
}}}

{{{id=2|
def generating_function(cs):
    return prod(1 + c*pot(vs,ds) for ds,c in cs.items())

generating_function({(1,1,0,0,1):3, (1,1,0,0,0):5})
///
(5*x0*x1 + 1)*(3*x0*x1*x4 + 1)
}}}

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to