# Distribution of the Error term in GH Hardy's "curious result" $\sum_{\nu \leq n } \{ \nu \theta \}^2 = \tfrac{1}{12} n + O(1)$

In an early paper, GH Hardy talks about the distribution of "curious" sum:

$$\sum_{\nu \leq n } \{ \nu \theta \}^2 = \tfrac{1}{12} n + O(1)$$

where $\{x\}:=x-\left \lfloor x \right \rfloor -1/2$. With a computer it was not hard to verify the linear growth, the factor of $\frac{1}{12}$ or the constant error term. Here are my experiments:

The line is rather easy to prove with Weyl equidistribution theorem - without the $O(1)$ term.

$$\frac{1}{n}\sum_{\nu \leq n } \{ \nu \theta \}^2 \approx \int_{-\frac{1}{2}}^{\frac{1}{2}} x^2 \, dx = \frac{1}{12}$$

Are there any easy ways to understand the noise? It clearly has no limit... in the figure $\theta = \sqrt{7}$ the $O(1)$ error term is distributed between 0.05 and 0.30 with clear bands at indeterminate values.

Obviously $\theta \notin \mathbb{Q}$ and even then the uncertainty might be too large.

I had computed the Fourier series in order to trace the proof of the Von Neumann ergodic theorem.

We can plot the sum of the sawtooth functions. The first 10 and the first 100 terms. The limit of $\sum_{\nu \leq n} \{ \nu \theta \}^2$ is highly oscillatory but does not converge at some points.

• Is it usual notation? I would think that $\{x\}$ is a fractional part of $x$ and takes values from 0 to 1, while you probably mean that it is the distance to closest integer. Oct 20 '15 at 16:46
• I am on my phone. Here use distance to nearest integer: 2.7 rounds to -0.3 Oct 20 '15 at 18:33
• Are you assuming that $\theta$ is irrational? This seems to be false if $\theta$ is a rational ($\theta=0$ for example). I guess you want the constant also to depend on $\theta$. Oct 20 '15 at 19:50
• Is @EmanueleTron 's edit right? While similar facts are probably true for $x - \lfloor x \rfloor - 1/2$, I thought the OP wanted $x - [x]$.
– user13113
Oct 20 '15 at 20:17
• I bet the short periodic continued fraction is relevant; have you tried a transcendental number?
– user13113
Oct 20 '15 at 21:33

As indicated in Lucia's answer, we can look at the Fourier transform

$$\{ \nu \theta \} ^2 = \frac{1}{12} + \frac{1}{2 \pi^2} \sum_{k \neq 0} \frac{\exp(2 \pi i k \nu \theta)}{k^2}$$

Interchanging the sums gives (barring errors on my part)

$$\sum_{\nu=1}^n \{ \nu \theta \}^2 = \frac{n}{12} + \frac{1}{\pi^2} \sum_{k =1}^{\infty} \frac{1}{k^2} \csc(\pi k \theta) \sin(\pi k n \theta) \cos(\pi k (n+1) \theta)$$

Now, forget that $n$ is a discrete variable, and instead varies continuously. The error term is just a linear combination of offset sine waves, each of which has a period exactly dividing $1 / \theta$.

Consequently, the error term is periodic, and the observed errors should extremely closely resemble the distribution we get from assuming $n$ is a uniformly distributed random variable across one period.

After adding by $0.25$ (since you seem to be taking the sum starting from $\nu=0$), an approximate plot of the first few terms for $\theta = \sqrt{7}$ is:

(obtained from wolframalpha)

From which we should expect the errors to have especially high density near $0.18$, and high density near $0.16$, $0.20$, and near the extremes $0.10$ and $0.26$, and that the errors should have relatively low density in the in-between regions.

This is pretty much exactly what you see from your plot, except for an overall shift, which is probably explained from adding up the average of the tail.

With more precision and taking more terms of the series, we should be able to observe all features of the data.

There are several puzzling things about the question: Firstly of course $\theta$ must be irrational, and it is intended for $\{ x\}$ to denote the Bernoulli polynomial $x-[x]-1/2$ rather than the more usual fractional part. Secondly, where is the result of Hardy from? I did find this statement in the Cambridge ICM paper of Hardy and Littlewood where they write

"While engaged on the attempt to elucidate these questions we have found a curious result which seems of sufficient interest to be mentioned separately. It is that $$\sum_{\nu =1}^{n} \{ \nu \theta\}^2 = \frac{n}{12} +O(1)$$ for all irrational values of $\theta$. When we consider the great irregularity and obscurity of $\ldots$, it is not a little surprising that [this] (and presumably the corresponding sums with higher even powers) should behave with such marked regularity."

