Binary Quadratic Forms: Introduction
Which integers can be written as for integers ? This question looks like a natural cousin of representing numbers as sums of two squares. Yet it behaves in a strikingly different and richer way. The expression is a binary quadratic form: a homogeneous degree-two polynomial in two variables with integer coefficients. Studying which integers such forms represent, and how different-looking forms can secretly represent the same set of integers, was one of the great achievements of eighteenth- and nineteenth-century number theory. It was driven by Fermat, Lagrange, Legendre, and above all Gauss. The subject matters because binary quadratic forms unify and vastly generalize the theory of Sums of Two Squares. That classical theorem is really the special case of the form . Once we allow arbitrary forms , we gain a language capable of encoding questions about primes represented by . It also encodes the arithmetic of quadratic fields, class numbers, and eventually Pell-type equations. The single invariant that controls almost everything is the discriminant . This includes which integers a form can represent, how many essentially different forms exist with a given behavior, and how forms relate to each other. The big picture is this: instead of studying one Diophantine equation at a time, we study the whole family of forms sharing a discriminant. We ask how they relate under integer-linear changes of variable. Two forms connected by such a substitution represent exactly the same set of integers. So the substitutions partition all forms of a fixed discriminant into classes. This foreshadows the deeper theory of equivalence and reduction. There, each class acquires a canonical simplest representative. The number of classes (the class number) becomes a fundamental arithmetic invariant. It ties to unique factorization in quadratic fields and to the solvability of Pell's equation. This article lays the foundations: the precise definition of a binary quadratic form, its discriminant, the notion of an integer "represented" by a form, and the basic structural theorem. That theorem shows equivalent forms represent identical sets of integers. We prove everything from scratch, work through two concrete numerical examples, and show exactly why each hypothesis in the main theorem is needed.
- A binary quadratic form is with .
- Its discriminant controls the form's qualitative behavior (definite vs. indefinite).
- An integer is represented by if has an integer solution; representation is primitive if .
- Integer linear substitutions with determinant transform a form into an equivalent form.
- Equivalent forms represent exactly the same integers, with equal multiplicity of representations.
- (discriminant ) is the simplest case, tying this theory directly to Sums of Two Squares.
- Key idea: the discriminant is an invariant of equivalence classes, and classifying forms by discriminant is the gateway to deeper structure (reduction, class numbers, Pell's equation).
Where this lives today
The theory of binary quadratic forms is the direct classical precursor to the ideal class group of a quadratic number field: a form of discriminant corresponds to an ideal class in the ring of integers of , and Gauss's composition law becomes multiplication of ideal classes. This connection underlies modern algorithmic number theory and cryptography: class groups of imaginary quadratic fields are used in cryptographic protocols (e.g., in some discrete-log-based schemes) precisely because Gauss's composition of forms gives an explicit, efficiently computable group law discovered over two centuries before the cryptographic application existed. In the study of Pell's Equation, the indefinite case shows up directly: solving is equivalent to understanding units in the ring of integers of , which in turn is governed by the equivalence classes of forms of discriminant (or related discriminants). The reduction theory of indefinite forms, building on the equivalence relation introduced here, produces the continued fraction expansion of used to solve Pell's equation explicitly. Beyond pure number theory, quadratic forms with integer coefficients appear in the geometry of numbers (Minkowski's theorem on lattice points, sphere packings via forms like the lattice form), in the theory of modular forms (theta series attached to quadratic forms count representations and are themselves modular forms of weight related to the number of variables), and in coding theory, where lattice quadratic forms control the minimum distance of lattice-based error-correcting codes. The representation problem for forms like also connects to class field theory, characterizing exactly which primes satisfy in terms of congruence conditions modulo invariants built from .
Ask the tutor: How does the reduction algorithm pick a canonical "smallest" form in each equivalence class, and how does that lead to solving Pell's equation?
A binary quadratic form over is a polynomial
in two indeterminates . We write for short. The form is called primitive if . The discriminant of is the integer
Since , every discriminant satisfies or . A form is called:
- definite if (and then takes only values of one sign, or is identically zero only at — see below),
- indefinite if (takes both positive and negative values),
- degenerate if is a perfect square including (in this case factors over into two rational linear forms).
We say represents an integer if there exist with . The representation is primitive if . Two forms and are (properly) equivalent, written , if there is a matrix
such that
Equivalently, is obtained from by the invertible unimodular substitution .
Intuition
Think of a binary quadratic form as a machine: feed it a pair of integers , and it outputs an integer . The question "which integers does represent?" is really asking: as ranges over , what is the image of the machine? For , the image is exactly the set of integers whose prime factorization has every prime appearing to an even power — this is the content of the Sums of Two Squares theorem. Changing the coefficients changes the machine, and generically changes the image completely. The discriminant is best understood through the associated real quadratic curve for fixed , or through completing the square:
When (definite case, assuming ), the right side is a sum of two squares (after scaling), so has a fixed sign for : it behaves like a distorted circle, an ellipse-shaped level set. When (indefinite case) the right side is a difference of squares, and the level curves are hyperbolas — the form takes both positive and negative values, and this is exactly the setting where Pell-type equations live. Equivalence by a unimodular substitution is a change of integer basis for the lattice : it relabels which lattice points we call without changing which values the form actually attains as we range over all of . This is why equivalent forms must represent the same integers — the "machine" is the same machine, just wired to a different coordinate system.
Let and be binary quadratic forms with integer coefficients such that , i.e. there exists an integer matrix
with for all . Then: 1. (Equal discriminant) . 2. (Same represented set) For every integer , represents if and only if represents . 3. (Bijection of representations) There is a bijection between the set of pairs with and the set of pairs with , for every fixed . 4. (Primitivity preserved) is a primitive representation of by if and only if the corresponding pair is a primitive representation of by .
We use direct computation with the substitution matrix, the technique of tracking a unimodular linear change of variables through the quadratic form and through the greatest common divisor.
Setup. Write where . Expand:
Collecting coefficients of gives where
(This is exactly what "" means as an identity of polynomials, so these formulas follow by direct expansion and comparison of coefficients; no further justification is required beyond high-school algebra.)
Part 1: Discriminant invariance. This is a direct algebraic identity. One computes using the formulas above. Rather than expand this laboriously by hand, we use the matrix/determinant formulation, which packages the computation cleanly and rigorously. Associate to the symmetric matrix
so that as a matrix product (with a row vector). Then . The substitution is the linear map where and . Then
so (this matrix is symmetric, matching the symmetric form of , since ). Taking determinants,
since . Multiplying by :
This proves Part 1.
Part 3 (which implies Part 2): bijection of representations. Since , the matrix has an inverse over , namely
using the standard inverse formula and . Crucially, has integer entries because . Moreover , so is again a unimodular integer matrix. Define the map
Because has integer entries, maps into . Because has integer entries, the map also maps into , and it is a genuine two-sided inverse of since . Hence is a bijection. By the defining relation , for any fixed integer :
So restricts to a bijection between
This is exactly the assertion of Part 3.
Part 2 follows immediately from Part 3: the set on the left is nonempty if and only if the set on the right is nonempty (a bijection between two sets exists, in particular, if and only if the sets are simultaneously empty or simultaneously nonempty — a bijection cannot exist between an empty set and nonempty set, and the identity/inverse maps constructed above establish a genuine bijection whenever either side is nonempty). Hence represents if and only if represents .
Part 4: primitivity preserved. Suppose satisfies and corresponds under to , satisfying . We must show . Let . Since and are integer linear combinations of , we have and , so . Conversely let . Using : and (from ), which are integer linear combinations of ; hence and , so . Combining and with (as gcd's, they are unless , a case excluded since then would force degenerate consideration but the divisibility argument holds regardless of sign conventions), we conclude . In particular , proving Part 4.
∎Worked examples
Example 1: An indefinite form and a nontrivial equivalence. Let . Its discriminant is
Since and is not a perfect square, is indefinite and non-degenerate. Apply the unimodular substitution , i.e. , which has determinant . Compute
Expand term by term:
Summing: -coefficient: ; -coefficient: ; -coefficient: . So
Check the discriminant: , matching exactly as Equivalent Forms Represent the Same Integers, with the Same Multiplicities guarantees. Now test representation of . Try : with , . Try : . Try : . Try : . Try : . Try : . Try : . Instead, let us verify representation consistency directly rather than hunt blindly: by the theorem, whatever represents, represents identically. Take in : . Its corresponding -point is applied, but easier: by construction , so at we get , matching our computation above of . This confirms the bijection concretely: , exactly as guaranteed, with the primitive pair (gcd ) mapping to the primitive pair (gcd ), consistent with Part 4.
Example 2: Primitivity and a specific representation for . Consider , discriminant . This form is definite (since and , always, with equality only at ). Does represent ? We seek with . Try : , so . Indeed
Check primitivity: , so this is a primitive representation. Does represent ? Try : , . So , but — also primitive. Try : , , giving with — an imprimitive representation. So has both a primitive representation and an imprimitive one ; this shows a single integer can have representations of both types, and illustrates why Part 4 of the theorem is stated for a specific representation carried across the bijection, not as a blanket statement that " is primitively represented" is an invariant of alone — rather, primitivity of each individual representation is what transports correctly under equivalence. Finally, does represent ? We would need with (no integer solution) or (impossible since ). So is not represented by , foreshadowing the finer theory (to be developed under reduction theory and genus theory) that determines exactly which primes are represented by .
Drop the hypothesis and replace it with a general integer matrix, say , and see the conclusion fail. Let (discriminant ), and let
Define . This is again an integer binary quadratic form, , with discriminant
So already the discriminant is not preserved — confirming why Part 1 of the theorem genuinely needs (we used ; using works equally well by a symmetric argument, but or any value other than breaks it). Worse, the represented sets differ: represents ? No ( is not a sum of two squares, since and appears to an odd power in its own factorization — by Sums of Two Squares). And represents ? We need ; trying fails, gives impossible. So in this instance both happen to fail to represent , but consider : has solutions — genuinely represented. Does have a solution? Yes: , or . So both represent — not yet a contradiction. Try : represents via . Does have integer solutions? Only works (since forces ). So does represent too, coincidentally. The cleanest failure is at the level of the bijection of representations (Part 3), which is what truly requires : the map is injective but not surjective onto (its image misses every point with odd first coordinate, such as ), so it cannot be a bijection. Concretely, is a representation of by that does not correspond to any integer point of under , since . The clean one-to-one correspondence between representations of a fixed integer, which was the heart of the theorem, genuinely collapses once we allow .
Scope, edge cases & common traps
| Situation | What happens | Why |
|---|---|---|
| , | for all , zero only at origin — "positive definite" | completing the square: |
| , | always — "negative definite"; usually studied via | same identity with sign flipped |
| a perfect square (incl. ) | factors into two integer/rational linear forms; representation theory reduces to linear Diophantine analysis | is a difference of squares when is a square |
| , not a square | indefinite, takes both signs, connects to Pell's equation | hyperbola-shaped level sets, as in the figure |
| is imprimitive; every value represented is divisible by that gcd | factor with primitive |
The mathematician behind it
Origins · 1 minCarl Friedrich Gauss and how this was discovered
Gauss developed the systematic theory of binary quadratic forms — equivalence, reduction, composition, and genus theory — as a central pillar of the Disquisitiones Arithmeticae, published when he was 24. Building on earlier work of Fermat, Euler, Lagrange, and Legendre on specific forms like , Gauss gave the first fully rigorous and general treatment: he proved the finiteness of the class number for each discriminant, defined the composition law making equivalence classes into what we now recognize as a finite abelian group, and introduced genus theory to organize classes further. This work directly anticipates the theory of ideal classes in quadratic number fields, developed later by Dedekind and Kummer, and remains a standard entry point into algebraic number theory.
What exactly counts as a "binary quadratic form"?
A binary quadratic form is any homogeneous degree-two polynomial in two variables with integer coefficients, written . "Binary" refers to the two variables , and "quadratic" to the total degree in each monomial. The word "form" in classical number theory specifically denotes such a homogeneous polynomial, as opposed to an inhomogeneous polynomial like . The coefficients can be any integers, including zero or negative values, and the form need not be primitive (i.e., can exceed ), though primitive forms are often the main object of study since imprimitive ones reduce to primitive ones after factoring out the common divisor.
Why does the discriminant have to be congruent to 0 or 1 mod 4?
Because , and always, we get . Squares modulo are only (when is even) or (when is odd), since and . Hence every discriminant of an integer binary quadratic form satisfies or , and conversely every such is realized by some form (e.g., if , or if ). This congruence restriction exactly matches the discriminant congruences that arise for rings of integers of quadratic fields .
Is every integer represented by some binary quadratic form of a given discriminant?
Not necessarily by a specific form, but this article's theorem shows representability is shared across an entire equivalence class. Whether a particular integer is represented by forms of discriminant at all is governed by deeper criteria (quadratic residue conditions on modulo , and eventually genus theory), which lie beyond this introductory treatment. What is guaranteed here is only the transfer of representability between equivalent forms — if one form of discriminant represents , then every form equivalent to it also represents , with an explicit bijection between the representations.
How does this generalize the theorem on sums of two squares?
The classical theorem on Sums of Two Squares is precisely the representation theory of the single form , which has discriminant . The binary quadratic forms framework asks the analogous question for every discriminant simultaneously: for we study (among other forms of that discriminant), for we study , and so on. The general machinery of equivalence, reduction, and genus theory (developed after this article) provides the tools to answer these representation questions uniformly, generalizing the specific congruence-based criterion (primes ) that characterizes sums of two squares.
What is the difference between "equivalent" forms and forms that merely represent the same integers?
Equivalence, as defined here via a unimodular substitution, is a strictly stronger and more structured relation than merely representing the same set of integers. Equivalent forms always represent the same integers (this article's theorem), but it is conceivable — and indeed occurs — that two inequivalent forms of different discriminants, or even the same discriminant, represent overlapping or even identical sets of integers without being related by any unimodular substitution. Equivalence tracks an actual algebraic correspondence between the forms as objects (matrices, up to -conjugation of the associated symmetric matrix), which is much more rigid than agreement of represented sets alone.
Why require specifically, rather than allowing as well?
Conventions differ across textbooks. Requiring defines proper equivalence, the finer relation used in Gauss's original class group construction, because it corresponds to orientation-preserving changes of basis and yields exactly the composition law making equivalence classes into a group. Allowing defines the coarser improper equivalence (sometimes just called equivalence), under which a form and its "mirror" can become identified. Both relations preserve the discriminant and the represented set (the proof given here works verbatim for too, since regardless of sign), but only proper equivalence gives the group structure central to class number theory.
Can a binary quadratic form represent zero nontrivially, i.e. at a point other than the origin?
Yes, exactly when the discriminant is a perfect square (including ). In that case factors as a difference of squares over the integers (when is a perfect square), so factors into two integer linear forms, and setting one factor to zero gives nontrivial solutions to . When is negative, forces by the positive/negative definiteness argument from completing the square. When but not a perfect square, also forces , since otherwise would be forced to be rational, a contradiction.