# Improved intermediate value theorem

Suppose $f\colon [a,b] \to \mathbb{R}$ is a continuous function with $f(a)<0$, $f(b)>0$. Can it be proved that there exists $s_1\leq s_2$ and $\epsilon>0$ such that $f(s)=0$ for all $s\in[s_1,s_2]$, whilst $f(s)<0$ for all $s\in [s_1-\epsilon, s_1)$ and $f(s)>0$ for all $s\in (s_2,s_2+\epsilon]$?

If not, what about in the case that one assumes $f$ is $C^1$, or smooth?

• It sounds very plausible to me. I think $s_1\le s_2$ is very important (as opposed to $s_1<s_2,$ where the claim would be too strong). Can't say how to prove it, though. Sep 4, 2018 at 13:49
• @user3342072 The conjecture would not hold for $s_1=s_2$, it is easy to construct a smooth function $f\colon [0,1] \to \mathbb{R}$ which is strictly increasing from 0 to 1/3, equal to 0 from 1/3 to 2/3, and strictly increasing from 2/3 to 1. Sep 4, 2018 at 14:34
• @user3342072 Not necessarily. There is a counterexample if one assumes $s_1=s_2$ (but $s_1<s_2$ works) and another one if $s_1<s_2$ is assumed (but $s_1=s_2$ works).
– mfl
Sep 4, 2018 at 14:44
• As we have seen, it is in general not true with the requirement $s_1 < s_2$. Thus the only chance would be $s_1 = s_2$. It is obviuos that there exist $s_0 \in (a,b)$ and $\epsilon >0$ such that $f(s_0) = 0$ and $f(s) < 0$ for $s \in [s_0 - \epsilon, s_0)$ or $f(s) > 0$ for $s \in (s_0,s_0+ \epsilon]$. But you cannot achieve "and" as GEdgar's answer shows. The example can be made smooth. Sep 4, 2018 at 15:12
• A more appropriate generalization is that there is a first number $c\in(a, b)$ and a last number $d\in(a, b)$ such that $f(c) =f(d) =0$. Also $c$ may be equal to $d$. Sep 4, 2018 at 17:54

### Counterexample

Let $f(x) = x^2 \sin^2(1/x) \operatorname{sign}(x)$ with $f(0)=0$ (plot). For $x<0$ the function oscillates between $0$ and negative values, and for $x>0$ it oscillates between $0$ and positive values. At $x=0$ the function crosses the $x$-axis, but it has zeros arbitrarily close to $x=0$ so there is no interval $(-\epsilon,0)$ on which $f$ is strictly negative, and no interval $(0, \epsilon)$ on which $f$ is strictly positive.

• Nice example (+1). $f^{-1}(0)$ has only one non-isolated component. Of course there are no counterexamples where all components of $f^{-1}(0)$ are isolated since then the number of components of $f^{-1}(0)$ must be finite. Sep 4, 2018 at 16:24
• Great example and easy to visualize! Thanks :) Sep 6, 2018 at 9:58

Do you know the Cantor set? Perhaps you can construct a continuous function $f$ on $[0,1]$ so that:

$f$ is positive on $\left(\frac{1}{3},\frac{2}{3}\right)$
$f$ is negative on $\left(\frac{1}{9},\frac{2}{9}\right)$ and $\left(\frac{7}{9},\frac{8}{9}\right)$
$f$ is positive on $\left(\frac{1}{27},\frac{2}{27}\right)$ and $\left(\frac{7}{27},\frac{8}{27}\right)$ and $\left(\frac{19}{27},\frac{20}{27}\right)$ and $\left(\frac{25}{27},\frac{26}{27}\right)$
and so on, with finally $f$ zero on the rest (the Cantor set).

Then take $a=1/6, b=1/2$. • Thanks for the great suggestion :) I had seen this construction on a different stackexchange question before but didn't realize it would apply to give the desired counter-example :) Sep 4, 2018 at 17:34

This is possible if $f$ does not need to vanish on $[s_1,s_2]$ — and impossible if it needs to.

I will first consider the case where $f$ does not necessarily vanish on $[s_1,s_2]$. Let $Z=f^{-1}(0)$ be the set of zeroes of $f$ on $[a,b]$. By the intermediate value theorem $Z\neq\emptyset$.

We can let $s_1=\min Z$ and $s_2=\max Z$. The set $Z$ is a closed (and compact) set, so the minimum and maximum exist. If you are not convinced, replace minimum and maximum by infimum and supremum and show that they must in fact be in $Z$ by continuity of $f$.

We have $a<s_1\leq s_2<b$ since $f(a)\neq0\neq f(b)$. On $[a,s_1)$ the function $f$ only takes negative values. If there was a positive or zero value, the intermediate value theorem would lead to a contradiction with minimality of $s_1$. Similarly $f$ is positive on $(s_2,b]$. If you choose $\epsilon=\frac12\min(s_1-a,b-s_2)$, the desired properties are satisfied apart from $f|_{[s_1,s_2]}\equiv0$.

