Examples about bounded variation function 
Problem. Give an example of a function with bounded variation $f:[0,1] →\mathbb R$ with $f'$ integrable in $[0,1]$, and such that the function $g:[0,1]→\mathbb R$ defined by
  $$g(x)=f(x)-f(0)-\int_0^xf'(s)\,\mathrm ds$$
  vanishes at the points $\displaystyle x_n = \sum_{j=1}^n\frac{1}{2^j}$, $g$ is positive on $(x_n,x_{n+1})$ if $n$ is odd and is negative if $n$ is even.

This example does not seem intuitive for me. How can I try to build this function? Is there any strategy for this?
In addition to the assumptions, the unique other restriction that I saw clearly: $$\int_0^xf'(s)\,\mathrm ds ≠ f(x) - f(0).$$ The only non-trivial function that I know that satisfies this is the Cantor-Lebesgue function, but this function does not work for this problem. So, I tried to start with a function that was not absolutely continuous, but I could not get an example.
 A: $\def\aeeq{\stackrel{\mathrm{a.e.}}{=}}\def\d{\mathrm{d}}$Denote by $C(x)$ the Cantor function on $[0, 1]$ and define$$
h(x) = \begin{cases}
\dfrac{1}{2} C(2x); & 0 \leqslant x \leqslant \dfrac{1}{2}\\
\dfrac{1}{2} C(2(1 - x)); & \dfrac{1}{2} < x \leqslant 1
\end{cases},
$$
then $h$ is continuous, $h(0) = h(1) = 0$, $0< h(x) \leqslant 1$ for $0 < x < 1$, $h' \aeeq 0$, and the variation of $h$ on $[0, 1]$ is$$
V_{0, 1}(h(x)) = \frac{1}{2} V_{0, \frac{1}{2}}(C(2x)) + \frac{1}{2} V_{0, \frac{1}{2}}(C(2(1 - x))) = \frac{1}{2} V_{0, 1}(C(x)) + \frac{1}{2} V_{0, 1}(C(x)) = 1.
$$
Now, denote $x_0 = 0$ and take$$
f(x) = \sum_{k = 1}^∞ (-1)^k (x_k - x_{k - 1}) h\left( \frac{x - x_{k - 1}}{x_k - x_{k - 1}} \right) I_{[x_{k - 1}, x_k)}(x),
$$
where $I_A$ is the indicator function. Note that $f(x)$ is continuous at $x = 1$ since $x_n - x_{n - 1} → 0\ (n → ∞)$ and $0 \leqslant h(x) \leqslant 1$ for $0 \leqslant x \leqslant 1$, thus $f$ is continuous on $[0, 1]$. The variation of $f$ on $[0, 1]$ is\begin{align*}
V_{0, 1}(f(x)) &= \sum_{k = 1}^∞ (x_k - x_{k - 1}) V_{x_{k - 1}, x_k} \left( h\left( \frac{x - x_{k - 1}}{x_k - x_{k - 1}} \right) \right)\\
&= \sum_{k = 1}^∞ (x_k - x_{k - 1}) V_{0, 1}(h(x)) = \sum_{k = 1}^∞ (x_k - x_{k - 1}) = \lim_{n → ∞} x_n = 1.
\end{align*}
Also, $f' \aeeq 0$. Thus,$$
g(x) = f(x) - f(0) - \int_0^x f'(s) \,\d s = f(x). \quad \forall x \in [0, 1]
$$
For any $n \geqslant 1$, $g(x_n) = f(x_n) = (-1)^{n + 1} (x_{n + 1} - x_n) h(0) = 0$. If $n$ is odd, then$$
g(x)\Bigr|_{(x_n, x_{n + 1})} = f(x) \Bigr|_{(x_n, x_{n + 1})} = (-1)^{n + 1} (x_{n + 1} - x_n) h\left( \frac{x - x_n}{x_{n + 1} - x_n} \right) > 0.
$$
If $n$ is even, then$$
g(x)\Bigr|_{(x_n, x_{n + 1})} = f(x) \Bigr|_{(x_n, x_{n + 1})} = (-1)^{n + 1} (x_{n + 1} - x_n) h\left( \frac{x - x_n}{x_{n + 1} - x_n} \right) < 0.
$$
Therefore, this $f$ satisfies all the requirements.
