solving for Gauss's composition law I would like to understand more about Gauss's composition law for binary quadratic forms, in particular solve for the constraints explicitly so that I can see at a basic algebra level what is going on. Unfortunately, I can see enough to guess my way to a solution, but cannot figure out how to solve it directly to see all the steps.
Given two binary quadratic forms $f_1, f_2$, we can (under some conditions?) find another binary quadratic form $f_3$ obtained from their "composition"
$$
f_1(w,x)\ f_2(y,z) = f_3(X,Y)
$$
where
$$
\begin{aligned}
f_1(w,x) &= A_1 w^2 + B_1 wx + C_1 x^2 \\
f_2(y,z) &= A_2 y^2 + B_2 yz + C_2 z^2 \\
f_3(X,Y) &= A_3 X^2 + B_3 XY + C_3 Y^2 \\
\begin{bmatrix}X \\ Y \end{bmatrix} &=
  \begin{bmatrix}a & b & c & d \\ e & f & g & h\end{bmatrix}
  \begin{bmatrix}wy \\ wz \\ xy \\ xz \end{bmatrix} \\
\end{aligned}
$$
and all variables are integers.
Expanding out the equation and collecting like terms of $w,x,y,z$ gives nine constraints which can be arranged like so:
$$
\begin{aligned}
A_1\begin{bmatrix}
A_2 \\ B_2 \\ C_2
\end{bmatrix} &=
  \begin{bmatrix}
  a^2 & a e & e^2 \\
  2 a b & (a f + b e) & 2 e f \\
  b^2 & b f & f^2 \\
  \end{bmatrix}
  \begin{bmatrix}
  A_3 \\ B_3 \\ C_3
  \end{bmatrix} \\
B_1 \begin{bmatrix}
A_2 \\ B_2 \\ C_2
\end{bmatrix} &=
  \begin{bmatrix}
  2 a c &(a g + c e) &2 e g \\
  2 (a d + b c) & (a h + b g + c f + d e) & 2 (e h + f g) \\
  2 b d & (b h + d f) & 2 f h \\
  \end{bmatrix}
  \begin{bmatrix}
  A_3 \\ B_3 \\ C_3
  \end{bmatrix} \\
C_1 \begin{bmatrix}
A_2 \\ B_2 \\ C_2
\end{bmatrix} &=
  \begin{bmatrix}
  c^2 & c g & g^2 \\
  2 c d & (d g + c h) & 2 g h \\
  d^2 & d h & h^2 \\
  \end{bmatrix}
  \begin{bmatrix}
  A_3 \\ B_3 \\ C_3
  \end{bmatrix} \\
\end{aligned}
$$
If I look at the determinants of those matrices, they are "suspiciously" factorizable and let me guess what would be "convenient" solutions for $A_1,B_1,C_1,A_2,B_2,C_2$ in terms of $a,b,c,d,e,f,g,h$. If I plug that guess in, it is now possible to solve for $A_3,B_3,C_3$ showing that the guess works.
$$
\begin{aligned}
A_1 &= a f - b e \\
B_1 &= a h - b g + c f - d e \\
C_1 &= c h - d g \\
A_2 &= a g - c e \\
B_2 &= a h + b g - c f - d e \\
C_2 &= b h - d f \\
A_3 &= f g - e h \\
B_3 &= a h - b g - c f + d e \\
C_3 &= b c - a d \\
\end{aligned}
$$
Also, due to the symmetry of the constraints, it is possible to get related solutions by swapping some signs.
At this point I found that this matches the summary given in this answer
https://math.stackexchange.com/a/1948413/746701
And also looks like
https://en.wikipedia.org/wiki/Bhargava_cube
However, since I effectively guessed my way to the solution, I cannot exclude the possibility of other answers. For instance the above suggests all three forms have the same discriminant
$$D = B_1^2 - 4 A_1 C_1 = B_2^2 - 4 A_2 C_2 = B_3^2 - 4 A_3 C_3$$
but it is my understanding that Gauss's initial ideas involved a more general composition law that allowed composition of forms with different discriminants. I guess this could be found from modifying my guessed solution to include extra factors at some points?
But I really just want to see how to get there without guessing. Since I was able to use linear algebra tools to guess my way to the answer, I assume someone more well versed in linear algebra can show how to solve it directly.

  
*
  
*How can we directly solve the 9 constraint equations to get a clear relationship of the variables $A_1,...,C_3$ in terms of $a,b,c,d,e,f,g,h$?
  
*At what point (if ever) do we finally use the fact that we're dealing with integers here? Maybe that is crucial to the steps I'm missing?
  

 A: As explained here, the $A$ coefficient in the composed form is completely specified, but there is always freedom of choice from a collection of $(B,C)$-pairs of coefficients.  There are conventions for this choice.  The cited article mentions the choice where $B$ is the smallest possible positive integer.
Also, the method at the cited article seems less complicated than your method, as long as you are comfortable solving congruences.
A: Have you consulted Disquisitiones Arithmeticae? I use the Arthur A. Clarke translation published by Yale U Press in 1966. In that version the nine constraint equations appear on p.223. Gauss proceeds to make a series of deductions that have always struck me as the paragon of algebraic skill. He leaves out details, but the translator includes some helpers. From these equations, Gauss shows generally that the discriminants of the three forms are in the same class in the group $\mathbb{Q}^{*}/(\mathbb{Q}^*)^2$. More precisely, he shows that the ratio of the discriminant of your $f_1$ or $f_2$ to the discriminant of $f_3$ is the square of a rational number with denominator dividing the the content of $f_2$ and $f_1$, respectively ("content" meaning the gcd of a form's coefficients).
He then shows that the equalities you produced for the coefficients of $f_1$ and $f_2$ are generally proportions with proportionality constants given as the square root of an appropriate ratio of discriminants. In particular, they are equalities when the forms all have the same discriminant.
At the end of that section, on p.239, he declares that conversely, if one sets up the nine propotions mentioned above and treat as unknowns the two discriminant-quotients determining the proportionality constants, then you can deduce the original nine equations. He states this, but says the calculation is left to the reader because it "would be too long to include here." Considering his previous calculation and then his computation of the associative property a few sections later, I shudder to think what "too long" meant to Gauss!
Concerning your second question, the use of integers explicitly seems to make an appearance first when Gauss introduces some auxilliary values: they are triples of coefficients you can use in linear combinations of the form coefficients to obtain the form contents. Perhaps then his results hold generally in a Bezout domain -- I didn't think too hard about that.
An additional deduction that may be of interest: for the relationship between forms you setup, Gauss says that $f_3$ is transformable into $f_1 f_2$. To say that $f_3$ is their composition, he requires that the six 2 by 2 determinants appearing in your expressions for $A_1$, $B_1$, $C_1$, $A_2$, $B_2$, and $C_2$ have gcd=1. Under this assumption, he shows that the content of $f_3$ must be the product of the contents of $f_1$ and $f_2$.
