Posted by: holdenlee | June 3, 2011

Number Theory and Pi

In this post we give a number theory proof of the following identity


(Prerequisite: knowing how factoring works in \mathbb Z[i].)

Step 1: Approximate the sum with a finite sum.

We claim that

1-\frac13+\frac 15-\cdots=\lim_{N\to \infty} \frac 1N\left(\left\lfloor \frac N1\right\rfloor-\left\lfloor \frac N3\right\rfloor+\left\lfloor \frac N5\right\rfloor-\cdots\right).

(Bear with me… this is the most technical part of the proof.) Indeed, we have

(Note we used the trivial bound 2 on each term in the first sum and telescoped the last sum.)

Step 2:

\frac 1N\left(\left\lfloor \frac N1\right\rfloor-\left\lfloor \frac N3\right\rfloor+\left\lfloor \frac N5\right\rfloor-\cdots\right)=\sum_{n=1}^N (d_1(n)-d_3(n))

where d_k(n) denotes the number of divisors of n that are congruent to k modulo 4.

Indeed, the LHS equals

\sum_{n\equiv 1\pmod 4} \left\lfloor \frac Nn\right\rfloor -\sum_{n\equiv 3\pmod 4}\left\lfloor \frac N{n}\right\rfloor.

The term \left\lfloor\frac Nn\right\rfloor counts the number of multiples of n less than N, so \sum_{n\equiv 1\pmod 4} \left\lfloor \frac Nn\right\rfloor counts the number of pairs (n,n') where n\equiv 1\pmod 4 and n'\le N is a multiple of n. Summing the number of such pairs over n' instead we get \sum_{n'\le N} d_1(n'). Similarly, \sum_{n\equiv 3\pmod 4}\left\lfloor \frac N{n}\right\rfloor=\sum_{n'\le N} d_3(n').

Step 3: 4(d_1(n)-d_3(n)) is the number of integer solutions to x^2+y^2=n.

One proof of this uses Jacobi’s triple product identity (see We give a proof using Gaussian integers.

Each solution to x^2+y^2=n corresponds to a factoring (x+yi)(x-yi)=n over the Gaussian integers \mathbb Z[i]. Thus the number of solutions is the number of z such that z\bar{z}=n, or 4 times the number of nonassociated z\in \mathbb Z[i] such that z\bar{z}=n. (Two Gaussian numbers are associated if they differ by a unit \pm 1, \pm i, so x+yi, -y+xi, -x-yi, y-xi are considered the same.)

Now factor n=2^ap_1^{b_1}\cdots p_k^{b_k}q_1^{c_1}\cdots q_m^{c_m} where p_j and q_j are primes congruent to 1, 3 modulo 4, respectively. From knowledge of factoring in \mathbb{Z}[i] we know that

  1. 2 ramifies in \mathbb Z[i], that is, it is the product of two associated primes 1+i,1-i.
  2. The p_j\equiv 1\pmod 4 split, that is, p_j=z_j\bar{z_j} where z is prime in \mathbb{Z}[i] and not associated to \bar z.
  3. The q_j\equiv 3\pmod 4 remain prime.

Now if z\bar z=n and a Gaussian prime divides z, then its conjugate must divide \bar z. Thus, since we have unique factorization in \mathbb{Z}[i], each such z, up to multiplication by associates, corresponds to a way of splitting the prime factors of n into complex conjugate pairs. We note the following:

  1. The factors q_j are their own conjugates, so z and \bar z must each get q_j^{c_j/2}. If one of the c_j is odd there is no solution. So we suppose they are all even.
  2. It doesn’t matter how the prime factors of 2^a are split since they are all associates.
  3. There are b_j+1 ways to split the factors of q_j^{b_j}, since we can have either z_j^{b_j}, or z_j^{b_j-1}\bar{z_j},… or \bar z_j^{b_j} divide z. Thus there are (b_1+1)\cdots (b_k+1) solutions to z\bar z=n up to associates.

Now if c_k is odd, then the number of factors that are congruent to 1 or 3 modulo 4 are the same: Indeed, for every factor d having an even power of q_k, we can pair it up with the factor dq_k, and these two factors are different modulo 4.

If all the c_k are even, then we claim (b_1+1)\cdots (b_k+1)=d_1(n)-d_3(n). We induct on the number of 3-mod-4 factors m. For the case m=0, all odd factors of N=2^ap_1^{b_1}\cdots p_m^{b_m} are 1 mod 4, and N has (b_1+1)\cdots (b_k+1) odd factors. For the induction step, note that each 1-mod-4 factor of N is obtained by multiplying an even power of q_m (there are \frac{c_j}{2}+1 choices since c_j is even) by a 1-mod-4 factor of \frac n{q_m}, or multiplying an odd power of q_m (there are \frac{c_j}2 choices) by a 3-mod-4 factor. Hence d_1(n)=\left(\frac{c_j}{2}+1\right)d_1\left(\frac n{q_m^{c_m}}\right)+\frac{c_j}{2}d_3\left(\frac n{q_m^{c_m}}\right). We get a similar formula for d_3(n). Thus

by the induction hypothesis.

Thus in either case, the number of solutions to x^2+y^2=n equals the 4(d_1(n)-d_3(n)).

Step 4: Counting lattice points in circles

From step 3, we now know

\sum_{n=1}^N 4(d_1(n)-d_3(n))

is the number of integer solutions to 1\le x^2+y^2\le N, i.e. the number of lattice points in the circle centered at the origin with radius \sqrt N excluding the origin. The area formula for the circle gives that there are around \pi(\sqrt N)^2 lattice points inside, so \lim_{N\to \infty}\frac 1N \sum_{n=1}^N 4(d_1(n)-d_3(n))=\pi, which together with steps 1-2, complete the proof.

Note to make the above geometric argument rigorous, for each lattice point (x,y) in the circle, shade the square with opposite corners (x,y) and (x+1,y+1). Then every point in the circle with radius \sqrt N-\sqrt 2 is shaded (since the square that contains the point is entirely within the original circle) and no point outside the circle with radius \sqrt N+\sqrt 2 is shaded (since the square that contains the point is entirely outside the original circle). The area of the shaded region is f(n)=1+\sum_{n=1}^N 4(d_1(n)-d_3(n)). Hence \pi (\sqrt N-\sqrt 2)^2-1 \le \sum_{n=1}^N 4(d_1(n)-d_3(n))\le \pi (\sqrt N+\sqrt 2)^2-1 which gives the desired after dividing by N and taking the limit.

(Note: The regular calculus proof can be found at



  1. On a deeper level we can see this as a special case of the analytic class number formula. See lecture 3 of and

  2. And step 3 is the identity zeta(s)L(s,(*/4))=zeta_{Q(i)}(s).

  3. […] proved this identity in a post several years ago on Number Theory and Pi. It turns out that this is a special case of a more general identity called the analytic class […]

  4. I am now not sure the place you’re getting your information, however great topic.
    I must spend some time learning much more or understanding more.
    Thank you for fantastic info I was on the lookout for this information for
    my mission.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: