**Edit: I got rid of my old definitions. Everything should be clear now**


Since no one has answered [my question](https://math.stackexchange.com/questions/3637157/how-do-prove-the-darboux-like-sum-of-a-function-defined-on-a-countable-set-with) on MSE, I’m hoping to get an answer here. I apologize if you dislike my writing. I am an undergraduate student and I don’t know whether this is a research question.




---


Definition
----------


Consider a continuous $f:A\to[0,1]$ where $A\subseteq[0,1]$.


**Edit: I did not use [@Mathworker21's answer](https://math.stackexchange.com/a/3340521/125918) because I assumed it would not give the result I am looking for.** Now I realize this is not the case. Here is his definition.



> 
> We can assume $A \subseteq [a,b]$, since that's where everything is happening. For ease, I'll have $[a,b] = [0,1]$. Based on the above discussion, I'll just have $P$ be defined on all of $[0,1]$ and continuous. Let $E\_1 = [0,1], E\_2 = [0,\frac{1}{2}], E\_3 = [\frac{1}{2},1], E\_4 = [0,\frac{1}{4}], E\_5 = [\frac{1}{4},\frac{1}{2}], E\_6 = [\frac{1}{2},\frac{3}{4}]$, $E\_7 = [\frac{3}{4},1], E\_8 = [0,\frac{1}{8}]$, etc. 
> 
> 
> If $A$ is finite, it's obvious how to define the average of $P$ (just do $\frac{1}{|A|}\sum\_{x \in A} P(x)$). So, assume $A$ is infinite. Consider the sets $A\cap E\_1, A\cap E\_2, \dots$. Let $x\_1$ be a point in the first nonempty one of these sets. Let $x\_2$ be a point in the second nonempty of these sets, etc. Look at the measures $\delta\_{x\_1}, \frac{\delta\_{x\_1}+\delta\_{x\_2}}{2}, \dots, \frac{\delta\_{x\_1}+\dots+\delta\_{x\_N}}{N},\dots$. Since $[0,1]$ is a compact metric space, there is some probability measure $\mu$ on $[0,1]$ that is a weak\* limit of some subsequence of these measures, i.e. there is some $(N\_k)\_k$ with $\frac{1}{N\_k}\sum\_{j=1}^{N\_k} f(x\_j) \to \int\_0^1 f d\mu$ for each $f \in C([0,1])$. 
> 
> 
> We then define the average of $P$ over $A$ to be $\int\_0^1 Pd\mu$. 
> 
> 
> 




---



> 
> For concreteness, suppose that $$f=\operatorname{id}$$ and
>  $$A=\left\{\frac{1}{2^x}+\frac{1}{2^y}+\frac{1}{2^z}:x,y,z\in\mathbb{Z}^{+}\right\}\cap[0,1]$$
> 
> 
> My guess is, in this case, the average will converge to $0$. How do we prove whether I am right or wrong? Could we create a better definition that is easier to compute or gives an exact value?
> 
> 
> 


Possible evidence that the average is zero
------------------------------------------


Here is a number line plot of all elements of set $A$



```
generateA[n_Integer] := 
 Select[Union@
   Flatten[Table[
     1/2^x + 1/2^y + 1/2^z, {x, 1, n}, {y, x, n}, {z, y, n}]], 
  0 <= # <= 1 &]
NumberLinePlot[generateA[50], PlotStyle -> PointSize[0.003]]

```

It appears the points become "denser" near $0$. If the 'densest point' carries the most weight in the average, it is possible that the average should be $f(0)=0$.


Also by analysis, if we take the function inside $A$ and set $x$ as constant $a$ and $y$ as constant $b$, taking $z\to\infty$ we get


$$\left\{\frac{1}{2^a}+\frac{1}{2^b}:a,b\in\mathbb{Z}^{+}\right\}$$


This represents all the limit points. Since the limit points are "infinitely denser" than finite points, they should have infinitely greater weight for the average.


If we set $b\to\infty$ we get


$$\left\{\frac{1}{2^a}:a\in\mathbb{Z}^{+}\right\}$$


These represent second-order limit points "closely approximated" by first-order limit and finite points. The second-order limit points should have infinitely more weight than the lower order limit points.


As $a\to\infty$, we get $0$, the third order limit point and the densest point in the set. Third-order limit points should have infinitely more weight than second order, first order, and finite limit point.


From our analysis, it's possible, the average is $f(0)=0$.


Finally, consider the following code (from Wolfram Mathematica). This replicates $L(f,P)$ and $U(f,P)$ which I mentioned earlier:



```
partition[a_List, s_] := Module[{f, r}, f[{}, x_] := {x};
  f[l_List, x_] := If[x - l[[1]] < s, Append[l, x], Sow[l]; {x}];
  r = Reap[Fold[f, {}, a]];
  Append[r[[2, 1]], r[[1]]]]
partition[{0, 1, 2, 7, 10, 11, 12}, 5]
(*{{0,1,2},{7,10,11},{12}}*)
calculate[p_, a_, s_] := 
 Module[{parts = partition[a, s], n, inf, sup}, n = Length[parts];
  inf = Total[Min[p /@ #] & /@ parts];
  sup = Total[Max[p /@ #] & /@ parts];
  {inf/n, sup/n}]
calculate[Identity, generateA[500], N[10^(-170)]] // N

```

I get:



```
{0.00598798, 0.00598798}

```

But it took a long time to compute. In fact, the [person who gave me this answer](https://mathematica.stackexchange.com/a/220088/34171) doesn't think the sum converges to $0$ when $f=\operatorname{id}$? How do we prove otherwise?


~~Deleted Definition~~
----------------------




> 
> Let $\require{enclose} \enclose{horizontalstrike}{A \subseteq [0,1]}$, and let $\require{enclose} \enclose{horizontalstrike}{P}$ be a partition of $\require{enclose} \enclose{horizontalstrike}{[0,1]}$ such that it is a finite set of sub-intervals $\require{enclose} \enclose{horizontalstrike}{X}$ with disjoint interiors and each subinterval has the same length. Define $\require{enclose} \enclose{horizontalstrike}{P' = \{ X\in P: X\cap A \neq \emptyset\}}$. Define $\require{enclose} \enclose{horizontalstrike}{n' = |P'|}$ (the cardinality of a finite set, or in this case, the number of sub-intervals whose intersection with $\require{enclose} \enclose{horizontalstrike}{A}$ is non-empty). 
> 
> 
> 


Calculate/define the following:


$$\require{enclose} \enclose{horizontalstrike}{L\_{f,P} = \frac{1}{n^{\prime}} \sum\_{X \in P^{\prime}} \bigg(\inf\_{t \in X}f(t) \bigg)}$$


$$\require{enclose} \enclose{horizontalstrike}{U\_{f,P} = \frac{1}{n^{\prime}} \sum\_{X \in P^{\prime}} \bigg(\sup\_{t \in X}f(t) \bigg)}$$


Define the limits under refinements of $P$ like so:
$$\require{enclose} \enclose{horizontalstrike}{L\_f = \lim\_{\|P\| \to 0}(L\_{f,P})}$$
$$\require{enclose} \enclose{horizontalstrike}{U\_f = \lim\_{\|P\| \to 0}(U\_{f,P})}$$


Where $\require{enclose} \enclose{horizontalstrike}{\|P\|=\sup\_{X\in P}\|X\|}$.


$\require{enclose} \enclose{horizontalstrike}{L\_f}$ is the 'lower average' of $\require{enclose} \enclose{horizontalstrike}{f}$ on $\require{enclose} \enclose{horizontalstrike}{[0,1]}$ (with respect to partition $\require{enclose} \enclose{horizontalstrike}{P}$). Likewise, $\require{enclose} \enclose{horizontalstrike}{U\_f}$ is the 'upper average' of $\require{enclose} \enclose{horizontalstrike}{f}$ on $\require{enclose} \enclose{horizontalstrike}{[0,1]}$ with respect to partition $\require{enclose} \enclose{horizontalstrike}{P}$.


If these lower and upper averages limits converge to the same value (id est: are equal), we are given "my definition of average" of $f$. If they do not converge, then the average is undefined. Notice I define "upper" and "lower" averages to show when an average can not exist. 


Note I describe $\require{enclose} \enclose{horizontalstrike}{L(f, P)}$ and $\require{enclose} \enclose{horizontalstrike}{U(f, P)}$ as "Riemman-like" because original Riemman-sums have upper and lower sums. However, this doesn't mean they are the same. Here we discard empty sub-interval with no points. This means my average could be anywhere between $\require{enclose} \enclose{horizontalstrike}{f(0)}$ and $\require{enclose} \enclose{horizontalstrike}{f(1)}$ depending on $\require{enclose} \enclose{horizontalstrike}{A}$, and possibly initial $\require{enclose} \enclose{horizontalstrike}{P}$.



Prove or disprove this integral of a function, defined on a countable set with infinite limit points, converges to zero
For the concrete question you ask, the answer is yes. 


Your set $A$ is in fact the set of all numbers between $0$ and $1$ with binary expansion that has no more than 3 bits equaling 1. 


Let $\ell\_+ = \lceil \log\_2 n \rceil$ and $\ell\_- = \lfloor \log\_2 n \rfloor$. You can estimate 


$$ n' \geq (\ell\_- - 1) + \binom{\ell\_- - 1}{2} + \binom{\ell\_- - 1}{3} \approx \ell\_-^3 $$


On the other hand, the sum inside either the upper/lower sum is between


$$ \sum\_{i = 1}^{\ell\_+} 2^{-i} + \sum\_{i = 1}^{\ell\_+} \sum\_{j = i+1}^{\ell\_+} (2^{-i} + 2^{-j}) + \sum\_{i = 1}^{\ell\_+} \sum\_{j = i+1}^{\ell\_+}\sum\_{k = j+1}^{\ell\_+} (2^{-i} + 2^{-j} + 2^{-k}) $$


(which is the sum of all numbers in $A$ with no more than 3 bits equaling 1 *and* least significant bit at least $2^{-\ell\_+}$) and 


$$ \sum\_{i = 1}^{\ell\_+} (2^{-i} + 2^{-\ell\_-}) + \sum\_{i = 1}^{\ell\_+} \sum\_{j = i+1}^{\ell\_+} (2^{-i} + 2^{-j}+ 2^{-\ell\_-}) + \sum\_{i = 1}^{\ell\_+} \sum\_{j = i+1}^{\ell\_+}\sum\_{k = j+1}^{\ell\_+} (2^{-i} + 2^{-j} + 2^{-k}+ 2^{-\ell\_-}) $$


(which is the sum of the same set of numbers of the first sum, increased by the width of the interval).


The first sum is easily evaluated to be $O(\ell\_+^2)$ (here we take advantage of the fact that at least one level of the summation converges using geometric series). The second sum is $O(\ell\_+^2) + O(\ell\_+^3 2^{-\ell\_-})$. 


So this means that both the upper sum and the lower sum behave like $\frac{C}{\log\_2(n)} \to 0$ as $n \to +\infty$. 


(This explains why your numerical computation goes very slow. At $n = 10^{-170}$, $\log\_2(n)$ is something like 800. In fact, I don't even know if there is a reasonable numerical method for this, since to get convergence to the 10th decimal place, you will need a floating point arithmetic with a 2^30 bit mantissa to avoid numerical errors, or alternatively invent a new way to do exact arithmetic with rational numbers with very large numerators and denominators.)


