Quadratic forms

Lessons from linear forms

The set of numbers that the linear form ax+byax+by represents is completely determined by an invariant called the gcd of aa and bb, (a,b)(a,b). Two of these linear forms represent the same set of numbers (are "equivalent") if the gcd of the two numbers is the same.

To better understand the binary quadratic forms ax2+bxy+cy2ax^2 + bxy + cy^2 it would be good to define a notion of equivalence and try to find an invariant. The invariant is called the discriminant of the form and even though it doesn't tell apart every single QF it is a key object in the theory.

Equivalence

Originally I wanted to define two forms to be equivalent if they represent the same set of numbers. It turns out this isn't the correct notion of equivalence. All the texts on quadratic forms define equivalence as the forms being related by a "change of variables", technically a linear transform with determinant 1. With that definition it's obvious that equivalent forms represent the same set of numbers - but the converse does not hold. I'll write about that at the end.

Invariant

The determinant of the matrix is an obvious invariant, scale it up by 44 to make it an integer and we have the discriminant of the form: D=4acb2D = 4ac - b^2.

A counterexample

Take the forms:

E(x,y)=x2+xy+y2E(x,y) = x^2 + xy + y^2 U(u,v)=u2+3v2U(u,v) = u^2 + 3v^2

they have different discriminants (the discriminant of EE is 3 and the discriminant of UU is 12) so they can never be equivalent.. but they represent the same numbers e.g.

1729=252+2523+232=12+32421729 = 25^2 + 25\cdot 23 + 23^2 = 1^2 + 3\cdot 24^2

first U(u,v)=E(uv,u+v)U(u,v) = E(u-v,u+v) so EE can represent everything UU can. Now to prove that UU can represent everything EE can let x2+xy+y2=nx^2 + xy + y^2 = n and (we can assume x,yx,y are coprime by dividing out the square of their gcd) then there are 3 cases to consider:

The first two cases were solved by considering the quadratic field factorizations:

E(x,y)=(x+ωy)(x+ω¯y)E(x,y) = (x + \omega y)(x + \bar\omega y) U(u,v)=(u+3v)(u3v)U(u,v) = (u + \sqrt{3}v)(u - \sqrt{3}v)

where ω=1i32\omega = \frac{1 - i \sqrt{3}}{2}, ω¯=1+i32\bar \omega = \frac{1 + i \sqrt{3}}{2}.

rewriting EE like this: E(x,y)=((x+12y)+i32y)((x+12y)i32y)=(x+12y)2+3(12y)2E(x,y) = ((x + \tfrac{1}{2}y) + \frac{i \sqrt{3}}{2}y)((x + \tfrac{1}{2}y) - \frac{i \sqrt{3}}{2}y) = (x + \tfrac{1}{2}y)^2 + 3(\tfrac{1}{2}y)^2

suggests

which works. In the case that both are odd we can directly solve the system

to get

which also works.

this completes the proof that the forms take on all the same values.

Code

For testing I coded up the isomorphism and checked it really worked for many small values

q1 x y = x^2 + x*y + y^2
q2 u v = u^2 + 3*v^2

alg1 x y = (g * u, g * v)
 where n = q1 x y
       g = gcd x y
       (x', y', n') = (x `div` g, y `div` g, n `div` (g^2))
       (u, v) = case () of
        () | even x' && odd y' -> (y' + x' `div` 2, x' `div` 2)
        () | odd x' && even y' -> (x' + y' `div` 2, y' `div` 2)
        () | odd x' && odd y' -> ((x' - y') `div` 2, (x' + y') `div` 2)

test ns = [ (x,y) | x <- ns, y <- ns, (u, v) <- [alg1 x y], q1 x y /= q2 u v ]

Another counterexample

J(x,y)=x2+xyy2J(x,y) = x^2 + xy - y^2 K(x,y)=x2+5y2K(x,y) = x^2 + 5y^2

End

This was a really unexpected result to me. Now I have a lot more interesting stuff to learn about quadratic forms!