Say you have a function such as $f(x)=1+\sin(x)$ that is defined from $-\frac{\pi}{4}$ to $\frac{\pi}{4}$. Everywhere else, the function takes on the value $-\frac{1}{2}$.
How do you compute the total variation? I've been looking at examples of polynomials, and it's easier in that case. The derivative of the function is decreasing on the first half of the interval and increasing on the second. Do I break my variation into the sum of two vars?
In your case, $a_1=-\pi/4$ and $a_2=\pi/4$. The former contributes $$|-1/2- (1+\sin(-\pi/4)| + 0 \tag{1}$$ (The second term is zero because $f(a_1)=f(a_1+)$.) The latter contributes $$ 0 + |(1+\sin(\pi/4) - (-1/2)| \tag{2}$$ Finally, the integral of $|f'|$ is $$ \int_{-\pi/4}^{\pi/4} |f'(x)|\,dx = \int_{-\pi/4}^{\pi/4} \cos x\,dx \tag{3} $$ The total variation is the sum of $(1)$, $(2)$, and $(3)$.