# Some follow up questions to the integrability of Thomae's function

After doing some work with Thomae's function, I feel like the following details (which I have generalized) are relevant to the proof that this function is integrable:

1. For any partition P, the lower sum $$L(f,P)$$ is constant (say $$C$$). This is accomplished by having a dense set $$S$$ in $$[a,b]$$ such that if $$s \in S$$, then $$f(s)=C$$ and by requiring that $$C$$ is a lower bound to $$f[a,b]$$.

2. For any $$y \gt C$$, if $$T_y$$ is the set of points such that $$f(t) \gt y$$ (where $$t \in T$$), then $$T$$ is finite.

From these two descriptors, I have two questions:

First Question

If a function $$f$$ satisfies 1. and 2., can I conclude that $$\displaystyle \int_a^b f=C\cdot (b-a)$$? (In Thomae's function, $$C=0$$, and we get that the integral of Thomae's function is $$0$$)

I feel like the answer should be YES, and the proof probably works out by showing you can always find an appropriate partition such that $$U(f,P) \lt \varepsilon + C$$

If the answer is no, then I am clearly missing an additional feature that characterizes Thomae's function's integrability, so if you could comment on that, I would appreciate it.

Second Question

If the answer to the first question is NO, this follow up question is meaningless and can be ignored.

Thomae's function is classically defined on the interval $$[0,1]$$ as:

$$f(x)=\begin{cases} \frac{1}{q},&\text{if x=\frac{p}{q} in lowest terms}\\ 0,&\text{if x\in\mathbb{R}\setminus \mathbb{Q};} \end{cases}$$

Suppose I made a new function $$g$$ that looks like this:

$$g(x)=\begin{cases} \frac{1}{q},&\text{if x=\frac{p}{q} in lowest terms}\\ -\frac{1}{q},&\text{if x=\frac{p}{q} in lowest terms and q is a multiple of 3}\\ 0,&\text{if x\in\mathbb{R}\setminus \mathbb{Q};} \end{cases}$$

There are other ways of making this $$g$$, but the gist of this edited function is that I am breaking the first outlined condition. There is still a dense set in $$[0,1]$$ such that $$g(x)=0$$, but $$L(f,P)$$ is no longer constant. However, the second outlined condition is still applicable going the other way...i.e.:

For any $$y \lt 0$$, if $$T_y$$ is the set of points such that $$f(t) \lt y$$ (where $$t \in T$$), then $$T$$ is finite.

My question is: Is $$g$$ integrable?

Edit:

The following is a proof to the proposition offered by Greg Martin in his answer; the proof is divided into two sections: Section 1 will show that the function $$d=k-h$$ is integrable on $$[a,b]$$ and Section 2 will show that $$\int_a^b d=0$$. From these results, we will be able to conclude that $$\int_a^b k =\int_a^b h$$. Before beginning, note that $$d$$ is a function which is defined as satisfying the following property:

$$\forall \varepsilon \gt 0: \exists N \in \mathbb N \cup \{0\}: \displaystyle\Big\lvert\{x\in[a,b]: |d(x)| \gt \varepsilon\} \Big\rvert = N$$.

We can show that $$d$$ (which is a real-valued function) must therefore be bounded. This is true because:

Consider any arbitrary $$\varepsilon$$. We know that there is a corresponding $$N_{\varepsilon}$$ number of elements such that if $$x$$ is one of these elements, then $$|d(x)| \gt \varepsilon$$. Because $$N_{\varepsilon}$$ is finite, there must be an element $$x^*$$ such that $$|d(x^*)| \geq |d(x)|$$ for all other $$x$$ in this list. Now, let $$M=|d(x^*)|+1$$. Then we must have that $$|d(x^*)| \lt M$$. More importantly, this implies that $$\forall x \in [a,b]: |d(x)| \lt M$$ because any $$x \in [a,b]$$ satisfies either $$|d(x)| \lt \varepsilon \lt M$$ or satisfies $$|d(x)| \lt M$$. Therefore, $$d$$ is bounded.

Section 1

Our goal is to show that for an arbitrary $$\varepsilon \gt 0$$, we can find a partition $$P$$ such that: $$U(d,P)-L(d,P) \lt \varepsilon$$. To do this, we will create two categories of subintervals: the first category will be used to section off subintervals that contain at least one large value of $$d$$ and the second category will be used to section off subintervals that only contain small values of $$d$$ (here, 'large' and 'small' refer to distance away from $$0$$...so a sufficiently negatively value can be 'large'). To each category, we will consider a partial Upper:Lower Sum Difference such that if $$S_1$$ and $$S_2$$ denote the different categories, then $$U^{S_1}(d,P)-L^{S_1}(d,P)$$ denotes the partial Upper:Lower Sum Difference of category 1 subintervals and $$U^{S_2}(d,P)-L^{S_2}(d,P)$$ denotes the partial Upper:Lower Sum Difference of category 2 subintervals. We will construct the subintervals of the these two categories to only share end points, which means $$U^{S_1}(d,P)-L^{S_1}(d,P)+U^{S_2}(d,P)-L^{S_2}(d,P)=U(d,P)-L(d,P)$$. We will require that each partial Upper:Lower Sum Difference is $$\lt \frac{\varepsilon}{2}$$ so that we can conclude $$U(d,P)-L(d,P) \lt \varepsilon$$.

