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. enter image description here

I have a feeling that we can use some clever idea to modify this function such that it satisfy our given condition.


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 π∉ℚ

  • 1
    $\begingroup$ Can you please tell me how make these graphs? $\endgroup$ – A B Oct 18 '18 at 8:59
  • 2
    $\begingroup$ @StammeringMathematician plotWindow [fnPlot $ \x -> (1+abs x)/(2+abs x)*sin(pi*x)] with dynamic-plot (a Haskell library). $\endgroup$ – leftaroundabout Oct 18 '18 at 9:04
  • 2
    $\begingroup$ @leftaroundabout Thanks. These graphs are beautiful. $\endgroup$ – A B Oct 18 '18 at 9:07
  • 2
    $\begingroup$ The proof that the image of $\sin(x)\sin(\pi x)$ is $(-1,1)$ seems nontrivial. I have no doubt it's true, but it's not clear to me how to prove it. $\endgroup$ – eyeballfrog Oct 18 '18 at 16:55
  • 2
    $\begingroup$ +1 for not deleting the wrong answer and preventing me to make the same mistake! Also, amazing visual explanation $\endgroup$ – F.Carette Oct 19 '18 at 9:50

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)$

  • 9
    $\begingroup$ And if you are not familiar with $\tanh$, you can write a similar function explicitly, for example: $$f(x)=\sin(\pi x)\frac{1}{1+e^x}$$ A rational function (as the modifier factor) may also work, like: $$f(x)=\sin(\pi x)\frac{x^2+1}{x^2+2}$$ $\endgroup$ – Jeppe Stig Nielsen Oct 18 '18 at 9:15
  • 5
    $\begingroup$ "To make it open, we need the peaks to get arbitrarily close to some value, but never reach them" You seem to be confusing the notion of not-closed and open $\endgroup$ – Aleks J Oct 18 '18 at 12:11
  • $\begingroup$ @AleksJ Except for $\emptyset$ and $\mathbb R$, every open set is not-closed. $\endgroup$ – eyeballfrog Oct 18 '18 at 15:58
  • $\begingroup$ @eyeballfrog but not vice versa $\endgroup$ – John Dvorak Oct 18 '18 at 17:03
  • $\begingroup$ I believe that the point @JohnDvorak is making is that the peaks getting arbitrarily close to some value but not reaching it is necessary, but not sufficient, for the image to be open, and that trying to get an open set is not a necessary condition for it being non-closed (although it is sufficient). $\endgroup$ – Acccumulation Oct 18 '18 at 17:31

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$].


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). $$



$$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).$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.