Construct a continuous real valued function which takes zero on integers and such that image of function is not closed.

The image of $\sin(\pi x)$ is closed because the peaks all reach 1 and -1. To make it open, we need the peaks to get arbitrarily close to some value, but never reach them. The easiest way is to use an amplitude modifier that asymptotes to a constant nonzero value at infinity, such as $\tanh(x)$. Thus, we can use the function $$ f(x) = \sin(\pi x)\tanh(x), $$ which is obviously continuous, zero at each integer, and can be easily shown to have image $(-1,1)$


The simplest solution that would come to mind is to take that sine function and multiply it with an amplitude envolope that only approaches $1$ in the $\pm$infinite limit: $$ f(x) = \frac{1+|x|}{2+|x|}\cdot\sin(\pi\cdot x) $$ Graph of the enveloped oscillating function Plotted together with the asymptotes: Envelopes of that function


Incidentally, since you just said “not closed” but not whether it should be bounded, we could also just choose

$$ f\!\!\!\!/(\!\!\!\!/x\!\!\!\!/)\!\!\!\!/ =\!\!\!\!/ x\!\!\!\!/\cdot\!\!\!\!/\sin\!\!\!\!/\!\!\!\!\!\!\!\!/(\pi\!\!\!\!/\cdot\!\!\!\!/ x\!\!\!\!/) $$ Unbounded envelope oscillation

(The image of this is all of $\mathbb{R}$ which is actually closed, as the commenters remarked.)


A more interesting example that just occured to me:

$$ f(x) = \sin x \cdot\sin(\pi\cdot x) $$ Why does this work? Well, this function never reaches $1$ or $-1$, because for that to happen you would simultaneously need $x$ and $\pi\cdot x$ to be an odd-integer multiple of $\tfrac\pi2$. But that can never coincide because $\pi$ is irrational! It does however get arbitrarily close to $\pm1$, in fact it gets close to $-1$ quite quickly due to $\tfrac\pi2 \approx 1.5 = \tfrac32$. But it never actually reaches either boundary.

The solution that relies on π∉ℚ


Using piecewise linear functions (instead of $\sin (\pi x)$) makes this simpler. For each $n \neq 0$ draw the triangle with vertices $(n,0),(n+1,0)$ and $(n+\frac 1 2, 1-\frac 1 {|n|})$. You will immediately see how to construct an example. [You will get a function (piecewise linear function) whose range contains $1-\frac 1 {|n|}$ for each $n$ but does not contain $1$].