This is written during the flight from Hong Kong to Frankfurt.

In the previous articles, we investigate the number of ways to express integers as a sum of two squares, so one would naturally ask how frequently are integers expressible as a sum of two squares. In other words, we hope to investigate the asymptotic behavior of the following function:

N(x)=nxa,bZ s.t. n=a2+b21=nxr(n)>01.(1)N(x)=\sum_{\substack{n\le x\\\exists a,b\in\mathbb Z\text{ s.t. }n=a^2+b^2}}1=\sum_{\substack{n\le x\\r(n)>0}}1.\tag1

By the definition of r(n)r(n), we see that the Dirichlet series associated with N(x)N(x) can be expressed as a product of primes as follows

F(s)=n1r(n)>01ns=p1(4)(11ps)1p3(4)(11p2s)1.(2)F(s)=\sum_{\substack{n\ge1\\r(n)>0}}{1\over n^s}=\prod_{p\equiv1(4)}\left(1-{1\over p^s}\right)^{-1}\prod_{p\equiv3(4)}\left(1-{1\over p^{2s}}\right)^{-1}.\tag2

Typically, we hope to associate F(s)F(s) with ζ(s)\zeta(s) or L(s,χ)L(s,\chi) as in the previous article so that we perform contour integration tricks on the estimation of N(x)N(x).

Basic properties of F(s)F(s)

If we were to square both sides, then we see that

F2(s)=p1(4)(11ps)1p3(4)(1+1ps)1×p1(4)(11ps)1p3(4)(11ps)1p3(4)(11p2s)1=ζ(s)L(s,χ4)(112s)p3(4)(11p2s).\begin{aligned} F^2(s) &=\prod_{p\equiv1(4)}\left(1-{1\over p^s}\right)^{-1}\prod_{p\equiv3(4)}\left(1+{1\over p^s}\right)^{-1} \\ &\times\prod_{p\equiv1(4)}\left(1-{1\over p^s}\right)^{-1}\prod_{p\equiv3(4)}\left(1-{1\over p^s}\right)^{-1}\prod_{p\equiv3(4)}\left(1-{1\over p^{2s}}\right)^{-1} \\ &=\zeta(s)L(s,\chi_4)\left(1-{1\over2^s}\right)\prod_{p\equiv3(4)}\left(1-{1\over p^{2s}}\right). \end{aligned}

Obviously, we see that the last product converges absolutely on (s)>12\Re(s)>\frac12. In order to obtain bounds for F(s)F(s) helpful for contour integration, we need to take a detour to logζ(s)\log\zeta(s) and logL(s,χ4)\log L(s,\chi_4).

De la Vallée Poussin's region

Although logarithm is multi-valued, logζ(s)\log\zeta(s) and logL(s,χ4)\log L(s,\chi_4) are well-defined whenever ss lies in their zero-free region within the right half plane. In fact, de la Vallée Poussin had proven in 1896 that

There exists a constant c>0c>0 such that ζ(s)\zeta(s) and L(s,χ4)L(s,\chi_4) are free of zeros in

σmax(12+δ,1clogτ),τ=max(t,4).(3)\sigma\ge\max\left(\frac12+\delta,1-{c\over\log\tau}\right),\quad\tau=\max(\vert t\vert ,4).\tag3

In 1913, Gronwall showed that when ss lies in the region described by (3), the following estimate

logζ(s)loglogτ+O(1).(4)\vert \log\zeta(s)\vert \le\log\log\tau+O(1).\tag4

is valid when ss is away from 1. As shown in Montgomery & Vaughan's Multiplicative Number Theory I: Classical theory, (4) is also valid when ζ(s)\zeta(s) is replaced by L(s,χ4)L(s,\chi_4), which indicates that whenever ss lies in the same region as (3), F(s)F(s) satisfies

F(s)e2loglogτ+O(1)p3(4)(11p1+2δ)1/2=O(log2τ).(5)\vert F(s)\vert\le e^{2\log\log\tau+O(1)}\prod_{p\equiv3(4)}\left(1-{1\over p^{1+2\delta}}\right)^{-1/2}=O(\log^2\tau).\tag5

The bound (5) is sufficient for us to estimate contour integrals over F(s)F(s) along line segments lying within (3). Therefore, let's bring in Perron's formula.

