On Oct 11, 10:24 pm, James Parson <par...@hood.edu> wrote: > Dear sage-support, > > Is there a preferred built-in method for invoking elementary symmetric > functions in Sage? > > The best that I could turn up was something like the following: > > sage: e = SFAElementary(QQ) > sage: e([2]).expand(3) > x0*x1 + x0*x2 + x1*x2 > > That is very nice, but when I tried to automate some constructions (in > Sage 4.5.3), I ran into the following sort of problem: > > sage: for i in range(3): > ... print(e([i]).expand(3)) > Traceback (most recent call last): > ... > AttributeError: 'list' object has no attribute 'parent' >
It turns out that Python starts counting at zero. So sage: range(3) [0, 1, 2] So this works. sage: for i in range(1,4): e([i]).expand(3) ....: x0 + x1 + x2 x0*x1 + x0*x2 + x1*x2 x0*x1*x2 For something a little more "Sage-ic", you could try sage: for i in [1..3]: e([i]).expand(3) ....: x0 + x1 + x2 x0*x1 + x0*x2 + x1*x2 x0*x1*x2 This uses Sage Integers instead of Python ints. However, none of this deals with the issue that the error message is most uniformative for e([0]). Chalk this up as another place where 'empty' input causes some trouble. Someone on sage-combinat already working on this particular instance (I know many of them have been fixed recently)? - kcrisman -- 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