TITLE: The intermediate value theorem implies a point at which function changes sign.
QUESTION [8 upvotes]: Let $f$ be continuous in $[a,b]$ and $f(a)<0,\ f(b)>0$.
Then by the intermediate value theorem, $\exists c\in(a,b)$ such that $f(c)=0$.
I was wondering if it is also true that there exists $d\in(a,b)$ such that $f(d)=0$ and $f$ changes sign of the function at $d$. (there is some $>0$ such that $()<0$ when $\in(−,)$ and that $()>0$ when $\in(,+)$ It seems clear but I am not sure how to prove if it is true.

REPLY [3 votes]: As mentioned, some plateau functions can do this, but they satisfy your condition if it is made a little weaker, requiring one side to have a neighborhood of nonnegativity and the other to have a neighborhood of nonpositivity. In fact, the $\sin(1/x)$ example also has that property, as commented.
Below is a sketch of a Cantor-set based function that I believe fails to have even the weaker version of that property. The idea is to add alternating peaks above and below gaps of the Cantor set of various sizes. I'm afraid I'm  feeling rushed, but hopefully it gets the idea across.
It also inspires a conjecture: any such function which fails to have even this weak property, must obtain the value zero uncountably many times. I am not at all confident in this, but it seems worthy of some thought.