Contour integration and error estimates

Using Perron's formula, we see that whenever a=1+(logx)1a=1+(\log x)^{-1} and 4Tx4\le T\le x there is

N(x)=12πiaiTa+iTF(s)xssds+O(xlogxT)(6)N(x)={1\over2\pi i}\int_{a-iT}^{a+iT}F(s){x^s\over s}\mathrm ds+O\left(x\log x\over T\right)\tag6

Because F(s)F(s) behaves like (s1)1/2(s-1)^{-1/2} when ss approaches one, we cannot handle the integral via residue theorem. Instead, we deform the path [aiT,a+iT][a-iT,a+iT] into

aiTa+iT=aiT1kiT+1kiT1kiε+C+1k+iε1k+iT+1k+iTa+iT,\int_{a-iT}^{a+iT}=\int_{a-iT}^{1-k-iT}+\int_{1-k-iT}^{1-k-i\varepsilon}+\int_C+\int_{1-k+i\varepsilon}^{1-k+iT}+\int_{1-k+iT}^{a+iT},

where k=c(logT)1k=c(\log T)^{-1} and CC denote some path that begins from 1kiε1-k-i\varepsilon, surrounds s=1s=1 counter-clockwise, and finally goes to 1k+iε1-k+i\varepsilon. For integrals other than CC, plugging (5) in gives

aiT1kiT+1k+iTa+iTxlog2TTxlog2xT(7)\int_{a-iT}^{1-k-iT}+\int_{1-k+iT}^{a+iT}\ll{x\log^2T\over T}\le{x\log^2x\over T}\tag7

and

1kiT1kiε+1k+iε1k+iTx1k(logT)3x1k(logx)3.(8)\int_{1-k-iT}^{1-k-i\varepsilon}+\int_{1-k+i\varepsilon}^{1-k+iT}\ll x^{1-k}(\log T)^3\le x^{1-k}(\log x)^3.\tag8

Setting logT=logx\log T=\sqrt{\log x} and combining (6), (7), and (8), we see that there exists some c0>0c_0>0 such that

N(x)=x2πiCF(s)xs1sdxI+O(xec0logx).(9)N(x)={x\over2\pi i}\underbrace{\int_CF(s){x^{s-1}\over s}\mathrm dx}_I+O(xe^{-c_0\sqrt{\log x}}).\tag9

Thus, the remaining task is to compute the integral along the path CC, which presumably becomes the main term of N(x)N(x).

The main term of N(x)N(x)

Let C1C_1 denote the path CC shifted one unit to the left. Then we have

I=C1u1/2xuh(u+1)du,I=\int_{C_1}u^{-1/2}x^uh(u+1)\mathrm du,

where it is evident that h(u+1)=u1/2F(u+1)/(u+1)h(u+1)=u^{1/2}F(u+1)/(u+1) is obivously analytic in and on CC. To calculate II further, we deform C1C_1 into a truncated Hankel contour:

I=eiπkiεiε+γ+iεeπisk+iε,(10)I=\int_{e^{-i\pi}k-i\varepsilon}^{-i\varepsilon}+\int_\gamma+\int_{i\varepsilon}^{e^{\pi is}k+i\varepsilon},\tag{10}

where γ\gamma denotes a counterclockwise arc connecting iε-i\varepsilon and iεi\varepsilon, so letting ε0+\varepsilon\to0^+, (10) becomes

I=(eπi/2eπi/2)0kv1/2xvh(1v)dv.(11)I=(e^{\pi i/2}-e^{-\pi i/2})\int_0^kv^{-1/2}x^{-v}h(1-v)\mathrm dv.\tag{11}

Due to the analyticity of h(1v)h(1-v) near v=0v=0, we see that it admits an asymptotic expansion:

h(1v)=a0+a1v+a2v2++aN1vN1+O(vN),h(1-v)=a_0+a_1v+a_2v^2+\dots+a_{N-1}v^{N-1}+O(\vert v\vert ^N),

so (11) becomes

