# Identity involving "the distance to the nearest integer" function

It's a problem of an exercise list:

I want to prove that, if $||x||$ = the distance to the nearest integer to $x$, then:

$$\sum_{n=1}^{\infty}4^{-n}||2^nx||=||x||(1-2||x||)$$

is true for every $x \in \mathbb{R}/\mathbb{Z}$.

What I've tried so far:

We know that the set $D=\{\sum_{k=1}^T\frac{a_k}{2^k}$, where $a_i = 0, 1 \forall i \in \{1,2,\ldots,T\}; T \in \mathbb{N}\}$ is dense in $(0,1)$. So, it's enought to prove the identity for these numbers. Because then, we can use the Weierstrass M Test to guarantee that the identity is valid to any other number in $(0,1)$.

Why these specific numbers? Because then, the infinity sum $\sum_{n=1}^{\infty}4^{-n}||2^nx||$ will become finity and it will be easier to work with.

So, considering numbers of the form above, we obtain that

$$\sum_{n=1}^{\infty}4^{-n}||2^nx||=\sum_{n=1}^{\infty}4^{-n}\left|\left|2^n\sum_{k=1}^T\frac{a_k}{2^k}\right|\right| = \sum_{k=1}^{T-1}4^{-n}\left|\left|2^n\sum_{k=1}^{T}\frac{a_k}{2^k}\right|\right|.$$

Firt of all, the way I constructed that specific numbers, we can't obtain 1, but that's OK, because in $\mathbb{R}/\mathbb{Z}$ is 0.

Now, note that:

$||x||=x$, if $0 \leq x \leq 1/2$ and

$||x|| = 1- x$, if $1/2 < x <1$

(Remember we are working in $\mathbb{R}/\mathbb{Z}$).

So, if we define $S_n=2^n\sum_{k=1}^{T-1}\frac{a_k}{2^k}$, we get that $||S_n||=||2^n\sum_{k=1}^{T-1}\frac{a_k}{2^k}||=a_{n+1}-2a_{n+1}S_n+S_n$, because if $a_{n+1}=0$, $S_n \leq 1/2$ and if $a_{n+1}=1$, $S_n > 1/2$.

So, $$\sum_{n=1}^{\infty}4^{-n}\left|\left|2^n\sum_{k=1}^T\frac{a_k}{2^k}\right|\right|=\sum_{n=1}^{T-1}4^{-n}(a_{n+1}-2a_{n+1}S_n + S_n)$$ $$= \sum_{n=1}^{T-1}\frac{a_{n+1}}{4^n}-\sum_{n=1}^{T-1}\frac{1}{4^n}(2a_{n+1}S_n - S_n)$$ $$=\sum_{n=1}^{T-1}\frac{a_{n+1}}{4^n} + \sum_{n=1}^{T-1}\frac{S_n}{4^n}(1-2a_{n+1})$$ $$=\sum_{n=1}^{T-1}\frac{a_{n+1}}{4^n}+\sum_{n=1}^{T-1}\sum_{i=1}^{T}\frac{a_i}{2^i}\left(\frac{1-2a_{n+1}}{2^n}\right)$$.

On the other hand, we have that $$||x||(1-2||x||)=\sum_{k=2}^{T}\frac{a_k}{2^k}-2\left(\sum_{k=2}^{T}\frac{a_k}{2^k}\right)^2$$.

I'm having trouble finding a way to prove that the two expressions are, indeed, equal. I tried to write the last expression as an open product of two series, but it didn't work...

Does someone have a hint or a solution?

Thanks!

A simple, but unfortunately unrelated, argument would be to first prove that $$f(x)=\sum_{n=1}^{\infty}4^{-n}||2^n x||$$ is a continuous function on $\mathbb R / \mathbb Z$. This is relatively easy - for instance, noting that $4^{-n}||2^n x||$ is Lipschitz continuous with Lipschitz constant $2^{-n}$ yields that $f$ is Lipschitz continuos with Lipschitz constant $1$.
Now, let's consider the metric space of continuous functions on $\mathbb R / \mathbb Z\rightarrow \mathbb R$ endowed with the metric $$d(f,g)=\sup_{x\in\mathbb R / \mathbb Z}|f(x)-g(x)|$$ and, on this space, consider the map $$T(g)=x\mapsto\frac{||2x||+g(2x)}{4}.$$ of which $f$ is obviously fixed point. The function $x\mapsto ||x||(1-2||x||)$ is also a fixed point, though the proof of this is more tedious. Moreover, $T$ is a contraction map (contracting by a factor of $\frac{1}4$) and therefore has at most one fixed point. Thus, as both $f$ and $x\mapsto ||x||(1-2||x||)$ are fixed points, they are equal.