# Distribution of binary quadratic forms in a given genus

It was brought up in this question (Distribution of 'square classes' of binary quadratic forms) that the objects I am interested in are actually binary quadratic forms in the principal genus of its discriminant.

One can then formulate he following question. Consider the set of integral points

$$\displaystyle \{(a,b,c) \in \mathbb{Z}^3 : \max\{|a|, |b|, |c|\} \leq X\}$$

and the map $$\rho$$ from $$\mathbb{Z}^3$$ to the lattice of integral binary quadratic forms sending $$(a,b,c)$$ to $$ax^2 + bxy + cy^2$$.

We say an integral binary quadratic form is in the principal genus of discriminant $$d$$ if it is $$\text{GL}_2(\mathbb{R})$$-equivalent to the principal form of discriminant $$d$$ and it is $$\text{GL}_2(\mathbb{Z}_p)$$-equivalent to the principal form for every prime $$p$$.

What is the asymptotic size of the following two sets?

$$\displaystyle S(X) = \{(a,b,c) \in \mathbb{Z}^3 : \rho(a,b,c) \text{ is in the principal genus}, \max\{|a|, |b|, |c|\} \leq X\}$$

and

$$\displaystyle S_a(X) = \{(b,c) \in \mathbb{Z}^2: \rho(a,b,c) \text{ is in the principal genus}, \max\{|b|, |c|\} \leq X\}$$