Rational quadratic form from invariants

asked 2023-01-17 23:45:41 +0100

I'm trying to restore rational quadratic form from invariants using quadratic_form_from_invariants function. But why this code doesn't work? I'm taking rational quadratic form invariants and trying to restore it back. Or am I doing something wrong?

    Q = DiagonalQuadraticForm(QQ, [1, -1, -1])
P = [p for p in [-1] + list(prime_range(1000)) if Q.hasse_invariant(p) == -1]

params = Q.dim(), Q.Gram_det(), P, Q.signature_vector()[1]
print(params)

print(quadratic_form_from_invariants(QQ, *params))

It gets results

  (3, 1, [-1, 2], 2)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [1], in <cell line: 7>()
      4 params = Q.dim(), Q.Gram_det(), P, Q.signature_vector()[Integer(1)]
      5 print(params)
----> 7 print(quadratic_form_from_invariants(QQ, *params))

File /home/sc_serv/sage/src/sage/quadratic_forms/quadratic_form.py:154, in quadratic_form_from_invariants(F, rk, det, P, sminus)
    152     f = 1
    153 if (f + len(P)) % 2 == 1:
--> 154     raise ValueError("invariants do not define a rational quadratic form")
    155 D = []
    156 while rk >= 2:

ValueError: invariants do not define a rational quadratic form

Thanks!

edit retag flag offensive close merge delete

Comments

P is a list of primes, so why [-1] is in your code? It seems that without this [-1] your code works

achrzesz gravatar imageachrzesz ( 2023-01-18 13:51:21 +0100 )edit

You may try P = [p for p in 2*[-1] + list(prime_range(1000)) if Q.hasse_invariant(p) == -1] to avoid that raise - the implementer had something different in mind and wanted P to be a list of primes...

dan_fulea gravatar imagedan_fulea ( 2023-01-20 21:32:57 +0100 )edit