On 09/06/2018 04:00, Travis Scrimshaw wrote:
What Vincent has neglected to mention is the reasoning why I am suggesting
to keep the current behavior for Laurent polynomials. A casual user will
almost certainly do
1 / x^k
and then try to do a method on Laurent polynomials (say, iterate over such
element). The rational functions code does not have many of the methods and
features that Laurent polynomials have.
Also, they (or at least I) would be quite surprised when x^-1 does not
behave the same as 1/x as they are mathematically equivalent. Also, what
about ~x, should that be the same as 1/x or x^-1? You now have to choose
the correct inverse to get working code. I think this inconsistency is far
worse.
Mathematically equivalent is first of all vague and secondly not
relevant within most CAS since there are tons of different 0 that behave
very differently.
I agree that having x^-1 and 1/x being different is confusing. I will
update the branch at #25524 to make them identically return a rational
fraction.
I think that any comparison to the integers is a bit unfair given that ZZ
and QQ are generally very good with ducktyping and there is no natural way
to create the inverse of the variables (i.e., what makes them Laurent
polynomials) other than by division or exponentiation.
"natural" sounds strange in that context. As already mentioned there is
1 // x
to get the inverse of x. And x.inverse_of_unit() also does the job.
Though, close to what Nils talked about, there is no straight
method for "internal division or raise error". The closest would
be
sage: L.<q> = LaurentPolynomialRing(QQ)
sage: a = (q + 1)
sage: b = q * (q + 1)
sage: L(a / b)
q^-1
sage: L(1 / (q + 1))
Traceback (most recent call last):
...
ArithmeticError: element is not a unit
This is what you obtain with the branch at #25524 thanks to
the initialization of a Laurent polynomial from a rational
fraction.
Vincent
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.