Sums of Two Squares Ways

In the Fun Fact Sums of Two Squares, we’ve seen which numbers can be written as the sum of two squares. For instance, 11 cannot, but 13 can (as 32+22). A related question, with a surprising answer, is: on average, how many ways can a number can be written as the sum of two squares?

We should clarify what we mean by average. Let W(N) is the number of ways to write N as the sum of two squares. Thus W(11)=0, and W(13)=8 (as sums of squares of all possible combinations of +/-3 and +/-2 , in either order).

So if A(N) is the average of the numbers W(1), W(2), …, W(N), then A(N) is the average number of ways the first N numbers can be written as the sum of two squares. Then it makes sense to take the limitof A(N) as N goes to infinity to get the “average” number of ways to write a number as the sum of two squares, over all positive whole numbers.

A surprising fact is that this limit exists, and it is Pi!

Presentation Suggestions:
This might be presented after a discussion of lattice points in Pick’s Theorem.

The Math Behind the Fact:
The proof is as neat as the result! Every solution (x,y) to x2+y2=N can be thought of as a lattice point in the plane, i.e., a point with integer coordinates. Such a lattice point lies on a circle of radius Sqrt(N).

Therefore, the sum of W(1) through W(N) counts the number of lattice points in the plane inside or on a circle of radius Sqrt(N) (except for the origin), and the average A(N) is this number of lattice points divided by N. But as N goes to infinity, the number of lattice points inside this circle is approximately the area of the circle, hence Pi times the radius squared: Pi*Sqrt(N)2 or Pi*N. Therefore A(N) is approximately Pi, and this approximation gets better and better as N goes to infinity!

Counting the the number of lattice points inside a circle is known as Gauss’ circle problem. Also, see several other Fun Facts about sums of two squares or formulas for pi.

How to Cite this Page: 
Su, Francis E., et al. “Sums of Two Squares Ways.” Math Fun Facts. <https://www.math.hmc.edu/funfacts>.

Fun Fact suggested by:
Darryl Yong

Did you like this Fun Fact?

Click to rate it.

Average rating 4.1 / 5. Vote count: 16

No votes so far! Be the first to rate this Fun Fact

Share: