Ask Your Question

Revision history [back]

The problem is that your quadratic form is not definite.

sage: q = QuadraticForm(ZZ, 2, [3, 2, 0])
sage: q
Quadratic form in 2 variables over Integer Ring with coefficients: 
[ 3 2 ]
[ * 0 ]
sage: q.is_definite()
False

Indeed when you try to see what q.lll() is doing:

sage: q.lll??

you see that it is doing

self(self.matrix().LLL_gram())

Let us try this step by step, by first computing self.matrix()

sage: m = q.matrix()
sage: m
[6 2]
[2 0]

and then applying the LLL_gram method to it.

sage: m.LLL_gram()

We get the same error as the one you got.

Looking at the documentation for this method:

sage: m.LLL_gram?

we read:

LLL reduction of the lattice whose gram matrix is self.

INPUT:

* "M" - gram matrix of a definite quadratic form

OUTPUT:

* "U" - unimodular transformation matrix such that U.transpose() *
  M * U  is LLL-reduced.

So the documentation is telling us the input should be the Gram matrix from a definite quadratic form.

It is true that the message you got was not so helpful and that it took some digging to get to the problem.

Maybe it would be worth for the lll method to first check if the form is definite, and raise an error if not, rather than trying to do the computation and letting the user end up with a not so helpful error message. Of course, one could add a keyword to decide whether to perform the test, if this test makes the method slower. This way when one uses the method a lot with forms known to be definite, one could keep speed.