Ticket #2653 (closed defect: fixed)
[with patch, with positive review] norm and trace of elements of orders are Rational not Integer
| Reported by: | cremona | Owned by: | was |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-2.11 |
| Component: | number theory | Keywords: | orders, norm, trace |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
For elements of an order, the norm and trace are (mathematically) integers, but Sage returns Rationals. More generally, the charpoly and minpoly are returned as Rational polynomials when they are (mathematically) in ZZ[].
sage: Zi.<i>=ZZ.extension(x^2+1) sage: n=(1+i).norm() sage: type(n) <type 'sage.rings.rational.Rational'> sage: t=(1+i).trace() sage: type(t) <type 'sage.rings.rational.Rational'> sage: p=(1+i).charpoly() sage: type(p) <class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_rational_dense'> sage: p=(1+i).minpoly() sage: type(p) <class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_rational_dense'>
I would like this to change, as it led to some very inefficient behaviour until I discovered it, and now I am having to manually coerce norms and traces into ZZ.
Attachments
Change History
comment:2 Changed 5 years ago by cremona
Apologies: the code
sage: Zi.<i>=ZZ.extension(x^2+1)
results in i being asigned to the first Z-module generator of the order, which is 1:
sage: i 1
so the second posting on this ticket is incorrect to say that the minpoly and charpoly (etc) are wrongly computed.
However I do *not* think that users should be allowed to enter
sage: Zi.<i>=ZZ.extension(x^2+1)
and have i assigned to 1.
comment:4 Changed 5 years ago by robertwb
- Summary changed from norm and trace of elements of orders are Rational not Integer to [with patch, needs review] norm and trace of elements of orders are Rational not Integer
comment:5 Changed 5 years ago by cremona
- Summary changed from [with patch, needs review] norm and trace of elements of orders are Rational not Integer to [with patch, with positive review] norm and trace of elements of orders are Rational not Integer
Review of patch: the code looks just fine and appears to solve the problem raised. I only say "appears" as I'm travelling and not in a position to test it myself, but the added doctests give me sufficitne confidence to say: OK!


Actually it is worse than that:
These are wrong! Both the minpoly and charpoly of 1+i should be x2-2*x+2, the trace should be 2 and the norm 2.