Proving $f(0) = 0, f(x) = \frac{1}{2^n}$ when $\frac{1}{2^{n+1}}Consider the following function definition of $f:[0,1]\to \mathbb{R}$
$$f(0) = 0$$
and
$$ f(x) = \frac{1}{2^n}$$
when  $$\frac{1}{2^{n+1}}<x\le\frac{1}{2^n}$$
I need to use the criteria of integrability, to prove that this function is integrable. This criteria is the one about the superior and inferior integrals. 
So, I must prove that the inferior and superior integrals are the same. 
That's what I tried: (ps: I know that there might be better ways to solve this, but you'd really help me by following my reasoning and pointing where did I do wrong)
$$\underline{\int_{a}^b}f(x) dx =  \sup S(f, P)  = \sup \sum_{i=1, t_i \in P} m_i(t_{i}-t_{i-1})$$
where $m_i = \inf\{f(x), x\in [t_i, t_{i-1}]\}$.
Now, for every $x\neq 0 \in [a,b]$, I can find $n$ such that $\frac{1}{2^{n+1}}<x\le \frac{1}{2^n}$. If I partition my set in like, $100$ points, there will be some 'gaps' in the form $[t_{j}-t_{j-1}]$ in which the function will always be the same, because in that interval, there would be only one option for $\frac{1}{2^{n+1}}$ and $\frac{1}{2^n}$ to have $x$ in the middle. For example, in the interval $[\frac{1}{4},\frac{1}{2}]$ there would be a lot of points inside it such that $\frac{1}{2^{1+1}}<x\le \frac{1}{2^{1}}$ and thus the value of the function in this entire interval would be $\frac{1}{2}$. Of course the intervals of the partition wouldn't be always exactly powers of $2$, but they will contain at least parts of it...
So, in these intervals where the function has always the same value, the $m_i$ of the interval would be the value of the function, because it's constand, and $m_i$ is the $\inf$.
So, in pratice, I think that the sum would resolve to something like this:
$$\sup \sum_{i=1, t_i \in P} m_i(t_{i}-t_{i-1})$$
where each $m_i$ would be a power of $2$, that is, in the form $\frac{1}{2^n}$. Lots of them would be included in the same partition, for example, in $[\frac{1}{4}, \frac{1}{2}]$. Suppose this occurs, so we have:
$$\frac{1}{2^k}(a_0-b_0)+\frac{1}{2^k}(a_1-b_1)+\cdots +\frac{2}{^k}(a_j-b_j)$$
then they could be grouped like this:
$$\frac{1}{2^k}(a_0-b_0+a_1-b_1+\cdots +a_j-b_j)$$
in which $(a_0-b_0+a_1-b_1+\cdots +a_j-b_j)$ would sum to the entire interval where $f(x)=\frac{1}{2^n}$, that is, the sum is $\frac{1}{2^n}-\frac{1}{2^{n+1}}$
So in the end, we would sum something like this:
$$\sum_{k=1}^{\infty} \frac{1}{2^k}\left(\frac{1}{2^k}-\frac{1}{2^{k+1}}\right)$$
I don't know if the reasoning above is correct, but I know that if I do the same for the inferior integral, which involves sums of $M_i$'s, which are the superiors of the function values in such intervals, will also be the value of the function in the interval. So in pratice, $m_i = M_i$ and thus the inferior and superior integrals must be the same.
Am I correct? 
 A: Take the simple functions,
$$\phi_m(0)=\begin{cases}
\frac{1}{2^n}\quad\mbox{if $\frac{1}{2^{n+1}}<x<\frac{1}{2^n}$ and $1\leq n\leq m$}
\\
0\quad\mbox{otherwise}
\end{cases} $$
and 
$$\psi_m(0)=\begin{cases}
\frac{1}{2^n}\quad\mbox{if $\frac{1}{2^{n+1}}<x<\frac{1}{2^n}$ and $1\leq n\leq m$}
\\
\frac{1}{2^m}\quad\mbox{otherwise}
\end{cases}.$$
Then $\phi_m(x)\leq f(x)\leq \psi_m(x)$ for all $x\in [0,1]$ and as $m\to +\infty$, 
$$\inf S(f, P)-\sup s(f, P)\leq S(\psi_m,p_m)-s(\phi_,p_m) =\frac{1}{2^m}\cdot \frac{1}{2^{m+1}}\to 0$$
where $p_m$ is the partition of $[0,1]$ given by the points $0,\frac{1}{2^{m+1}},\frac{1}{2^{m}},\dots,\frac{1}{2},1$.
Hence $f$ is integrable on $[0,1]$.
A: Let's say
$$x\in(\frac{3}{2^{k+3}},\frac{3}{2^{k+2}})$$
than
$$m_i=\frac{1}{2^{k+1}} , M_i=\frac{1}{2^{k}} $$ 
so 
$$ M_i -m_i = \frac{1}{2^{k+1}}\gt 0 $$
in every interval containing a point of the from $ \frac{1}{2^{k+1}}$ but as we can decrease the length of the intervals around those points,we can say that the difference between the upper sum and the lower sum is lower than some $\epsilon$
A: It's not true that $f$ is constant in the interval $[1/4,1/2]$. We have $f=1/2$ on $(1/4,1/2]$ and $f(1/4) = 1/4.$ On $[1/4,1/2]$ we have $M-m=1/4.$ (I'm sure you know this, but your remarks there were confusing to me.)
You're right though that if you choose a partition with small mesh size, there will be lots of subintervals where $f$ is constant. On those subintervals you will have $M-m=0,$ which is a good thing.
At the end you seem to want to get your hands on what the integral should equal with that infinite series. That's a nice additional problem (although I think you want to start the sum at $k=0$). But remember the main point is to prove integrability, i.e., to find a partition for which $\sum (M_i-m_i)\Delta x_i < \epsilon.$
I may add to this later.
