Suppose $f$ is a bounded function on $[a,b]$, its total variation is defined to be $$ \mathrm{Var}(f) = \sup_{\tau} \sum_{i=1}^{n} |f(x_{i})-f(x_{i-1})|. $$ Furthermore, if $f$ is continuous on $[a,b]$, it can be proved that $$ \mathrm{Var}(f) = \lim_{|\tau|\to 0}\sum_{i=1}^{n} |f(x_{i})-f(x_{i-1})|, $$ where $|\tau|$ denotes the mesh of the partition $\tau$.
When $f$ is discontinuous, can anyone give a counterexample to the above equality, that is the total variation cannot always be calculated by letting the mesh approaching zero?
To see that the limit and supremum in question might produce difference results define $f:[0,1]\to[0,1]$ as $$ f(x) = \begin{cases} 0, &\text{ if } \ x \neq 1/2, \\ 1, &\text{ if } \ x = 1/2. \end{cases} $$ Clearly $\mathrm{Var}(f) = 2$, but any partition of $[0,1]$, with diameter however small, will result in $0$ variance-sum unless it includes the point $1/2$ in the partition of $[0,1]$.