Given $f : [a, b] \rightarrow [c, d]$ is a continuous function, and for each $y ∈ [c, d]$, the set $\{x \in [a, b] : f(x) = y\}$ has at most $2018$ elements, I wish to show that total variation of $ f$ over $[a,b]$ is less than or equal to $2018(d − c)$.
I know total variation is defined to be the supremum of $\sum|{f(x_i)-f(x_{i-1})}|$ and also is the sum of positive and negative variations of $f$ over $[a,b]$. So do I consider that?
Let $P=\left \{ x_i \right \}^n_i$ be a partition of $[a,b]$. Refine this partition to the partition $P'$ by adding the points $Q_i=f^{-1}(f(x_i))=\left \{ a_{i1},\cdots ,a_{in_i} \right \};\ 1\le n_i\le 2018;\ a_{i1}<\cdots <a_{in_i}.\ $ Of course, each $x_i$ is included in these fibers.
Now, $S_{P'}^+(f)$ and $S_{P'}^-(f)$ are sums of non-negative differences of the form
$f(a_{ij})-f(a_{i'j'});\ 1\le i,i'\le n;\ 1\le j\le n_j;\ 1\le j'\le n_{j'}.$
Evidently, if $i=i'$, then $f(a_{ij})-f(a_{i'j'})=0$ because in this case, each of $a_{ij}$ and $a_{i'j'}$ are in $Q_i$.
Thus, the sum $S_{P'}^+(f)$ is of the form $(f(a_i)-f(a_j))^+ ;\ i\neq j;\ a_i\in Q_i;\ a_j\in Q_j$ and $a_j$ is the immediate predecessor of $a_i$ in $P'.$
Choose $x_2$, if there is one, to be the least element of $P'$ greater than $a$ such that $(f(x_2)-f(a))^+$ is not equal to zero. Then, by the previous remarks, $x\in Q_j;\ j\neq 1.$ Now choose $x_3$, the least element greater than $x_2$ such that $(f(x_3)-f(x_2))^+$ is not equal to zero. Continuing in this way, we obtain a telescoping sum which is equal to $f(x)-f(a)$ for some $x\in [a,b];\ f(x)>f(a).$ Clearly, $f(x)-f(a)\le d-c.$
Now choose the least element in $P'$, if there is one, that does not occur among any of the elements in the previous sum. (If there is none, then the fibers of $f$ are singletons). Repeat the above process, to obtain another telescoping sum whose sum is $\le d-c.$
Repeating the process, until we exhaust the $Q_i$, we obtain $S^+(f)$ as a sum of telescoping sums, each of which is $\le d-c.$ That is, $S^+(f)\le A(d-c),\ $ where $0\le A\le 2018.$ This implies, of course, that $V^+(f)\le A(d-c)$.
Now, we do the same thing for $S_{P'}^-(f):$ choose $y_2$, if there is one, to be the least element of $P'$ greater than $a$ such that $(f(y_2)-f(a))^-$ is not equal to zero. Note $y_2\neq x_2$. Also, as before, $y_2\in Q_j;\ j\neq 1.$ Now choose $y_3$, the least element greater than $y_2$ such that $(f(y_3)-f(y_2))^-$ is not equal to zero. Note, $y_3\neq x_3.$ Continuing in this way, we obtain a telescoping sum which is equal to $f(y)-f(a)$ for some $y\in [a,b];\ f(x)>f(a)$ and of course $f(y)-f(a)\le d-c.$
We continue this process as before, but now, since $y_i\neq x_i;\ 1\le i\le n_i$, there are at most $2018-A$ such telescoping sums and so $V^-(f)\le (2018-A)(d-c).$
To finish, note that $V(f)=V^+(f)+V^-(f)\le (A(d-c)+(2018-A)(d-c)=2018(d-c).$