Note that Hardy and Littlewood also use $\{x\}$ to denote the Bernoulli polynomial. This is puzzling since it seems completely false if for example $\theta$ is a Liouville number. Indeed then I found a follow up paper of Hardy and Littlewood where they note (see page 36 there)

"We may take this opportunity of correcting a misstatement in our communication to the Cambridge congress $\ldots$. It was stated there that $$\sum_{\nu =1}^{n} \{ \nu \theta\}^2 = \frac{n}{12} +O(1)$$ for every irrational $\theta$. This is untrue; but the equation holds for very general classes of values of $\theta$, and in particular for any $\theta$ whose partial quotients are bounded."

What Hardy and Littlewood had in mind is presumably to write out the Fourier expansion of the Bernoulli polynomial $(x-[x]-1/2)^2 -1/12$ which is $$\frac{1}{2\pi^2} \sum_{k\neq 0} \frac{e^{2\pi i kx}}{k^2},$$ and then sum this over $x = \nu \theta$. From here one can see that what is needed for their result is that if $\Vert k\theta \Vert$ isn't smaller than $k^{-2+\epsilon}$ then the series will converge nicely, but there will be problems for very well approximable numbers. Using the Fourier expansion, for good irrationals (e.g. $\sqrt{7}$) the Fourier expansion shows that the remainder term will have an almost periodic structure.

• The complete works of GH Hardy volume 1. It's one of the first papers. I haven't read the 1922 papers cited, also in that volume. Oct 20 '15 at 21:35
• I assume $[x]$ in this post means floor function, rather than nearest integer?
– user13113
Oct 20 '15 at 21:52
• @Hurkyl: yes, (and it's standard usage.) Oct 20 '15 at 21:53
• ($\lfloor x \rfloor$ for the floor function and $[x]$ for nearest integer is also standard usage)
– user13113
Oct 20 '15 at 21:54
• Ok -- different standards then! Oct 20 '15 at 21:54

This is an approach on the error term. The idea is to use Koksma's inequality and Erdos-Turan inequality. I used this on a problem in MSE: $\sum \frac{(-1)^n|\sin n|}n$. To recall,

Theorem [Koksma]

Let $f$ be a function on $I=[0,1]$ of bounded variation $V(f)$, and suppose we are given $N$ points $x_1, \ldots , x_N$ in $I$ with discrepancy $$D_N:=\sup_{0\leq a\leq b\leq 1} \left|\frac1N \#\{1\leq n\leq N: x_n \in (a,b) \} -(b-a)\right|.$$ Then $$\left|\frac1N \sum_{n\leq N} f(x_n) - \int_I f(x)dx \right|\leq V(f)D_N.$$

Theorem [Erdos-Turan]

Let $x_1, \ldots, x_N$ be $N$ points in $I=[0,1]$. Then there is an absolute constant $C>0$ such that for any positive integer $m$, $$D_N\leq C \left( \frac1m+ \sum_{h=1}^m \frac1h \left| \frac1N\sum_{n=1}^N e^{2\pi i h x_n}\right|\right).$$

We are using these on the sequence $x_n = n \theta \ \mathrm{mod} \ 1$ and $f(x) = (x -\frac12)^2$. By Erdos-Turan and Lemma 3.3 in Kuipers & Neiderrater 'Uniform Distribution of Sequences', we obtain the following bound of discrepancy:

Lemma

Let $\theta$ be an irrational real number. If $\mu$ is the irrationality measure of $\theta$, then the discrepancy $D_N$ for the sequence $n\theta \ \mathrm{mod} \ 1$ satisfies $$D_N \ll N^{-\frac1{\mu-1}+\epsilon}.$$

Therefore, we obtain the following estimate:

Let $\theta$ be an irrational real number with irrationality measure $\mu$, then we have $$\sum_{\nu\leq n} \{ \nu\theta \}^2 = \frac n{12} + O\left( n^{1-\frac1{\mu-1} + \epsilon } \right).$$

Note that $\mu=2$ for almost all $\theta\in\mathbb{R}$ yielding the error term bound $O(n^{\epsilon})$.

Kuipers & Neiderrater's book also contains the following result:

Theorem If $\theta\in\mathbb{R}\backslash \{0\}$ has a bounded partial quotients in the continued fraction, then $$D_N\ll \frac{\log N}N.$$

For $\theta=\sqrt 7$, it has periodic partial quotients, so we have

$$\sum_{\nu\leq n} \{ \nu\theta \}^2 = \frac n{12} + O\left( \log n \right)$$ which is better than $O(n^{\epsilon})$.