1 | initial version |
I think this is it:
def sym_reduce(f):
Sym = SymmetricFunctions(f.base_ring())
m = Sym.m()
e = Sym.e()
v = f.variables()
s = 0
while True:
t = max((t for t in f if t[1] and (d:=t[1].degrees())==tuple(sorted(d,reverse=True))), key=lambda t: t[1], default=0)
if t==0:
return sum(c*e[d] for d,c in e.from_polynomial(s) if max(d)<=len(v)), f
g = t[0] * m[t[1].degrees()].expand(len(v),v)
s += g
f -= g
For example,
R.<x,y,z> = PolynomialRing(QQ, order='lex')
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 monomial order.
2 | No.2 Revision |
I think this is it:
def sym_reduce(f):
Sym = SymmetricFunctions(f.base_ring())
m = Sym.m()
e = Sym.e()
v = f.variables()
s = 0
while True:
try:
t = max((t next( t for t in f if t[1] and (d:=t[1].degrees())==tuple(sorted(d,reverse=True))), key=lambda t: t[1], default=0)
if t==0:
(d:=t[1].degrees())==tuple(sorted(d,reverse=True)) )
except StopIteration:
return sum(c*e[d] for d,c in e.from_polynomial(s) if max(d)<=len(v)), f
g = t[0] * m[t[1].degrees()].expand(len(v),v)
s += g
f -= g
For example,
R.<x,y,z> = PolynomialRing(QQ, order='lex')
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 monomial order.
3 | No.3 Revision |
I think this is it:
def sym_reduce(f):
Sym = SymmetricFunctions(f.base_ring())
m = Sym.m()
e = Sym.e()
v = f.variables()
s = 0
while True:
try:
t = next( t for t in f if t[1] and (d:=t[1].degrees())==tuple(sorted(d,reverse=True)) )
except StopIteration:
return sum(c*e[d] for d,c in e.from_polynomial(s) if max(d)<=len(v)), len(d)=0 or d[0]<=len(v)), f
g = t[0] * m[t[1].degrees()].expand(len(v),v)
s += g
f -= g
For example,
R.<x,y,z> = PolynomialRing(QQ, order='lex')
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 monomial order.
4 | No.4 Revision |
I think this is it:
def sym_reduce(f):
Sym = SymmetricFunctions(f.base_ring())
m = Sym.m()
e = Sym.e()
v = f.variables()
s = 0
while True:
try:
t = next( t for t in f if t[1] and (d:=t[1].degrees())==tuple(sorted(d,reverse=True)) )
except StopIteration:
return sum(c*e[d] for d,c in e.from_polynomial(s) if len(d)=0 len(d)==0 or d[0]<=len(v)), f
g = t[0] * m[t[1].degrees()].expand(len(v),v)
s += g
f -= g
For example,
R.<x,y,z> = PolynomialRing(QQ, order='lex')
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 monomial order.
5 | No.5 Revision |
I think this is it:
def sym_reduce(f):
Sym = SymmetricFunctions(f.base_ring())
m = Sym.m()
e = Sym.e()
v = f.variables()
s = 0
while True:
try:
t = next( t for t in f if t[1] and (d:=t[1].degrees())==tuple(sorted(d,reverse=True)) )
except StopIteration:
return sum(c*e[d] for d,c in e.from_polynomial(s) if len(d)==0 or d[0]<=len(v)), f
g = t[0] * m[t[1].degrees()].expand(len(v),v)
s += g
f -= g
For example,
R.<x,y,z> = PolynomialRing(QQ, order='lex')
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 monomial variables order.
6 | No.6 Revision |
I think this is it:
def sym_reduce(f):
Sym = SymmetricFunctions(f.base_ring())
m = Sym.m()
e = Sym.e()
v = f.variables()
s = 0
while True:
try:
t = next( t for t in f if t[1] and (d:=t[1].degrees())==tuple(sorted(d,reverse=True)) )
except StopIteration:
return sum(c*e[d] for d,c in e.from_polynomial(s) if len(d)==0 or d[0]<=len(v)), f
g = t[0] * m[t[1].degrees()].expand(len(v),v)
s += g
f -= g
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.
f
is not symmetric. 7 | No.7 Revision |
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 this the following function is it: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 = 0
while True:
try:
t = next( t for t in f if t[1] and (d:=t[1].degrees())==tuple(sorted(d,reverse=True)) )
except StopIteration:
return sum(c*e[d] for d,c in e.from_polynomial(s) if len(d)==0 or d[0]<=len(v)), f
g = t[0] * m[t[1].degrees()].expand(len(v),v)
s += g
f -= g
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.
8 | No.8 Revision |
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 = 0
while True:
try:
t = next( t sum( t[0] * m[t[1].degrees()].expand(len(v),v) for t in f if t[1] and (d:=t[1].degrees())==tuple(sorted(d,reverse=True)) )
except StopIteration:
return sum(c*e[d] for d,c in e.from_polynomial(s) if len(d)==0 or d[0]<=len(v)), f
g = t[0] * m[t[1].degrees()].expand(len(v),v)
s += g
f -= g
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.
9 | No.9 Revision |
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[t[1].degrees()].expand(len(v),v) 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.