# What is the density of integers of the form $a^2+nb^2$?

Landau proved that the mean density of integers of the form $a^2+b^2$ up to $x$ is $K\frac{x}{\sqrt{\log x}} (1+o(1))$, where $K$ is an explicit constant. One proof is based on the fact that a prime $p$ is of this form iff $p\neq 3\mod 4$, and so we can express the generating function for these integers in terms of the zeta function and the $L$-function of the non-trivial character modulo $4$. From there one proceed using complex analysis.

For integers of the form $a^2 + nb^2$, one should have similar results. We know what primes has this form by class field theory, and then in principle one can continue as before.

I am sure this is classical, but unfortunately I've failed to find it in the literature (including google). Does anyone know a reference for this?

Yes there is quite a bit in the literature on this problem. Apparently it was first solved by Bernays in his 1912 PhD thesis under Landau. The density is as expected (namely proportional to $x/\sqrt{\log x}.$)

A modern paper on the topic is:

Brink, Moree, Osburn - Principal forms $X^2+nY^2$ representing many integers.

This contains many useful references about the history of the problem.

R. W. K. Odoni has his own proof of the theorem, see this paper on the problem,

"On norms of integers in a full module of an algebraic number field and the distribution of values of binary integral quadratic forms",

published in Mathematika 22 (1975), no. 2, 108–111. See Narkiewicz's review. Odoni's paper does not appear in the paper mentioned by Daniel.

The concluding remarks in Odoni's paper are very interesting and refer to some earlier partial results.