I=2i0n<Nan0kvn1/2xvdv+O(0vN12xudu)=2i0nNan(logx)n+1/20clogxyn1/2eydy+O(1logN+1/2x).(12)\begin{aligned} I &=2i\sum_{0\le n<N}a_n\int_0^kv^{n-1/2}x^{-v}\mathrm dv+O\left(\int_0^\infty v^{N-\frac12}x^{-u}\mathrm du\right) \\ &=2i\sum_{0\le n\le N}{a_n\over(\log x)^{n+1/2}}\int_0^{c\sqrt{\log x}}y^{n-1/2}e^{-y}\mathrm dy+O\left(1\over\log^{N+1/2}x\right). \end{aligned}\tag{12}

This suggests that the main term of N(x)N(x) is in fact expressed as some asymptotic series. Plugging (12) back into (9), we conclude that there exists a sequence bn=anΓ(n+12)/πb_n=a_n\Gamma(n+\frac12)/\pi such that

N(x)Kxlogx(1+b1logx+b2log2x+b3log3x+),(13)N(x)\sim{Kx\over\sqrt{\log x}}\left(1+{b_1\over\log x}+{b_2\over\log^2x}+{b_3\over\log^3x}+\dots\right),\tag{13}

where K=a0/πK=a_0/\sqrt\pi is called the Landau-Ramanujan constant. This indicates that the density of integers expressible as a sum of two squares is zero, but these types of integers are not so rare as primes (PNT gives x/logx\sim x/\log x). In the remaining part of this article, we develop analytical expressions for KK.

The value of Landau-Ramanujan constant

By definition, we know that a0=h(1)a_0=h(1) is exactly the limit of (s1)1/2F(s)(s-1)^{1/2}F(s) as s1s\to1, which means

a0=L(1,χ4)2p3(4)(11p2)1/2,a_0=\sqrt{L(1,\chi_4)\over2}\prod_{p\equiv3(4)}\left(1-{1\over p^2}\right)^{-1/2},

so it follows from the fact that L(1,χ4)=π/4L(1,\chi_4)=\pi/4 there is

K=122p3(4)(11p2)1/2.(14)K={1\over2\sqrt2}\prod_{p\equiv3(4)}\left(1-{1\over p^2}\right)^{-1/2}.\tag{14}

Using the properties of L(s,χ4)L(s,\chi_4), we see that

p3(4)(11p2s)1=L(s,χ4)p1(4)(11ps)p3(4)(11ps)1=L(s,χ4)p>21(1+χ4(p))/2ps1(1χ4(p))/2ps.\begin{aligned} \prod_{p\equiv3(4)}\left(1-{1\over p^{2s}}\right)^{-1} &=L(s,\chi_4)\prod_{p\equiv1(4)}\left(1-{1\over p^s}\right)\prod_{p\equiv3(4)}\left(1-{1\over p^s}\right)^{-1} \\ &=L(s,\chi_4)\prod_{p>2}{1-(1+\chi_4(p))/2p^s\over1-(1-\chi_4(p))/2p^s}. \end{aligned}

Consequently, we obtain another expression for KK:

K=π42p>2p(1+χ4(p))/2p(1χ4(p))/2.(15)K={\pi\over4\sqrt2}\prod_{p>2}{p-(1+\chi_4(p))/2\over p-(1-\chi_4(p))/2}.\tag{15}

Conclusion

In this article, we investigated the distribution of numbers that are a sum of two squares using the contour integration method. However, the case we study today is fundamentally different from those we have researched in the past.

Instead of calculating a residue integral as in the past, we see that the main term of N(x)N(x) is obtained by calculating a certain integral over a truncated Hankel contour.

Notes

In this article, the analytic continuation of F(s)F(s) is achieved by factoring a square root of ζ(s)\zeta(s). In the 1950s, mathematicians Selberg and Delange developed ambitious generalizations of the method mentioned in this article. Particularly, they show that if there exists some complex zz such that [ζ(s)]zF(s)[\zeta(s)]^{-z}F(s) is analytic and O(τ1δ)O(\tau^{1-\delta}) in the region described in (3), then there exists a sequence n\ell_n such that the summatory function of the coefficients of F(s)F(s) is asymptotic to

x(logx)z1{0+1logx+2log2x+3log3x}.\sim x(\log x)^{z-1}\left\{\ell_0+{\ell_1\over\log x}+{\ell_2\over\log^2x}+{\ell_3\over\log^3x}\right\}.

For a detailed account of this result, consult §II.5.3 of Tenenbaum's Introduction to Analytic and Probabilistic Number Theory.