I was reading Stillwell's Mathematics and its History, where Lagrange's theory of quadratic forms is synoptically presented, and I was wondering of what are the direct predecessors of the theory.
Specifically, I am interested in the possible results that inspired him to investigate the discriminant, equivalency and the composition of quadratic forms in order to resolve number-theoretic conjectures.