Ask Your Question

Revision history [back]

Rational quadratic form from invariants

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!