Skip to content
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

norm and trace of elements of orders are Rational not Integer #2653

Closed
JohnCremona opened this issue Mar 23, 2008 · 5 comments
Closed

norm and trace of elements of orders are Rational not Integer #2653

JohnCremona opened this issue Mar 23, 2008 · 5 comments

Comments

@JohnCremona
Copy link
Member

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.

Component: number theory

Keywords: orders, norm, trace

Issue created by migration from https://trac.sagemath.org/ticket/2653

@JohnCremona
Copy link
Member Author

comment:1

Actually it is worse than that:

sage: Zi.<i>=ZZ.extension(x^2+1)
sage: a=1+i
sage: a.norm()
4
sage: a.trace()
4
sage: a.minpoly()
x - 2
sage: a.charpoly()
x^2 - 4*x + 4

These are wrong! Both the minpoly and charpoly of 1+i should be x^2-2*x+2, the trace should be 2 and the norm 2.

@JohnCremona
Copy link
Member Author

comment:2

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.

@sagetrac-mabshoff sagetrac-mabshoff mannequin added this to the sage-2.11 milestone Mar 23, 2008
@robertwb
Copy link
Contributor

comment:4

Attachment: 2653-integral-norms.patch.gz

@JohnCremona
Copy link
Member Author

comment:5

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!

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Mar 26, 2008

comment:6

Merged in Sage 2.11.alpha2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants