# Function whose sets of discontinuities and zeros are the rationals

Question: Is there a real valued function $$f:\mathbb{R}\to\mathbb{R}$$ such that its set of discontinuities is $$\mathbb{Q}$$ and its set of zeros $$\{x\in \mathbb{R}\mid f(x)=0\}$$ is also $$\mathbb{Q}$$?

It's well known that the Thomae function has as discontinuities the rationals. However, its zero set is $$\mathbb{R}\setminus\mathbb{Q}$$. On the other hand, the characteristic function of the set of irrational numbers has the rationals as zero set but its set of discontinuities is $$\mathbb{R}$$. So none of the candidates, that come to mind first, work.

There isn't such a function. If $$f$$ is nonzero and continuous at some point $$x$$, then there is a neighbourhood of $$f$$ on which $$x$$ doesn't vanish. Hence if the zero set of $$f$$ is dense, then the function has to be discontinuous at every value on which it doesn't vanish.