# What is the equivalent of Mathematica SymmetricReduction[] in Sage?

I'm trying to reproduce the operation in this short segment of a presentation on Galois theory in here and here. The code is:

\begin{align}\text{In}:\quad &Δ^2 = (x - y)^2 * (x - z)^2 * (y -z)^2\ &\text{SymmetricReduction}[Δ, {x, y, z}, {s1, s2, s3}]\ \text{Out}: &\quad {s1^2 s2^2 -4 s2^3 -4 s1^3s3+ 18 s1s2s3-27 s3^2, 0} \end{align}

edit retag close merge delete

Sort by » oldest newest most voted

First off, if a given polynomial f is symmetric, then the following conversion

SymmetricFunctions(f.base_ring()).e().from_polynomial(f)


will do the job.

For a non-symmetric polynomial, I think the following function is equivalent to the one in Mathematica:

def sym_reduce(f):
Sym = SymmetricFunctions(f.base_ring())
m = Sym.m()
e = Sym.e()
v = f.variables()
s = sum( t[0] * m[d].expand(len(v),v) for t in f if (d:=t[1].degrees())==tuple(sorted(d,reverse=True)) )
return sum(c*e[d] for d,c in e.from_polynomial(s) if len(d)==0 or d[0]<=len(v)), f-s


For example,

R.<x,y,z> = PolynomialRing(QQ)
sym_reduce((x-y)^2 * (x-z)^2 * (y-z)^2)


gives

(e[2, 2, 1, 1] - 4*e[2, 2, 2] - 4*e[3, 1, 1, 1] + 18*e[3, 2, 1] - 27*e[3, 3],
0)


PS. Note that the result depends on the variables order when given polynomial f is not symmetric.

more