Possible bug in is_locally_represented_number in the quadratic forms package

36 views
Skip to first unread message

Edna Jones

unread,
Jun 30, 2014, 10:54:30 PM6/30/14
to sage-s...@googlegroups.com
sage: Q = DiagonalQuadraticForm(ZZ,[1,4,4])
sage: for j in range(42,43):
....:     print(j, Q.is_locally_represented_number(j)) # should print (42, False) but prints (42, True)
....: 
(42, True)

The above code prints (42, True) using Sage, version 6.2. I should state that the above code prints the correct output, i.e. (42, False), if IntegerRange is used instead of range. To see why the code should print (42, False), mod the expression generated by the quadratic form by 4. I believe that is_locally_represented_number() returns the wrong value because I'm passing a Python int to it instead of a Sage Integer. However, the documentation for is_locally_represented_number() does not explicitly state that a Python int cannot be passed to it. Clearly, the function is_locally_represented_number() does not raise an error when a Python int is passed to it; the function just outputs ridiculous values.

John Cremona

unread,
Jul 1, 2014, 9:39:25 AM7/1/14
to SAGE support
With 6.3.beta5 I get

sage: Q = DiagonalQuadraticForm(ZZ,[1,4,4])
sage: Q.is_locally_represented_number(42)
True
sage: Q.is_locally_represented_number(int(42))
True

which suggests that this has been fixed.

John
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

Dominique Laurain

unread,
Jul 1, 2014, 2:03:35 PM7/1/14
to sage-s...@googlegroups.com
Please check my answer below...I am newbie in these subjects...

The point of Edna's Jones question is about "locally", no ?

As Pete L.Clark points out in http://www.math.uga.edu/~pete/CasselsLemma.pdf

a number n can be "locally" (in Qp) represented but not integrally represented....read some examples in Clark's paper

The ZZ field is forced in DiagonalQuadraticForm() first argument to specify integer quadratic forms (with integer coefficients).

It doesn't matter if you use ZZ or python int for locally_represented_number() argument (+1 : previous answer).

You have Gauss's theorem for representing  number n different of 4^k(8l+7)  by the form x^2 + y^2 + z^2 with x,y,z in Q
and 42  is represented by it, so it is represented by the equivalent form x^2 + (2y)^2 + (2z)^2.

That's why function locally_represented returns true ... while obviously no integers x,y,z can be set to have x^2 + 4y^2 + 4z^2 = 42

Dominique


Edna Jones

unread,
Jul 1, 2014, 11:19:01 PM7/1/14
to sage-s...@googlegroups.com
Just to clarify, I believe that Q.is_locally_represented_number(42), where Q = DiagonalQuadraticForm(ZZ, [1,4,4]) should return False.

An integer m is locally represented if m is represented by Q mod p ^a for every prime p and every non-negative integer a and also that it is represented over the real numbers. This is a paraphrase from Jonathan Hanke's article "Local Densities and Explicit Bounds for Representability by a Quadratic Form." By m is represented by Q, I mean that there exists a vector v with integer entries such that Q(v) = m.

What I was saying in my post is that if you take the quadratic form x^2 + 4*y^2 + 4*z^2 (mod 2^2), you get that this expression is equivalent to x^2 (mod 4). However, 42 is equivalent to 2 (mod 4), and no number equivalent to 2 (mod 4) is a square. You could do a brute force calculation to verify this fact.

By the way, if the following actually occurs with 6.3.beta5, the program that I'm writing in Sage is going to be severely inaccurate in future versions of Sage unless this bug is fixed:
sage: Q = DiagonalQuadraticForm(ZZ,[1,4,4]) 
sage: Q.is_locally_represented_number(42) 
True

Dominique Laurain

unread,
Jul 2, 2014, 1:58:58 PM7/2/14
to sage-s...@googlegroups.com

In bold : where you and I disagree

you : "By m is represented by Q, I mean that there exists a vector v with integer entries such that Q(v) = m"

me : "By m is locally represented by Q, I mean that there exists a vector v with rational entries such that Q(v) = m"

You want to use Q.is_locally_represented_number()

Dominique
Message has been deleted

Dominique Laurain

unread,
Jul 2, 2014, 2:20:19 PM7/2/14
to sage-s...@googlegroups.com
42 is (integer) represented by form x^2 + y^2 + z^2  :   42 = 1^2 + 4^2 + 5^2

42 is locally (rationaly) represented by form x^2 +4 y^2 + 4z^2  :   42 = 1^2 + 4(4/2)^2 + 4(5/2)^2

Edna Jones

unread,
Jul 2, 2014, 4:25:23 PM7/2/14
to sage-s...@googlegroups.com
Thank you Dominique,

I didn't realize that is_locally_represented_number() is defined to return True if and only if m is locally represented by Q over the rational numbers. (I misunderstood the documentation for the function.) In that case, you are correct.

Is there a function in Sage that returns True if and only if m is locally represented by Q over the integers?

Sincerely,
Edna
Message has been deleted

Dominique Laurain

unread,
Jul 3, 2014, 1:22:37 PM7/3/14
to sage-s...@googlegroups.com
8 minutes (19:20)
Good question Edna.!!...:-)

I had the same question many months ago, when I was entertained by the 15-theorem and one Bhargava's paper.

I have not skipped the subject forever... just interested now about geometry.

You can be sure I would be very interested to know a polynominal time algorithm giving all (x,y,z) integers representing n in the Ramanujan's form n = x^2 + y^2 + 10 z^2   ....  :-)

Dominique.

Dominique Laurain

unread,
Jul 3, 2014, 2:19:32 PM7/3/14
to sage-s...@googlegroups.com

One SUFFICIENT condition for equivalence between "f represented in Q" and "f represented in Z" is given by Davenport-Cassels Lemma in J.P.Serre ' A course of Arithmetic' book.

(note : wikipedia page about it needs rewriting):

given f(X) = sum(aij Xi Xj) a definite positive quadratic form, with matrix (aij) symetric and with integer coefficients
given the hypothesis (H) "for every x=(x1,x2,..xp) in Q^p  it exists at leat one y in Z^p such as f(x-y) < 1"
then, if n is represented by f in Q field, then n is represented by f in Z field

Follows one example (Gauss's theorem) with the form x^2 + y^2 + z^2 representing n in Q field when n not equals to 4^a (8b-1)..such n is represented in Z field too, because (H) hypothesis holds. for the form.

Challenge : try to check if (H) hypothesis is true or false for your form..

Dominique.

Reply all
Reply to author
Forward
0 new messages