def contains_definite_form(V):
    """
    Check whether a given a subspace of the 3 dimensional space (a,b,c) contains
    a definitive positive quadratic form ax^2 + 2bxy + by^2.

    TESTS::

        sage: from flatsurf.geometry.finitely_generated_matrix_group import contains_definite_form

        sage: V = ZZ**3
        sage: contains_definite_form(V.submodule([(1,1,0)]))
        True
        sage: contains_definite_form(V.submodule([(2,1,1)]))
        True
        sage: contains_definite_form(V.submodule([(1,1,1)]))
        False
        sage: contains_definite_form(V.submodule([(1,0,0),(0,1,0)]))
        True
        sage: contains_definite_form(V.submodule([(1,0,0),(0,0,1)]))
        False
        sage: contains_definite_form(V.submodule([(-1,0,0),(0,1,3)]))
        True
    """
    dim = V.dimension()
    if dim == 0:
        return False
    elif dim == 1:
        a, c, b = V.gen(0)
        return b ** 2 < a * c
    elif dim == 2:
        a1, c1, b1 = V.gen(0)
        a2, c2, b2 = V.gen(1)
        if b1 ** 2 < a1 * c1 or b2 ** 2 < a2 * c2:
            return True
        return (2 * b1 * b2 - a2 * c1 - a1 * c2) ** 2 - 4 * (b1 ** 2 - a1 * c1
            ) * (b2 ** 2 - a2 * c2) > 0
    elif dim == 3:
        return True
    else:
        raise RuntimeError
