TITLE: Proof that $n(c)$, the number of the roots of the equation $f(x)=c$, is measurable.
QUESTION [5 upvotes]: The entire question is:

Let f be a continuous function on $[a,b]$. Denote $n(c)$ the number of the roots of the equation $f(x)=c$, which is finite or infinite. Proof that $n(c)$ is measurable on $\mathbb{R}$.

What I don't understand is how to use the characteristic function to express $n(c)$ and then illustrate $n(c)$ is measurable.

REPLY [6 votes]: I prefer to give you some context for the problem as well as a source you can consult. [Since this is not an "answer" I expect few votes.]
Let $f:[a,b]\to[m,M]$ be a continuous function and, for each $m\leq y\leq M$ define  $N_f(y)$ to be the number of elements in the level set $\{x\in [a,b]: f(x)=y\}$ [take $\infty$ if this set is not finite].
This function $N_f$ is called the Banach indicatrix of $f$.

Theorem [Banach]  The Banach indicatix of a continuous function $f$ is measurable [even Borel measurable, in Baire class 2] and moreover $\int_m^M
  N_f(y)\,dy$ is exactly equal to the total variation of $f$ on $[a,b]$.
In particular $N_f$ is integrable if and only if $f$ has bounded
variation.

Most real analysis texts will prove or mention this at least.  I like this source for the theorem and its proof:  Natanson, Theory of Functions of a Real Variable, Vol. I, p.225. See also Saks, Theory of the Integral, p. 280 for a simliar proof.
The original source:  S. Banach, Sur les lignes rectifiables et les surfaces dont l'aire et finie.  Fund. Math. 7, 225-237 (1925)