Opened 6 years ago
Last modified 6 years ago
#21123 new defect
monomials() and lt() for expansions of SymmetricFunctions over SymbolicRing broken
Reported by: | schilly | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-7.3 |
Component: | symbolics | Keywords: | |
Cc: | nthiery | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
smc user reported these inconsistencies related to listing monomials of a symmetric function:
e = SymmetricFunctions(SR).e() f = e([2]).expand(3) f f.monomials() f.lt() x0*x1 + x0*x2 + x1*x2 [1] x0*x1 + x0*x2 + x1*x2
i.e. just [1]
and the whole polynomial, while over QQ
:
e = SymmetricFunctions(QQ).e() f = e([2]).expand(3) f f.monomials() f.lt() x0*x1 + x0*x2 + x1*x2 [x0*x1, x0*x2, x1*x2] x0*x1
lists all three monomials and only one term for lt()
.
Change History (5)
comment:1 Changed 6 years ago by
comment:2 Changed 6 years ago by
- Cc nthiery added
- Summary changed from monomials() and lt() for SymmetricFunctions over SymbolicRing broken to monomials() and lt() for expansions of SymmetricFunctions over SymbolicRing broken
Nicolas, do you know who can comment on this, what would be a way to resolve this?
comment:3 follow-up: ↓ 4 Changed 6 years ago by
This is actually not a problem with symmetric functions, but how coercion into a polynomial ring over SR
works:
sage: R.<x,y,z> = PolynomialRing(ZZ) sage: p = x + y sage: S.<x,y,z> = PolynomialRing(SR) sage: f = S(p); f # This is what is used in symmetric functions in expand() x + y sage: f.monomials() [1] sage: f.coefficients() [x + y] sage: S.coerce_map_from(R)(p).monomials() [1] sage: S.coerce_map_from(R) Composite map: From: Multivariate Polynomial Ring in x, y, z over Integer Ring To: Multivariate Polynomial Ring in x, y, z over Symbolic Ring Defn: Conversion via _symbolic_ method map: From: Multivariate Polynomial Ring in x, y, z over Integer Ring To: Symbolic Ring then Generic morphism: From: Symbolic Ring To: Multivariate Polynomial Ring in x, y, z over Symbolic Ring
We probably check to see if the input can be considered a coefficient first, then try variable to variable. I would think the latter is actually a faster check, but it is probably a lesser-used code path.
comment:4 in reply to: ↑ 3 Changed 6 years ago by
Replying to tscrim:
This is actually not a problem with symmetric functions, but how coercion into a polynomial ring over
SR
works:
[...]
We probably check to see if the input can be considered a coefficient first, then try variable to variable. I would think the latter is actually a faster check, but it is probably a lesser-used code path.
To me this all sounds strange. Shouldn't a polynomial ring over SR be in SR itself, or it least it should be possible to coerse it there? But one gets:
sage: S.<x,y,z> = PolynomialRing(SR) sage: p=x+y sage: p in SR False sage: SR(p) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) [...] TypeError: not a constant polynomial sage:
comment:5 Changed 6 years ago by
See also #20454.
Most probably
SymmetricFunctions
should not allowSR
as an argument. By right,should create
f
inSR
, but it does something totally different:However it is possible to convert
f
into a symbolic expression:So the latter might be used as a workaround...