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

Bug in is_hyperbolic #18430

Closed
sagetrac-pkoprowski mannequin opened this issue May 16, 2015 · 23 comments
Closed

Bug in is_hyperbolic #18430

sagetrac-pkoprowski mannequin opened this issue May 16, 2015 · 23 comments

Comments

@sagetrac-pkoprowski
Copy link
Mannequin

sagetrac-pkoprowski mannequin commented May 16, 2015

The method is_hyperbolic in the class of quadratic form returns incorrect results over the field QQ_2. Here is an explicit example:

q = DiagonalQuadraticForm(QQ, [1,1,-1,-1])
print q.is_hyperbolic(2)

The form <1,1,-1,-1> is clearly hyperbolic - by definition. It is a sum of two hyperbolic planes. Nevertheless Sage returns False here.

The reason is as follows. In the file quadratic_forms/quadratic_form__local_field_invariants.py in function is_hyperbolic the actual code is

    elif p == 2:
        return QQ(self.det() * (-1)**m).is_padic_square(p) and (self.hasse_invariant(p) == (-1)**m)    ## Actually, this -1 is the Hilbert symbol (-1,-1)_p

while it should be

    elif p == 2:
        return QQ(self.det() * (-1)**m).is_padic_square(p) and (self.hasse_invariant(p) == (-1)**(m*(m-1)/2))    ## Actually, this -1 is the Hilbert symbol (-1,-1)_p

For mathematical explanation see e.g. T.Y. Lam "Introduction to Quadratic Forms over Field", Proposition V.3.25

I'm not sure how to formally patch the code, so I'm posting it this way.

Component: quadratic forms

Author: Malcolm Rupert

Branch/Commit: f99393f

Reviewer: Frédéric Chapoton, Travis Scrimshaw

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

@sagetrac-pkoprowski sagetrac-pkoprowski mannequin added this to the sage-6.7 milestone May 16, 2015
@sagetrac-MRupert
Copy link
Mannequin

sagetrac-MRupert mannequin commented May 25, 2015

Branch: u/MRupert/bug_in_is_hyperbolic

@sagetrac-MRupert
Copy link
Mannequin

sagetrac-MRupert mannequin commented May 25, 2015

comment:2

This commit should fix the problem. I also added functionality and improved the documentation on the infinite place.


New commits:

abb9f9918430: Fixes self.is_hyperbolic(2) and various cleanups

@sagetrac-MRupert
Copy link
Mannequin

sagetrac-MRupert mannequin commented May 25, 2015

Commit: abb9f99

@sagetrac-MRupert
Copy link
Mannequin

sagetrac-MRupert mannequin commented May 25, 2015

Author: Malcolm Rupert

@jdemeyer
Copy link

jdemeyer commented Jun 9, 2015

comment:3

Can you replace

if p == "infinity":
    return self.is_definite()
else:
    ...

by

if p == Infinity:
    return self.is_definite()

...

This means you don't need to indent the whole block for p a prime number and I also prefer the actual value Infinity (which needs to be imported from sage.rings.infinity) instead of the string "infinity".

I also don't understand why you use -1 at one point and "infinity" somewhere else.

And instead of writing

(-1)**(m*(m-1)/2)) ## Actually, this -1 is the Hilbert symbol (-1,-1)

why don't you actually write

hilbert_symbol(-1, -1, p)**(m*(m-1)/2))

@fchapoton
Copy link
Contributor

Changed commit from abb9f99 to fc968e3

@fchapoton
Copy link
Contributor

comment:5

rebase and clean-up


New commits:

fc968e3Merge branch 'u/MRupert/bug_in_is_hyperbolic' in 7.4.b2

@fchapoton
Copy link
Contributor

Changed branch from u/MRupert/bug_in_is_hyperbolic to u/chapoton/18430

@fchapoton fchapoton modified the milestones: sage-6.7, sage-7.4 Aug 28, 2016
@fchapoton fchapoton modified the milestones: sage-7.4, sage-8.0 Apr 2, 2017
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 3, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

64cfdf3Merge branch 'u/chapoton/18430' in 8.0.b0
7690f84trac 18430 fixing doctests, plus little code cleanup

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 3, 2017

Changed commit from fc968e3 to 7690f84

@tscrim
Copy link
Collaborator

tscrim commented Apr 3, 2017

comment:9

Replying to @jdemeyer:

I also don't understand why you use -1 at one point and "infinity" somewhere else.

And instead of writing

(-1)**(m*(m-1)/2)) ## Actually, this -1 is the Hilbert symbol (-1,-1)

why don't you actually write

hilbert_symbol(-1, -1, p)**(m*(m-1)/2))

I am pretty sure the former is (much) faster and the comment makes the simplification clear.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 4, 2017

Changed commit from 7690f84 to 3231a6d

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 4, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

3231a6dtrac 18430 details

@fchapoton
Copy link
Contributor

comment:11

done

@fchapoton
Copy link
Contributor

comment:12

ping ?

@tscrim
Copy link
Collaborator

tscrim commented Jun 3, 2017

Reviewer: Frédéric Chapoton, Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Jun 3, 2017

comment:13

If you just fix up this INPUT: docstring (in a few places):

-`p` -- a prime number > 0 or `-1` for the infinite place.
+- `p` -- a prime number > 0 or `-1` for the infinite place

Once that is done, you can set a positive review on my behalf.

@sagetrac-pmercuri
Copy link
Mannequin

sagetrac-pmercuri mannequin commented Jun 5, 2017

Work Issues: documentation formatting

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 7, 2017

Changed commit from 3231a6d to f99393f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 7, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

b4f668aMerge branch 'u/chapoton/18430' in 8.0.b9
f99393ftrac 18430 INPUT field has no dot

@fchapoton
Copy link
Contributor

Changed work issues from documentation formatting to none

@tscrim
Copy link
Collaborator

tscrim commented Jun 7, 2017

comment:17

LGTM.

@vbraun
Copy link
Member

vbraun commented Jun 9, 2017

Changed branch from u/chapoton/18430 to f99393f

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

4 participants