Let $f\colon \mathbb R\to\mathbb R$ be a continuous function such that $f(i) = 0$

Take a function whose graph is a triangle connecting $(0, 0)$ to $(1/2, 1/2)$ to $(1, 0)$.

Then connect $(1, 0)$ to $(3/2, 3/4)$ to $(2, 0)$.

Then connect $(2, 0)$ to $(5/2, 7/8)$ to $(3, 0)$.

Continue in this manner, and the range is $[0, 1)$, which is not closed in $\mathbb{R}$.


Moral of the story: The image $f([i, i + 1])$ is closed for each $i$. But a countable union of closed sets isn't always closed.


Take $$f(x)=\frac{\sin\pi x}{1+e^{-x}}.$$ Then show $\mathrm{Im}(f)=(-1,1)$.

Or:

$$g(x)=\sin\pi x \arctan x$$

Then $\mathrm{Im}(g)=\left(-\frac \pi 2,\frac \pi 2\right).$

Basically, this is because $x\mapsto \frac{1}{1+e^{-x}}$ and $x\mapsto\arctan x$ are increasing functions with images $(0,1)$ and $(-1,1)$ respectively.