To determine how we should distinguish between large and small values, we will use $$\varepsilon$$ to derive a boundary value $$C_{\varepsilon}$$ such that if $$|d(x)| \leq C_{\varepsilon}$$, then $$d(x)$$ is small...and if $$|d(x)| \gt C_{\varepsilon}$$, then $$d(x)$$ is large. $$C_{\varepsilon}$$ is calculated in the following way:

Consider all $$x$$ such that $$d(x) \in [-C_{\varepsilon},C_{\varepsilon}]$$ and the corresponding partial Upper:Lower Sum Difference associated with the subintervals that contain them. For a subinterval $$[t_{i-1},t_i]$$ that only contains these small values, we know that $$M_i - m_i \leq 2C_{\varepsilon}$$, where $$M_i$$ and $$m_i$$ are the supremum and infimum of $$d$$, respectively, on the corresponding subintervals that only contain small values. Now, the maximal length of all subintervals that exclusively contain $$x$$ such that $$d(x) \in [-C_{\varepsilon},C_{\varepsilon}]$$ is, obviously, $$[a,b]$$. Therefore, the partial Upper:Lower Sum Difference associated with these small values is, at most, $$2C_{\varepsilon}\cdot(b-a)$$. We want the following inequality to hold: $$2C_{\varepsilon}\cdot(b-a) \lt \frac{\varepsilon}{2}$$. Solving for $$C_{\varepsilon}$$ gives us: $$C_{\varepsilon} \lt \frac{\varepsilon}{4(b-a)}$$

Now, consider all of the points $$x$$ such that $$|d(x)| \gt C_{\varepsilon}$$. By assumption, the set of points satisfying this is finite. Suppose there are $$N$$ such points in $$[a,b]$$. Our next task is to determine how small we want the length of a given subinterval that contains these large points. We know that the partial Upper:Lower Sum Difference of the subintervals containing these points will equal: $$\displaystyle \sum_{i=1}^N \left(M_i-m_i\right)\cdot \omega \quad (*_1)$$, where $$\omega$$ is a constant window size of all subintervals that contain at least one $$x_i$$ of the $$N$$, and $$M_i$$ and $$m_i$$ are the supremum and infimum of $$d$$, respectively, on the corresponding subintervals that contain at least one large value.

Now, before we can solve for $$\omega$$, we need to first recall that $$d$$ is bounded. This means that there is a $$T$$ such that $$\forall x \in [a,b]: |d(x)| \leq T$$. Therefore, for the $$M_i$$ and $$m_i$$ associated with $$(*_1)$$, we know that for any $$i \in \{1,2, \cdots, N\}: M_i-m_i \leq 2T$$. The worst case scenario is that each of these subintervals contains exactly one large value; this would then mean that we have $$N$$ different subintervals containing large values. Thus, we have that the partial Upper:Lower Sum Difference of the subintervals containing these points is $$\leq (2T)\cdot \omega \cdot N$$. Further, we want this value to be $$\lt \frac{\varepsilon}{2}$$. Solving for $$\omega$$, we have that:

$$\omega \lt \frac{\varepsilon}{4NT}$$

To help us in constructing the actual values of the partition $$P$$ that will satisfy $$U(d,P)-L(d,P) \lt \varepsilon$$, it will be more convenient to think of $$\omega$$ as $$2\delta$$. This means that we will rewrite the above inequality as:

$$\delta \lt \frac{\varepsilon}{8NT}$$

