A binary quadratic form is a polynomial ax2 + bxy + cy2 with integer coefficients a, b, c. The form is primitive if the coefficients have no common factor. Only primitive forms are considered here. The discriminant of a form is D = b2 - 4 a c. For negative discriminants, only positive definite forms are considered, i.e. a and hence c must be positive. In Magma forms are printed as tuples < (a, b, c) >.
Binary quadratic forms are related to many other topics in number theory, including quadratic fields, modular forms and complex multiplication. Algorithms for binary quadratic forms provide efficient means of computing ideal class groups of orders in quadratic fields. By using the explicit relation of definite quadratic forms with lattices with nontrivial endomorphism ring in the complex plane, one can apply modular and elliptic functions to forms, and exploit the analytic theory of complex multiplication.
Quadratic forms of a given discriminant D correspond to ordered bases of ideals in an order in a quadratic number field, up to scaling by the rationals. For negative discriminants, the primitive reduced forms in this structure are in bijection with the class group of invertible ideals. For positive discriminants, the reduced orbits of forms are used for this purpose. Efficient algorithms are provided for composition, enumeration of reduced forms, class group computations, and discrete logarithms. The functions are implemented for quadratic forms for all discriminants, not only fundamental discriminants. Maps between forms of different discriminants are also provided.
The functionality for binary quadratic forms is rounded out with various functions for applying modular and elliptic functions to forms, and for class polynomials associated to class groups of definite forms.