Construct a continuous real valued function which takes zero on integers and such that image of function is not closed. I am trying to construct a continuous real valued function $f:\mathbb{R}\to \mathbb{R}$ which takes zero on all integer points(that is $f(k)=0$ for all $k\in \mathbb{Z}$) and Image(f) is not closed in $\mathbb{R}$
I had $f(x)=\sin(\pi x) $ in mind. But image of $f(x)$ is closed. 
I have a feeling that we can use some clever idea to modify this function such that it satisfy our given condition. 
 A: 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$]. 
A: If $f$ verifies the desired propery, its restriction $f|_{[n,n+1]}$ gives a continuous function on $[n,n+1]$ that is zero on the edges of the interval, for any $n \in \mathbb{Z}$. Reciprocally, if we have $f_n : [n,n+1] \to \mathbb{R}$ continuous with $f_n(n) = f_n(n+1) = 0$ for each integer $n$, by the gluing lemma this gives a continuous function $f: \mathbb{R} \to \mathbb{R}$ with $f(n) = f_n(n) = 0$. This means that we can approach the problem somewhat 'locally', i.e. we can fix an interval $[n,n+1]$. Now, the function
$$
f_n (t) = \mu_n\sin(\pi(t-n))
$$
takes values on $\mu_n[-1,1] = [-\mu_n,\mu_n]$ and $f_n(n) = f_n(n+1) = 0$. Thus, the family $(f_n)_n$ induces a continuous function $f$ that vanishes at $\mathbb{Z}$ and
$$
f(\mathbb{R}) = \bigcup_{n \in \mathbb{Z}} f_n([n,n+1]) = \bigcup_{n \in \mathbb{Z}}[-\mu_n,\mu_n]
$$
so the problem reduces to choosing a sequence $(\mu_n)_n$ so that the former union is open. One possible choice is $\mu_n = 1-\frac{1}{|n|}$ so that
$$
f(\mathbb{R}) = \bigcup_{n\in \mathbb{Z}}[-\mu_n,\mu_n] = \bigcup_{n\in \mathbb{N}}[-1+\frac{1}{n},1-\frac{1}{n}] = (-1,1).
$$
A: 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)$
A: Consider
$$f(x) = \sin^2 (\pi x)\frac{x^2}{1+x^2}.$$
Then $f$ is continuous, $f=0$ on the integers, but $f(\mathbb R) = [0,1).$
A: 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)
$$

Plotted together with the asymptotes:


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\!\!\!\!/)
$$

(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.

