-
-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inconsistencies of .subs() for multivariate polynomials #19130
Comments
See https://groups.google.com/g/sage-devel/c/vGzNJKAQWbs/m/YBRN4XOjAwAJ for some discussion. |
There seems to be consensus that, ideally, the parent of the output should only depend on the parents of the input. A further question is, whether one should make a distinction between a partial substitution, i.e., where only some of the generators are substituted, and a full substitution. One idea is to regard any partial substitution as a full substitution, where unspecified generators are substituted by themselves. Then, the parent of the output could be the common parent of base ring and parents of the values. Doing so,
would be correct. By contrast, we would have
By analogy, substitutions in the |
However, the following doctests violates the proposed rule:
Here, the substitution is partial, so given the above the result should be in One might argue that constants are special, but it seems that only
|
Possibly this question should be discussed together with what the parent of the result of division should be. Currently, we have
|
In some ways this is more clear cut, but we do have some exceptions for very important reasons (mainly Laurent polynomials when dividing by a monomial). Whichever way we decide to do it, we should 100% be consistent between the uni- and multi-variate cases. I don’t like that 0 is treated differently than constants. At the very least I expect those to behave the same. |
I like the idea of filling up a partial substitution to a full one. Hopefully that is not incompatible with other cases. |
Yes, there would be no full evaluation of InfinitePolynomial. And I should also have said that this would only be the definition, not the implementation. |
My main point on such issues is that it is extremely frustrating when there are discrepancies between univariate and multivariate behaviour, as well as different "special" cases like 0 and 1 demonstrated here. When the code is written to treat one case and then suddenly it breaks on another, which is logically the same, it is unpleasant. Since you can substitute elements that will expand the ring, it is natural to expect some changes. But when such a change is happening for a particular substitution, there is no reason to depend on the polynomial. In particular, maybe there is usually a substitution into "a full polynomial", but in some case it happens to be 0. That zero should work in the same way after the substitution, without any surprises with smaller rings. |
I expect it's an implementation issue: with other polynomials you can just let the coercion system figure out common parents as you go along, but for the zero polynomial there is no arithmetic with the arguments involved (because there are no monomials!), so you have to synthesize the parent for 0 yourself. One would probably get more uniform behaviour if polynomial evaluation/substitution code would analyze its evaluation arguments and construct a target parent to begin with and then coerce everything into there before doing arithmetic. I note that actually doing that may decrease performance: imagine polynomials over some very complicated ring that gets evaluated at integers. The values of the monomials could potentially be computed very efficiently. On the other hand, over a finite field that could blow up quite badly. |
I started to decipher the code of sage/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx Lines 3563 to 3678 in 1cd4990
Let me give a brief summary of what I believe to understand so far:
What I'd like to do (for experimentation) is to return in 3662 only if I think that the loop leading to 2) is also quite inefficient - we are possibly doing unnecessary work if only the last |
compared to the univariate case
Note also that we have
CC: @sagetrac-tmonteil @bgrenet
Component: algebra
Issue created by migration from https://trac.sagemath.org/ticket/19130
The text was updated successfully, but these errors were encountered: