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.