Section18.1Three questions
There are three types of questions we'll spend a lot of time with on functions. Namely, we wish to find formulas, find relations, and connect with limits.
So let's start by letting \(r(n)\) be the number of (all!) ways to write \(n\) as a sum of (two) squares and then ask questions of this function. For instance, \(r(25)=12\). Why? Because you can write it using the pairs \[(\pm 3,\pm 4),\; \; (\pm 4,\pm 3),\;\; (\pm 5,0)\text{ and }(0,\pm 5)\; .\] In this case, we count all solutions, positive or negative, and in any particular order possible, in determining the value of \(r(n)\).
Subsection18.1.1Formulas
As we had hoped for earlier, the function \(r\) has a formula. To see what it looks like, let's write primes of the form \(4k+1\) as \(p\), and primes of the form \(4k+3\) as \(q\).
To use this, notice that the empty product (no primes of the form \(4k+1\)) is 1, just like a sum over zero elements is zero. For instance, we can recover our result from the exercises that \(r(2^n)=4\) from this because all \(e_i\) and \(f_j\) are zero, so we just get \(4\cdot 1\).
Unfortunately, it turns out that every single proof of this is not very elementary. They all either go into some detail regarding factorization of Gaussian integers, or do some lengthy divisibility and congruence analysis. So we will skip them.
Remark18.1.2
Sage note:
You can use various tools we've already seen to compute this with Sage, such as factoring and multiplication. Try it!
Subsection18.1.2Relations
You may recall that there were some relations among values of \(\phi(n)\). One of these was that \(\phi(5)\phi(3)=\phi(15)\), since the entries are coprime. Similarly, there are some relations with multiplying for \(r\).
Indeed, now that we have a formula, that is nearly immediate. But it doesn't always work.
- For instance, \[r(3)r(5)=r(15)\] because both sides are zero!
- On the other hand, \[r(25)r(13)=12\cdot 8=24=r(325)\]
- Similarly, \[r(25)r(4)=12\cdot 4=48\neq 12=r(100)\; .\]
Remark18.1.3
Sage note:
Feel free to explore here!
Subsection18.1.3To the limit
A more compelling reason to bring this function up is that we can use \(r(n)\) to talk about limits with functions. Yes, limits in number theory!
The following graphic has as its basic content the circle with radius \(\sqrt{n}\) and blue lattice points representing all pairs \((x,y)\) such that \(x^2+y^2\leq n\). There is a little box of area one around each such lattice point; as you might expect, the boxes roughly cover the circle, but certainly not exactly.
What does this have to do with \(r(n)\)?
The total number of representations of any integer less than or equal to \(n\) can be thought of as the area of unit boxes around each lattice point giving the representation, and this number would be \[\sum_{k=0}^{n}r(k)\, .\] So the area of the boxes can give us information about \(r\).
As we noted, they neither cover nor are covered by the circle in question. However:
- These boxes will entirely cover a disk of radius \(\sqrt{n}\) minus half the diagonal length of the boxes, namely \(\frac{1}{\sqrt{2}}\), which is the inner circle above.
- Likewise, they are completely contained in a disk of radius \(\sqrt{n}\) plus half the diagonal length of the boxes.
Using these two pieces of information, in terms of area covered, \[\pi \left(\sqrt{n}-\frac{1}{\sqrt{2}}\right)^2\leq \sum_{k=0}^{n}r(k)\leq \pi \left(\sqrt{n}+\frac{1}{\sqrt{2}}\right)^2\, , \] which simplifes, if we divide by \(n\), to \[\pi \frac{n-\sqrt{2n}+1/2}{n}\leq \frac{1}{n}\sum_{k=0}^{n}r(k)\leq \pi \frac{n+\sqrt{2n}+1/2}{n}\, ,\] which yields \[\pi \left(1-\sqrt{\frac{2}{n}}+\frac{1}{2n}\right)\leq \frac{1}{n}\sum_{k=0}^{n}r(k)\leq \pi \left(1+\sqrt{\frac{2}{n}}+\frac{1}{2n}\right)\, .\]
- Since the limit as \(n\) goes to \(\infty\) of the lower and upper bounds with each of these inequalities outside guys exists and is \(\pi\);
- And since removing one term from the sequence won't affect the limit as it's an average;
- Then the beloved squeeze theorem from calculus implies that \[\lim_{n\to\infty}\frac{1}{n}\sum_{k=1}^{n}r(k)=\pi\, .\]
We can interpret this as saying:
Fact18.1.4
The average number of representations of a positive integer as a sum of squares is \(\pi\).WHAT?!
But it's true. And there's more to come.