With the above information, we can construct $$P$$ as follows: take every $$x_i$$ that is mapped through $$d$$ to a value greater or lesser than $$C_{\varepsilon}$$ or $$-C_{\varepsilon}$$, respectively, and form the interval $$[x_i-\delta,x_i+\delta]$$. If these subintervals happen to overlap, it is no issue, as our previous inequalities took into consideration no overlap (besides, perhaps, the end points), which is the worst case scenario. We can actually explicitly avoid this by adding an additional condition to our $$\delta$$. Because $$N$$ is finite, we know that the list of pairwise distances between all large $$x_i$$ is finite (it should be obvious that we do not want to compare an $$x_i$$'s distance with respect to itself). Further, there must be a smallest pairwise distance: call this distance $$\ell$$. Then we can require that $$\delta \lt \min(\frac{\varepsilon}{8NT},\ell)$$.

Also, if $$x_i-\delta \lt a$$, simply set that value to $$a$$; similarly, if $$x_i+\delta \gt b$$, set that value to $$b$$. Alternatively, we can once again explicitly encode a condition on $$\delta$$ to avoid this from happening by adding $$a$$ and $$b$$ into the list of large $$x_i$$ where we calculated the pairwise distances. In the event that $$x_1=a$$ or if $$x_N=b$$, we can remove the $$-\delta$$ or $$+\delta$$, respectively, from the subinterval.

With the above conditions, assuming the $$x_1 \lt x_2 \lt \cdots \lt x_N$$, we have a set that looks like $$\{a,x_1-\delta,x_1+\delta,x_2-\delta,x_2+\delta,\cdots,x_N-\delta,x_N+\delta,b\}$$. This set represents our desired $$P$$.

Section 2

Section 1 provided us with the following claim: for any $$\varepsilon \gt 0$$, there is a partition $$P$$ of $$[a,b]$$ such that $$U(d,P)-L(d,P)\lt \varepsilon$$. In this section, we will demonstrate that $$\displaystyle \inf_P U(d,P) \geq 0$$ and $$\displaystyle \sup L(d,P) \leq 0$$. Using these three statements, we can conclude that $$\displaystyle \inf_P U(d,P) = 0 = \sup L(d,P)$$, which of course means that $$\displaystyle \int_a^b d=0$$.

Because of how $$d$$ is defined, we would then have that $$\displaystyle \int_a^b d + \int_a^b h= \int_a^b d+h= \int_a^b k-h+h=\int_a^b k$$. Now, if $$\displaystyle \int_a^b d=0$$, then $$\int_a^b k =\int_a^b h$$, as desired.

We will now show that $$\displaystyle \inf_P U(d,P) \geq 0$$. The proof for $$\displaystyle \sup L(d,P) \leq 0$$ works symmetrically and will not be treated,

Suppose by contradiction that there is a partition $$P$$ of $$[a,b]$$ such that $$U(d,P) \lt 0$$. Equivalently, we have that $$\displaystyle \sum_{i=1}^n M_i (t_{i}-t_{i-1}) \lt 0$$. This implies that there is at least one $$j \in \{1,2,\cdots, n\}$$ such that $$M_j\lt 0$$. Let us take a look at how $$d$$ behaves on this subinterval $$[t_{j-1},t_j]$$.

Because $$M_j$$ is the supremum of $$d$$ on $$[t_{j-1},t_j]$$, we know that $$\forall x \in [t_{j-1},t_j]: d(x) \leq M_j \lt 0$$. By the property that defines $$d$$, we know that there are only a finite number of points on $$[a,b]$$ that are mapped through $$d$$ to below $$M_j$$. Importantly, then, there are only a finite number of points in the interval $$[t_{j-i},t_j]$$ that are mapped to values less than $$M_j$$. Because $$\frac{M_j}{2} \lt 0$$, the property of $$d$$ also lets us deduce that the number of values less than or equal to $$M_j$$ is also finite. This, combined with the fact that $$M_j$$ is the supremum, means that the subset $$\left.d\right|_{[t_{j-1},t_j]}$$ has only finitely many elements, but this is a contradiction...as there should be uncountably many elements in this subset. Therefore, there is no such $$P$$ satisfying $$U(d,P) \lt 0$$. This means that $$\displaystyle \inf_P U(d,P) \geq 0$$.

I believe the answers to both questions are "yes". I think they would follow from the following proposition, the proof of which should mirror the proof of the integrability of Thomae's function (indeed the proof would begin by defining $$d(x) = k(x)-h(x)$$).
Proposition: Let $$h(x)$$ be integrable on $$[a,b]$$. Suppose that $$k(x)$$ is a function defined on $$[a,b]$$ with the property that for every $$\varepsilon>0$$, the set $$\bigl\{ x\in [a,b]\colon |k(x)-h(x)| > \varepsilon \bigr\}$$ is finite. Then $$k(x)$$ is also integrable on $$[a,b]$$ and $$\displaystyle\int_a^b k(x)\,dx = \int_a^b h(x)\,dx$$.
• In my attempt to prove this theorem, I wanted to know whether or not it is important to assert that $k$ is bounded. The way my proof is currently headed, I am assuming that $k$ has an upper and lower bound. Perhaps this is implicit, but I just wanted to make sure that this needed to be assumed...as I do not think there is a way of deducing that $k$ is bounded simply from the set definition. Could you please confirm? Cheers~
• If $h$ itself is bounded, then yes, the boundedness of $k$ can be deduced from the hypotheses of the proposition (with $\varepsilon=1$, for example—any choice will do). Perhaps more importantly, the hypotheses imply that $k(x)-h(x)$ is bounded. Commented Sep 1, 2022 at 22:08