Magma includes basic functions for working with symmetric polynomials, which are invariants of the symmetric group.
Given a polynomial ring P of rank n, and an integer k with 1 ≤k ≤n, return the k-th elementary symmetric polynomial of P.
Given a polynomial f from a polynomial ring P of rank n, return whether f is a symmetric polynomial of P (i.e., is symmetric in all the n variables of P). If the answer is true, a polynomial g from a new polynomial ring of rank n is returned such that f = g(e1, ..., en), where ei is the i-th elementary symmetric polynomial of P. If g is desired to be a member of a particular polynomial ring S of rank n (to obtain predetermined names of variables, for example), then S may also be passed.
> P<a, b, c, d> := PolynomialRing(RationalField(), 4, "grevlex"); > f := > a^2*b^2*c*d + a^2*b*c^2*d + a*b^2*c^2*d + a^2*b*c*d^2 + a*b^2*c*d^2 + > a*b*c^2*d^2 - a^2*b^2*c - a^2*b*c^2 - a*b^2*c^2 - a^2*b^2*d - > 3*a^2*b*c*d - 3*a*b^2*c*d - a^2*c^2*d - 3*a*b*c^2*d - b^2*c^2*d - > a^2*b*d^2 - a*b^2*d^2 - a^2*c*d^2 - 3*a*b*c*d^2 - b^2*c*d^2 - > a*c^2*d^2 - b*c^2*d^2 + a + b + c + d; > // Check orbit under Sym(4) has size one: > #(f^Sym(4)); 1 > Q<e1, e2, e3, e4> := PolynomialRing(RationalField(), 4); > l, E := IsSymmetric(f, Q); > l; true > E; e1 - e2*e3 + e2*e4In the following example, we use a rational function field to define parameters a and b which occur as coefficients of the symmetric polynomial f.
> F<a,b> := FunctionField(RationalField(), 2); > P<x1,x2,x3,x4,x5> := PolynomialRing(F, 5, "grevlex"); > y1 := x1^4 + x1^2*a + x1*b; > y2 := x2^4 + x2^2*a + x2*b; > y3 := x3^4 + x3^2*a + x3*b; > y4 := x4^4 + x4^2*a + x4*b; > y5 := x5^4 + x5^2*a + x5*b; > f := y1*y2 + y1*y3 + y1*y4 + y1*y5 + y2*y3 + y2*y4 + > y2*y5 + y3*y4 + y3*y5 + y4*y5; > Q<e1,e2,e3,e4,e5> := PolynomialRing(F, 5); > l,E := IsSymmetric(f, Q); > l, E; true b*e1^3*e2 - 2*a*e1^3*e3 - 4*e1^3*e5 + a*e1^2*e2^2 + 4*e1^2*e2*e4 + 2*e1^2*e3^2 - b*e1^2*e3 + 2*a*e1^2*e4 - 4*e1*e2^2*e3 - 3*b*e1*e2^2 + 4*a*e1*e2*e3 + 8*e1*e2*e5 + a*b*e1*e2 - 8*e1*e3*e4 - 2*a^2*e1*e3 + b*e1*e4 - 6*a*e1*e5 + e2^4 - 2*a*e2^3 - 4*e2^2*e4 + a^2*e2^2 + 4*e2*e3^2 + 5*b*e2*e3 + 2*a*e2*e4 + b^2*e2 - 3*a*e3^2 - 4*e3*e5 - 3*a*b*e3 + 6*e4^2 + 2*a^2*e4 - 5*b*e5