TITLE: Question about Riemann integral and total variation
QUESTION [17 upvotes]: Let $g$ be Riemann integrable on $[a,b]$, $f(x)=\int_a^x g(t)dt $ for $x \in[a,b]$.
Can I show that the total variation of $f$ is equal to $\int_a^b |g(x)| dx $?

REPLY [20 votes]: If $g$ is non-negative, $f$ is non-decreasing and the total variation is $f(b)-f(a)$ which coincides with $\int_a^b{|g(x)|}dx$, so the theorem is true.
For arbitrary $g$, write $g=g^+-g^-$, with at least one of $g^+(x)$ and $g^-(x)$ equal to 0.
Fix $\varepsilon>0$. There is a mesh $\delta^+>0$ such that for all partitions $a=x_0<\dots<x_n=b$ of $[a,b]$ finer than $\delta^+$ (i.e. $\max_i x_{i+1}-x_i\le\delta^+$),
$$\sum_{i=1}^n (x_i-x_{i-1})\inf g^+([x_{i-1},x_i]) \ge \int_a^b{g^+(x)}dx - \varepsilon/2$$
We define $\delta^-$ symmetrically, and let $\delta=\min (\delta^+,\delta^-)$.
Now let's compute the total variation for a partition $x_0<\dots<x_n$ of $[a,b]$ finer than $\delta$:
$$V=\sum_{i=1}^n |f(x_i)-f(x_{i-1})|$$
For any interval $I=[x_i,x_{i-1}]$, if $\inf g^+(I)>0$, then $g^+$ is always non-zero on this interval and $g^-$ must be identically zero. Then
$$\begin{aligned}
|f(x_i)-f(x_{i-1})| =&\int_I{g^+(x)}dx\\
\ge&(x_i-x_{i-1})\inf g^+([x_{i-1},x_i])\\
=&(x_i-x_{i-1})\inf g^+([x_{i-1},x_i]) + (x_i-x_{i-1})\inf g^-([x_{i-1},x_i])
\end{aligned}$$
The bound holds similarly when $\inf g^-(I)>0$. Finally when $\inf g^+(I)=\inf g^-(I)=0$,
$$\begin{aligned}
|f(x_i)-f(x_{i-1})| \ge&0\\
=&(x_i-x_{i-1})\inf g^+([x_{i-1},x_i]) + (x_i-x_{i-1})\inf g^-([x_{i-1},x_i])
\end{aligned}$$
So we can write
$$V\ge \sum_{i=1}^n (x_i-x_{i-1})\inf g^+([x_{i-1},x_i]) + (x_i-x_{i-1})\inf g^-([x_{i-1},x_i])$$
and because the partition is finer than $\delta$:
$$V \ge \left(\int_a^b{g^+(x)}dx - \varepsilon/2\right)+\left(\int_a^b{g^-(x)}dx - \varepsilon/2\right)$$
that is
$$V \ge \int_a^b{|g(x)|}dx - \varepsilon$$
We also have the obvious upper bound
$$V=\sum_{i=1}^n \left|\int_{x_{i-1}}^{x_i} {g(x)} dx\right|\le \sum_{i=1}^n \int_{x_{i-1}}^{x_i} {|g(x)|} dx = \int_a^b{|g(x)|}dx$$
Since this holds for all $\varepsilon$, the total variation (the upper bound of the total variation over all partitions) is precisely $\int_a^b{|g(x)|}dx$.