Showing a function is Riemann integrable by upper sum and lower sum I am solving the following analysis problem.
Define $f : [0,1] \to \mathbb{R}$ by
$$  f(x) = \begin{cases}
1  ,&  \text{if $1-2^{-2k} \leq x \leq 1-2^{-(2k+1) }$ for $k=0,1,2,\dots$}  \\ 
0  ,&  \text{if $1-2^{-(2k+1)} \lt x \lt 1-2^{-(2k+2)}$ for $k=0,1,2,\dots$}\\
0  ,&  \text{if $x=1$}\end{cases} \text{.}  $$
Prove that $f$ is integrable on $[0, 1]$, and compute $$\int_{0}^1 f(x)dx.$$
My strategy is to sum up the values with a geometric series. Once I have it I want to pick an epsilon and work with the upper sum and lower sum until I have that
$$L(f) \leq U(f)$$ such that for any $\epsilon \gt 0$ there exists a partition P such that $$L(p,f) -U(p,f) \lt \epsilon$$
work is as follows:
$$L(p,f)=\sum_{i=0}^N inf*(t_k-t_{k-1})$$
$$U(p,f)=\sum_{i=0}^N sup*(t_k-t_{k-1})$$
For the lower sum I have:
$x_i$=$1-2^i$ for $i=0,1,...,N+1$
when $i =0$ $inf=1$
when $i=1$ $inf=0$
when $i=2$ $inf=1$
(upper sum obviously follows)
So,for the upper and lower sum I have:
$$L(p,f)=0+\sum_{i=0}^{N-1} 1_ieven*2^{-i-1}=0+2^{-1}+2^{-3}+...$$
$$U(p,f)=2^{-N-1}+\sum_{i=0}^{N-1} 1_i*2^{-i-1}=2^{-N-1}+2^{-1}+2^{-3}...$$
Now, I think my proof up to this point is sound but Im having a hard time computing the sum at the very bottom and could use some help. thanks.
 A: By Lebesgue's integrability condition, a function is Riemann integrable if and only if it is bounded and continuous almost everywhere on the domain of integration. Clearly our function is bounded because $0 \leq f(x) \leq 1$ for any $x,$ so the main concern is continuity.
Here our function will be continuous everywhere except at points $x = 1 - 2^{-k}$ for nonnegative integers $k.$ So, the set of discontinuities is countably infinite, and so it has a Lebesgue measure of $0,$ which means that the function is continuous almost everywhere.
To see why any countably infinite set has $0$ Lebesgue measure, consider turning the set of points into a sequence $x_n$ using the bijection between the set and the natural numbers. Now consider $I_n = (x_n - \frac{\epsilon}{2^{n+1}}, x_n + \frac{\epsilon}{2^{n+1}})$ for any real $\epsilon > 0.$ We have that $l(I_n) = \frac{\epsilon}{2^n},$ so the sum of the lengths is $\sum_{n=1}^{\infty} \frac{\epsilon}{2^n} = \epsilon.$ Because we can do this for any arbitrary $\epsilon > 0,$ the highest possible lower bound for the sum of the lengths, or in other words the Lebesgue measure, is $0.$
Now to compute the integral, consider the function
$$f_n(x) = \begin{cases}1, \text{if }  1 - 2^{-2k} \leq x \leq 1 - 2^{-2k-1} \text{ for } k \in \mathbb{Z}, 0 \leq k \leq n \\ 0, \text{if }  1 - 2^{-2k-1} \leq x \leq 1 - 2^{-2k-2} \text{ for } k \in \mathbb{Z}, 0 \leq k \leq n \\ 0, \text{otherwise}\end{cases}$$
Clearly we have that $|f_n(x)| \leq f(x)$ and $\lim_{n \to \infty} f_n = f,$ so by the dominated convergence theorem we have that $\lim_{n \to \infty} \int_0^1 f_n(x) dx = \int_0^1 f(x) dx.$
Now notice that for any finite $n,$ we can break up the integral into finitely many subintervals such that $$\int_0^1 f_n(x) = \sum_{k = 0}^n \left[\int_{1 - 2^{-2k}}^{1 - 2^{-2k-1}} f_n(x) dx + \int_{1 - 2^{-2k-1}}^{1 - 2^{-2k-2}} f_n(x) dx\right] = \sum_{k = 0}^n 2^{-2k} - 2^{-2k-1}$$ noting that the integrals for $k > n$ must be zero by the definition of $f_n.$
Now taking the limit as $n$ goes to infinity gives us that $$\int_0^1 f(x) dx = \sum_{k = 0}^{\infty} 2^{-2k} - 2^{-2k-1} = \sum_{k = 0}^{\infty} 4^{-k} - \sum_{k = 0}^{\infty} \frac12 4^{-k} = \frac43 - \frac23 = \frac23.$$
Intuitively this should make sense, because for any $k$ you look at, $(1 - 2^{-2k}, 1 - 2^{-2k-1})$ is twice as large as $(1 - 2^{-2k-1}, 1 - 2^{-2k-2}),$ so the intervals of the first form should take up two thirds of the space.
A: Sketch:
Consider, for $u \in [0,1)$,
$$  I(u) = \int_0^u f(x) \,\mathrm{d}x \text{.}  $$
For each choice of $u$, $I$ has only finitely many discontinuities, so is Riemann integrable.  On $[u,1]$, the minimum of $f(x)$ is $0$ and the maximum is $1$.  So a lower sum on $[u,1]$ has value $0$ and an upper sum has value $1-u$.  Now take the limit as $u \rightarrow 1^-$ to show that $I$ plus the upper sum and $I$ plus the lower sum have the same limit (thus showing that the limit of Riemann sums as the partition diameter goes to zero has that same limit).
