# Non-constant continuous function having uncountably many zeros?

I want to have an example of a non-constant function which has uncountably many zeros?

Is the following function continuous?

$f(x)=\prod\limits_{\alpha\in \mathbb{R\setminus Q}}(x-\alpha)$ If it so, it will be the required example.

• You are trying to find a continuous function on the line that is $0$ at all irrationals? That function by continuity would be everywhere $0.$ Take a look at $f(x)=0, x\in [0,1], f(x) = x, x<0, f(x) = x-1,x>0.$
– zhw.
Sep 21 '15 at 16:04
• I assume we're only talking about functions $\Bbb R \to \Bbb R$? Sep 21 '15 at 16:32

Let $C$ be any uncountable closed set, for example the Cantor set, and for every $x \in \mathbb{R}$, define $f(x) = d(x,C) = \inf\{d(x,c) : c \in C\}$. Since $C$ is closed, $f(x) = 0$ if and only if $x \in C$. Since $C$ is uncountable, we only need to verify that $f$ is continuous. To see this, fix $x,y \in \mathbb{R}$, and $c \in C$. Then by the triangle inequality, we have $$d(x,c) \leq d(x,y) + d(y,c)$$ Taking the infimum over $c \in C$ gives us $$f(x) \leq d(x,y) + f(y)$$ Similarly (interchanging the roles of $x$ and $y$ above), we have $$f(y) \leq d(x,y) + f(x)$$ Combining these two inequalities, we conclude that $$|f(x) - f(y)| \leq d(x,y)$$ which shows that $f$ is continuous (in fact, uniformly continuous).

P.S. I used the notation $d(x,y)$ above for the distance between $x$ and $y$, because the same proof works in any metric space that has an uncountable closed set $C$. In the case of $\mathbb{R}$, of course, we set $d(x,y) = |x-y|$.

• So here...what mattered really was that C was nowhere dense and closed?
– BLBA
Jul 15 '20 at 14:31
• @AnnieLeKatsu It doesn't matter whether $C$ is nowhere dense. All that is required is that $C$ is closed in order to conclude that $f$ is uniformly continuous and that $f(x) = 0$ if and only if $x\in C$. Then, to satisfy the OP's request, $C$ an be any closed uncountable set. We could equally well have chosen, say $C = [0,1] \subset \mathbb R$. But the Cantor set is more fun.
– user169852
Jul 15 '20 at 19:39

Your product does not converge for $x \in \mathbb{Q}$, so it does not define a continuous function. In fact the irrationals are dense, so a continuous function which is constant on the irrationals is constant everywhere.

If you are OK with a function which is locally constant in some regions, you can just take a continuous function with compact support, such as $f(x)=\max \{ 1-|x|,0 \}$. In some sense this feels like cheating to me, because it only achieves the goal by gluing a constant function to a non-constant function.

If you want a function which is nowhere locally constant and yet has uncountably many zeros, I can give a somewhat nonconstructive example: the trajectories of a Brownian motion have this property with probability $1$.