A continuous function with positive and negative values but never zero?

The function $f:\mathbb Q\setminus \{0\}\to \mathbb R$ defined by $f(q)=q$ is continuous at each rational number $q\neq 0$, takes positive and negative values, but is never $0$. The intermediate value theorem is valid for functions $f: I\subset \mathbb R\to\mathbb R$, where $I$ is a closed interval (i.e connected set in $\mathbb R$).

The example you give with $e^z:\mathbb C\to\color{red}{\mathbb C}$ actually doesn't show anything, because there is no total ordering on the complex numbers. Also you can read from Wikipedia:

The intermediate value theorem generalizes in a natural way: Suppose that $X$ is a connected topological space and $(Y, <)$ is a totally ordered set equipped with the order topology, and let $f : X → Y$ be a continuous map. If $a$ and $b$ are two points in $X$ and $u$ is a point in $Y$ lying between $f(a)$ and $f(b)$ with respect to $<$, then there exists $c$ in $X$ such that $f(c) = u$.

Edit: If $f$ is continuous, then the IVT can fail to apply either because the domain of $f$ is not connected, or because the codomain is not totally ordered:

In my example, $\mathbb R$ is totally ordered and the IVT fails to apply because $\mathbb Q\setminus \{0\}$ is not connected.

In the OP example $e^z:\color{blue}{\mathbb C}\to\color{red}{\mathbb C}$, $\quad \color{blue}{\mathbb C}$ is connected and the IVT fails to apply because $\color{red}{\mathbb C}$ is not totally ordered.


If you remove zero from $\mathbb{R}$ the result is a disconnected set whereas if you remove zero from $\mathbb{C}$, it is still connected.

If $f$ is a continuous function on a connected set $C$, then $f(C)$ is connected.

Hence if $f$ is a real valued continuous function that never takes the value zero, then we must have $f(C) \subset (-\infty, 0)$ or $f(C) \subset (0, \infty)$, so it cannot take both positive and negative values.

If $f$ is a complex valued continuous function that never takes the value zero, then all we can really say is that $f(C) \subset \mathbb{C} \setminus \{0\}$.

An analogy is that I can't pass a car on a single lane road (well, maybe...), but I can easily walk around an obstacle in the middle of a field.


It depends of the domain( for a real valued function)of the function. If it is connected, it is impossible, since the image of a connected space by a continuous function is connected. For a complex function the notion of positive and negative don't exist