$f$ continuous on [a,b] and $|f|$ being of bounded variation implies that $f$ has bounded variation on $[a,b]$?

Suppose $f$ is continuous on $[a,b]$ and $\vert f \vert$ has a bounded variation. I would like to show $f$ has bounded variation.

Using the intermediate value theorem we can take a partition such that (1) $f(x_{i+1}), f(x_i)\ge 0$ or $f(x_{i+1}), f(x_i) \le 0$. We can use the fact that $|f|$ has bounded variation to find an upper bound over the sums of $\vert f(x_{i+1})-f(x_i)\vert$. How do we know that the property (1) will be satisfied once our partition is refined?

• I would deeply appreciate it if anyone could suggest a detailed solution since mentioning that all the values $f(x_i)$ will be positive does not suffice to understand the big picture of the solution itself. Commented May 19, 2021 at 5:29

Hint: Use the intermediate value theorem to force each pair $f(x_k), f(x_{k+1})$ to both be either $\geq 0$ or $\leq 0$.
• @Thomas Can you explicitly provide more details on how the refinement could ensure the existence of all partition elements $x_i$ with $f(x_i) \geq 0$ or $f(x_i) \leq 0$? Moreover, intermediate value theorem just ensures that function $f$ can take on any given value between $f(a)$ and $f(b)$ at some point $\in [a,b]$ Commented May 19, 2021 at 5:26
• @Snowflake: Maybe a visualization will help without giving away too many details: For each partition, we sum y-distances between points on the graph of $f$. If two points lie on opposite sides of the x-axis, their y-distance splits into the y-distances of each point to the x-axis. By continuity, the graph intersects the x-axis between the two points, so the split can be written as the sum of two consecutive y-distances along the graph, where the two points in each measurement are not on different sides of the x-axis. Commented May 20, 2021 at 18:52