Calculate total variation on $[0,2\pi]$ of $f(x)$ Calculate total variation on $[0,2\pi]$ of $f(x)$, where 
$\begin{align*}
f(x) = 
\begin{cases}
\sin(x),  & \text{if $x \in [0,\pi)$} \\
2, & \text{if $ x= \pi$}\\
\cos(x), & \text{if $x \in (\pi,2\pi]$}
\end{cases}
\end{align*}$
My idea
Let $P$ a partition of $[0,2\pi]$, where exists $r$ such that $x_r=\pi$. Then,
$$\sum_{i=1}^{n} |f(x_{i})-f(x_{i-1})|=\sum_{i=1}^{r-1} |f(x_{i})-f(x_{i-1})|+|f(x_r)-f(x_{r-1})|\\ +|f(x_{r+1})-f(x_r)|+ \sum_{i=r+2}^{n} |f(x_{i})-f(x_{i-1})| \\= \sum_{i=1}^{r-1} |\sin(x_{i})-\sin(x_{i-1})|+|2-\sin(x_{r-1})|+|\cos(x_{r+1})-2|\\+ \sum_{i=r+2}^{n} |\cos(x_{i})-\cos(x_{i-1})|$$ but how can I bound that sums?, these sums converges and I didn´t know it?, and what happen if the point $\pi$ is not in the partition? But the real problem is calculate the $\mathrm{sup}\sum_{i=1}^{n} |f(x_{i})-f(x_{i-1})|$ and I suppose that is $2$, could you guide me?. Thanks, for your help.
 A: Total variation is additive over subintervals as $V_a^b(f) = V_a^c(f)+ V_c^b(f)$ for $a < c < b$.  
Thus, $V_0^{2\pi}(f) = V_{0}^{\pi/2}(f)+V_{\pi/2}^{2\pi}(f) = 1 + V_{\pi/2}^{2\pi}(f)$ since the sine function is monotone increasing on $[0,\pi/2]$ and $V_{0}^{\pi/2}(f) = |\sin(\pi/2) - \sin(0)|=1$.
Taking a partition $\frac{\pi}{2} = x_0 < x_1< \ldots  < x_{r-1} < x_r = \pi < x_{r+1} < \ldots <x_n = 2\pi$ we have, using the monotonicity of $f$ on $[0,\pi/2)$ and $(\pi,2\pi]$,
$$\sum_{j=1}^n |f(x_j) - f(x_{j-1})|\\ = \sum_{j=1}^{r-1}|\sin(x_j)- \sin(x_{j-1})| + |f(x_r) - \sin(x_{r-1})|+ |\cos(x_{r+1}) - f(x_r)| + \sum_{j=r+1}^{n}|\cos(x_j)- \cos(x_{j-1})|\\ =  1 - \sin(x_{r-1}) + |2 - \sin(x_{r-1})| + |2 - \cos (x_{r+1})| +1 - \cos(x_{r+1})$$
The supremum over partitions is approached as $x_{r-1} \to \pi$ and $\sin(x_{r-1}) \to 0$ from the left and $x_{r+1} \to \pi$ and $\cos(x_{r+1}) \to -1$ from the right. Thus,
$$V_{0}^{2\pi}(f) = 1 + V_{\pi/2}^{2\pi}(f) = 1+8 = 9$$
Note that the sum over a partition that excludes the single point $\pi$ is always dominated by a sum over a partition with $\pi$ included, since
$$|f(x_{r+1}) - f(x_{r-1})| \leqslant |f(x_{r+1}) - f(x_{r})|+ |f(x_{r}) - f(x_{r-1})|$$
