A function of bounded variation with derivative zero almost everywhere On $[0,1]$, we can define a function $f$ with $f(0)=0$, $f(1)=1$, $f(x)=0$ for irrational $x$ and $f(m/n)=1/n^3$ for $(m,n)=1$. How can i show that $f$ is of bounded variation and $f'=0$ a.e.$[m]$?  
Here $m,n$ are positive integers. 
Thanking you in advance.
 A: For each integer $n$, there are at most $n$ rational numbers in $[0,1]$ of the form $m/n$. For any partition used to compute the variation, we can increase the variation by including an irrational between any two rationals in the partition. Thus, the variation is at most
$$
\sum_{n=1}^\infty n\cdot2\cdot\frac{1}{n^3}=\sum_{n=1}^\infty\frac{2}{n^2}=\frac{\pi^2}{3}\tag{1}
$$

For any $\epsilon>0$ and a rational $m/n$, consider when an irrational $r$ satisfies
$$
\epsilon&lt\left|\frac{f(m/n)-f(r)}{m/n-r}\right|=\frac{1/n^3}{|m/n-r|}\tag{2}
$$

$(2)$ requires that $|m/n-r|&lt\dfrac{1}{\epsilon n^3}$. The measure of the irrationals which would have a difference ratio bigger than $\epsilon$ considering rationals with a denominator of $n$ would be at most $n\cdot2\cdot\dfrac{1}{\epsilon n^3}$. Summing, we get that the measure of the irrationals which would have a difference ratio bigger than $\epsilon$ considering rationals with a denominator of at least $n$ would be at most
$$
\sum_{k=n}^\infty k\cdot2\cdot\frac{1}{\epsilon k^3}=\sum_{k=n}^\infty\frac{2}{\epsilon k^2}=\frac{2}{\epsilon}\left(\frac1n+O\left(\frac{1}{n^2}\right)\right)\tag{3}
$$
Removing a finite number of rationals does not change the derivative at any irrational, so for any $\epsilon>0$, $(3)$ allows us to compute that, by removing a finite number of rationals (choosing $n$ large enough), we can ensure that the measure of the set of irrationals at which the $\limsup$ of the difference ratios exceeds $\epsilon$ is as small as we wish.
Thus, the measure of the set on which the derivative is not $0$ has measure $0$.
A: My turn:
First the BV part. Let $t_0=0 &lt t_1&lt...&ltt_n=1$ be a partition of $[0,1]$. As mentioned in another proof, we can always add irrational points $t_i'$ in between to refine the partition. Then we have $t_0 &ltt_0' &lt t_1&lt t_1' &lt...&ltt_{n-1}'&ltt_n$. Since $f(t_i') = 0$, we can form the estimate:
$$\sum_{i=0}^{n-1} | f(t_{i+1}) - f(t_i)| \leq \sum_{i=0}^{n-1} | f(t_{i+1}) - f(t_i)'|+|f(t_i')-f(t_i)| \leq 2 \sum_{i=0}^{n} f(t_i)$$
The last estimate can be replaced by summing over all points in $[0,1]$ where $f$ is positive:
$$\sum_{i=0}^{n-1} | f(t_{i+1}) - f(t_i)| \leq \sum_{t \in [0,1], f(t)>0} f(t) \leq 
\sum_{n=1}^{\infty} \frac{2(n+1)}{n^3} = K$$
(The final inequality comes from the fact that there are at most $n+1$ rationals with denominator $n$ in $[0,1]$.) Consequently, we have $\mathrm{Var}_{[0,1]} f \leq K$.
Now the differentiability part. It turns out that $f$ is differentiable at all irrational points. To see this, let $\alpha \in (0,1)$ be irrational, and choose $y \in [0,\alpha)$. (The analysis for $y \in (\alpha, 1]$ is similar, mutatis mutandis.)
I will prove differentiability in two parts, the first part is unnecessary, but motivates the slightly more involved second part.
The key aspect here is that there are at most $n |y-\alpha|$ (not $n|y-\alpha|+1$!!!) rationals with denominator $n$ in $[y,\alpha]$. This is because $\alpha$ is irrational. Following a similar line of reasoning to above, we can replace the $n+1$ by $n |y-\alpha|$ to get the estimate:
$$\mathrm{Var}_{[y,\alpha]} f \leq \sum_{n=1}^{\infty} \frac{2n|y-\alpha|}{n^3} \leq K|y-\alpha|$$
We are almost finished, the only issue is to replace $K$ by an arbitrary $\epsilon>0$. Pick an $\epsilon > 0$, and choose $N$ such that $\sum_{n=N+1}^{\infty} \frac{2n}{n^3} &lt \epsilon$. Now choose $\delta>0$ such that the interval $(\alpha-\delta, \alpha+\delta)$ contains no rational of the form $\frac{k}{n}$, where $k \leq n \leq N$. (Such a $\delta$ must exist since $\alpha$ is irrational.) Then if $y \in (\alpha-\delta, \alpha+\delta)$, we can repeat the above analysis to get the estimate:
$$\mathrm{Var}_{[y,\alpha]} f \leq \sum_{n=N+1}^{\infty} \frac{2n}{n^3} |y-\alpha| \leq \epsilon|y-\alpha|$$
Finally, since $|f(y)-f(\alpha)| \leq \mathrm{Var}_{[y,\alpha]} f$, we have that $f'(\alpha)$ exists and is $0$.
A: $f$ is of bounded variation on $[a,b]$iff the variation of $f$ is finite. This (the variation of $f$ over $[a,b]$) is by definition the supremum over all sums 
$$\sum|f(x_i)-f(x_{i+1})|$$
where the supremum is taken over all partitions $a=x_0 &lt ... &lt x_k = b$ 
How bad can it get in your example? The value of $f$ at $0$ and $1$ is not relevant of course.
A particular unlucky choice of partition will (more or less obviously) collect all rational numbers as one end point of an interval of the partition and an irrational number as the other one -- I leave it to you to show this is the worst possible case :-) . Assuming such a partition can be realized you need to estimate
$$\sum_{q = m/n, (m,n)=1} \frac{1}{n^3}$$
(with $q\in[0,1]$) In $(0,1]$ the number of fractions $m/n$ with $(m,n)=1$ is quite obviously bounded by $n$, so you need to show $$\sum_n \frac{1}{n^2}&lt \infty$$ which I guess you know if you are pondering about $BV$ functions.
This answers only the first part of the question. Since I don't know what you learned about $BV$ functions I cannot guess which kind of reasoning would be appropriate for you to show $f^'=0$, one way to show this is to prove $$ \int_0^1 f(x) g^'(x)dx =0 $$ for every compactly supported $g\in C^1[0,1]$