However, the requirement that $f$ vanishes between $s_1$ and $s_2$ is generally not possible to satisfy for smooth functions. Now we can no longer simply choose $s_1=\min Z$ and $s_2=\max Z$ — and indeed there are functions for which no choice works. For every closed subset $C\subset(a,b)$ there is a smooth function $f\colon[a,b]\to\mathbb R$ so that $f(a)<0<f(b)$ and $f^{-1}(0)=C$. (See this MathOverflow question. I will not go into the details here.)

Now if $C$ is such that all points are accumulation points but the interior is empty, then your desired properties cannot all be satisfied. Since $C$ has empty interior, we necessarily have $s_1=s_2$. (By assumption $[s_1,s_2]\subset C$, so $s_1<s_2$ implies that $C$ has interior points.) The zeroes accumulate at $s_1=s_2\in C$, so for any $\epsilon>0$ there are zeroes in $(s_1-\epsilon,s_1]$ or $[s_2,s_2+\epsilon)$.

On yet another note, your claim is true if $f$ is real analytic. Now there are finitely many zeroes and they are isolated. (The zeroes of a non-constant analytic function cannot accumulate.) Isolation implies $s_1=s_2$. This zero needs to be such that $f$ is negative left of it and positive right of it (near the point).

The zeroes $z_1<z_2<\dots<z_n$ of $f$ split $(a,b)$ into open subintervals $(a,z_1),(z_1,z_2),\dots$. On each of these intervals $f$ is positive or negative. There are two adjacent intervals so that $f<0$ on the left one and $f>0$ on the right one. (Such a zero has odd degree.) Then the zero $z$ between these intervals will work as your $z=s_1=s_2$. You can also explicitly choose $z=\inf\{x\in[a,b];f(x)>0\}$ if you want. If you want more details on this, I recommend asking a follow-up question. The detailed properties of real analytic functions would be too much of a sidetrack here.

• Great answer, just one point got me confused, you say that if $C$ is such that all points are accumulation points but the interior is empty, then $s_1=s_2$. Is that a typo? Surely if $s_1=s_2$ then $C$ is a single point and we are done? Also I am confused by the last paragraph, could you elaborate it? Sep 4, 2018 at 17:29
• @AerinmundFagelson I elaborated. It is not a typo. $s_1=s_2$ does not mean that $C$ is a single point. The set $[s_1,s_2]$ is a subset of $C$ but not necessarily the whole $C$. I also rewrote the part about analytic functions; I wasn't very clear originally. Sep 4, 2018 at 18:02
• I think you defined $Z$ as the set of zeros of $f$ on $[a,b]$, and $s_1=\min Z$, $s_2=\max Z$. Thus surely if $s_1=s_2$ it follows $Z$ is a single point, so $f$ has a single isolated zero. Am I missing something? Sep 4, 2018 at 20:20
• @AerinmundFagelson I considered several cases. If $f$ does not need to vanish on $[s_1,s_2]$, then I can choose $s_1=\min Z$ and $s_2=\max Z$. But if you add the requirement that $f|_{[s_1,s_2]}=0$, this choice no longer works. I tried to clarify that in my answer. The $s_1$ and $s_2$ are different in different cases. Sep 5, 2018 at 2:59

Edit: I see now that having an interval around the endpoints of the zero set is too strong. The claim is not true for continuous functions.

Let $g:[0,1]\rightarrow\mathbb{R}$ be a continuous function with zero set $\{\frac{1}{n}\mid n>1\}\cup\{0\}$. Then let $h(x)=|g(x)|$. Thus $h$ is nonnegative, and it has the same zero set as $g$. If $f:[-1,1]\rightarrow\mathbb{R}$ is given by $$f(x) = \begin{cases}-h(-x)&x\le0\\h(x)&x\ge0\end{cases}$$ Then it doesn't satisfy the conclusion of the problem.

Ah I see that $s_1$ can equal $s_2$, then this is true.
Let $s_1$ be the max of the closure of $\{s\mid f(s)<0\}$. Then $f(s_1)=0$ while $f(x)\ge0$ for $x>s_1$.
Now let $s_2$ be the max of the the connected component of $\{s\mid f(s)=0\}$ containing $s_1$. Can you see how to finish?
• I originally deleted this answer, because it was wrong, but undeleted it (and added a disclaimer) because it shows how close you can get. You can find a closed interval in the zero set of $f$, where $f$ is negative arbitrarily close to the left endpoint, and positive arbitrarily close to the right endpoint. You just can't get intervals around the endpoints. Sep 4, 2018 at 15:38