# Ticket #2653(closed defect: fixed)

Opened 5 years ago

## [with patch, with positive review] norm and trace of elements of orders are Rational not Integer

Reported by: Owned by: cremona was minor sage-2.11 number theory orders, norm, trace

### 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.

## Change History

### comment:1 Changed 5 years ago by cremona

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 x2-2*x+2, the trace should be 2 and the norm 2.

### 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:3 Changed 5 years ago by mabshoff

• Milestone set to sage-2.11

### 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!

### comment:6 Changed 5 years ago by mabshoff

• Status changed from new to closed
• Resolution set to fixed

Merged in Sage 2.11.alpha2

Note: See TracTickets for help on using tickets.