Opened 14 years ago

Closed 14 years ago

# [with patch; positive review] behaviour of the norm function in the p-adic ring

Reported by: Owned by: L J P Kilford David Roe minor sage-4.0 padics 4.0.alpha0 David Roe Robert Bradshaw N/A

### Description

The p-adic norm seems to be defined differently in SAGE to the standard textbook definition, in which it is usually normalized so that \$|p|=1/p\$, but this is what SAGE does:

sage: n=Q11(11)
sage: n.norm()
11 + O(11^21)

Would it be possible to swap it round so that the norm of 11 is given as 1/11?

### comment:1 Changed 14 years ago by Michael Abshoff

Milestone: sage-3.4 → sage-3.4.1

3.4 is for ReST tickets only.

Cheers,

Michael

### comment:2 Changed 14 years ago by Francis Clarke

Type: defect → enhancement

There is a confusion of terminology here. It's the "field norm" that's defined for p-adics. Thus

sage: F.<a> = Q11.ext(x^2 - 2)
sage: (2 + 3*a).norm()
8 + 9*11 + 10*11^2 + 10*11^3 + 10*11^4 + 10*11^5 + O(11^6)
sage: (2 + 3*a)*(2 - 3*a)
8 + 9*11 + 10*11^2 + 10*11^3 + 10*11^4 + 10*11^5 + O(11^6)

So

sage: Q11(22).norm()
2*11 + O(11^7)

is correct, as is

sage: QQ(-163).norm()
-163

What you're wanting is usually called the p-adic absolute value (it's a norm in the functional analysis sense). It would be good if one could do

sage: Q11(22).abs()

and get 1/11. This isn't currently defined, if z is an element of a padic field, the absolute value can be obtained as

z.parent().prime()^(-z.ordp())

### comment:3 Changed 14 years ago by David Roe

Summary: behaviour of the norm function in the p-adic ring → [with patch; needs review] behaviour of the norm function in the p-adic ring

### comment:4 Changed 14 years ago by John Cremona

Summary: [with patch; needs review] behaviour of the norm function in the p-adic ring → [with patch; with review, needs work] behaviour of the norm function in the p-adic ring

I thought this looked good, and it applied ok to 3.4.1.rc1, but I got a whole lot of doctest failures in sage/rings/padics:

The following tests failed:

Most look like this:

**********************************************************************
sage: y = W.teichmuller(3); y
Exception raised:
Traceback (most recent call last):
File "/home/jec/sage-3.4.1.rc1/local/bin/ncadoctest.py", line 1231, in run_one_test
self.run_one_example(test, example, filename, compileflags)
File "/home/jec/sage-3.4.1.rc1/local/bin/sagedoctest.py", line 38, in run_one_example
OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
File "/home/jec/sage-3.4.1.rc1/local/bin/ncadoctest.py", line 1172, in run_one_example
compileflags, 1) in test.globs
File "<doctest __main__.example_11[14]>", line 1, in <module>
y = W.teichmuller(Integer(3)); y###line 304:
sage: y = W.teichmuller(3); y
File "sage_object.pyx", line 98, in sage.structure.sage_object.SageObject.__repr__ (sage/structure/sage_object.c:1342)
NotImplementedError
**********************************************************************
sage: b = A.teichmuller(1 + 2*a - a^2); b
Exception raised:
Traceback (most recent call last):
File "/home/jec/sage-3.4.1.rc1/local/bin/ncadoctest.py", line 1231, in run_one_test
self.run_one_example(test, example, filename, compileflags)
File "/home/jec/sage-3.4.1.rc1/local/bin/sagedoctest.py", line 38, in run_one_example
OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
File "/home/jec/sage-3.4.1.rc1/local/bin/ncadoctest.py", line 1172, in run_one_example
compileflags, 1) in test.globs
File "<doctest __main__.example_11[18]>", line 1, in <module>
b = A.teichmuller(Integer(1) + Integer(2)*a - a**Integer(2)); b###line 310:
sage: b = A.teichmuller(1 + 2*a - a^2); b
File "sage_object.pyx", line 98, in sage.structure.sage_object.SageObject.__repr__ (sage/structure/sage_object.c:1342)
NotImplementedError
**********************************************************************
2 of  20 in __main__.example_11

while there also some simpler ones:

sage: y.precision_relative()
Expected:
20
Got:
2
**********************************************************************
sage: y.precision_absolute()
Expected:
24
Got:
6

and

**********************************************************************
sage: ((1+2*w)^5).norm()
Expected:
1 + 5^2 + O(5^5)
Got:
1 + O(5^2)
**********************************************************************
sage: ((1+2*w)).norm()^5
Expected:
1 + 5^2 + O(5^5)
Got:
1 + O(5^2)
**********************************************************************
sage: a.trace()
Expected:
3*5 + 2*5^2 + 3*5^3 + 2*5^4 + O(5^5)
Got:
O(5)
**********************************************************************
sage: a.trace() + b.trace()
Expected:
4*5 + 5^2 + 5^3 + 2*5^4 + O(5^5)
Got:
O(5)
**********************************************************************
sage: (a+b).trace()
Expected:
4*5 + 5^2 + 5^3 + 2*5^4 + O(5^5)
Got:
O(5)
**********************************************************************
sage: c._ntl_rep()
Expected:
[89 9 4 1]
Got:
[4 4 4]
**********************************************************************
2 of   8 in __main__.example_29
3 of  11 in __main__.example_30
1 of   8 in __main__.example_31
***Test Failed*** 6 failures.
For whitespace errors, see the file /home/jec/sage-3.4.1.rc1/tmp/.doctest_padic_ZZ_pX_FM_element.py
[1.4 s]

I have absolutely no idea what in the patch has caused this, but it needs to be looked at!

### comment:5 Changed 14 years ago by Michael Abshoff

Component: number theory → padics changed from William Stein to David Roe

### comment:6 Changed 14 years ago by Michael Abshoff

Summary: [with patch; with review, needs work] behaviour of the norm function in the p-adic ring → [with patch; with review] behaviour of the norm function in the p-adic ring

I guess this is reviewed by #5778 and the issues reported here due to doctest failures have been fixed there.

Cheers,

Michael

### Changed 14 years ago by David Roe

Implements abs() and exlains the difference between it and norm()

### comment:7 Changed 14 years ago by Michael Abshoff

Summary: [with patch; with review] behaviour of the norm function in the p-adic ring → [with patch; positive review] behaviour of the norm function in the p-adic ring

Positive review due to #5778 - credit goes to RobertWB.

Cheers,

Michael

### comment:8 Changed 14 years ago by Michael Abshoff

Resolution: → fixed new → closed

Merged in Sage 4.0.alpha0.

Cheers,

Michael

### comment:9 Changed 13 years ago by David Loeffler

Authors: → David Roe → 4.0.alpha0 → Robert Bradshaw
Note: See TracTickets for help on using tickets.