#
#--> symmpoly([x1,x2,...,xn]);  or  symmpoly([x1,x2,...,xn],m);
#
# Return the m'th (default a sequence for m = 0..n) symmetric polynomial
# in the variables x1,x2,...,xn (which may not necessarilly be distinct).
# Author MBM: Aug/90
# Updated MBM: Jun/93 to use combinat[choose]
#

symmpoly := proc(x,m) local n, i, t;

    if not type(x,list(name)) then
	ERROR(`1st argument must be a list of names`) fi;

    n := nops(x);

    if nargs=1 then RETURN( seq( symmpoly(x,i), i=0..n ) ) fi;

    if not type(m,integer) or m < 0 or m > n then 
    	ERROR( `2nd argument must be an integer in the range`,0..n) fi;

    convert( [seq( convert(t,`*`), t=combinat[choose](x,m) )], `+` )

end:
`combinat/symmpoly` := eval(symmpoly):

`help/text/symmpoly` := TEXT(
`FUNCTION: symmpoly - generate the symmetric polynomials`,
`   `,
`CALLING SEQUENCES: symmpoly([x1,x2,...,xn]);  or`,
`                   symmpoly([x1,x2,...,xn],m);`,
`   `,
`PARAMETERS: x1,x2,...,xn - names`,
`            m - non-negative integer`,
`   `,
`SYNOPSIS:   `,
`- The call symmpoly([x1,...,xn],m) returns the symmetric polynomial`,
`  in the variables x1,...,xn (which may not necessarilly be distinct)`,
`  having total degree m`,
`- The call symmpoly([x1,...,xn]); returns a sequence of the symmetric`,
`  polynomials in x1, ..., xn for m = 0..n `,
`   `,
`EXAMPLES:   `,
`   `,
`> symmpoly([u,v,w,x],3);`,
`   `,
`                         u v w + u v x + u w x + v w x`,
`> symmpoly([x,y,z]);`,
`   `,
`                      1, x + y + z, x y + x z + y z, x y z`
):

#save `symmpoly.m`;
#quit
