Are there functions whose roots are infinitely dense on the real number line? Related question:-
My question is a generalization of this question.
WARNINGS:-
$(1)$ This question might not have all the needed tags.
$(2)$ I am not a mathematician. So if this question doesn't make sense then please forgive me.
Clarification of the title of this question:-
Some people might ask what do I mean by

infinitely dense on the real number line.

So let me clarify the title with an example. If you take $\mathbb{Z}$ then it is not infinitely dense because in a finite interval on the real line, there exists only finitely many elements of $\mathbb{Z}$
But if you take, for example $\mathbb{Q}$ then it is infinitely dense because in a finite interval of the real line, there exists infinitely many elements of $\mathbb{Q}$.
How I got interested:-
I started wondering about this question after watching a few youtube videos about roots of a function and fractals.
Let,$\mathcal{R}(f)$ be the set of the roots of $f$
If you take $f=sin(x)$ then $\mathcal{R}(f)$ is infinite but not infinitely dense.
I started thinking about that how cool the graph of a function $f$ would look like if $\mathcal{R}(f)$ is infinitely dense because then the graph would intersect the $x$ axis infinitely many times
My questions:-
$(1)$ Let, $f$ be a continuous function.
Then, does there exist $f$ such that $\mathcal{R}(f)$ is infinitely dense?
$(2)$ If the answer to $(1)$ is "no" then why? If "yes" then how to construct such functions?
(If the question is poorly written in mathematical terms then sorry, I am not a mathematician)
 A: Since you say that you're not from a mathematical background, I'll try to exaplain the basics as much as I can. Please feel free to ask for further clarification.
That said, first note that what you're calling infinitely dense is actually simply called dense in the mathematical literature. A dense subset of $\Bbb R$ is

any subset $S$ of $\Bbb R$ such that $S \cap (a,b) \neq \phi$ for any $a,b \in \Bbb R (a \neq b)$.

Now, any function $f : \Bbb R \to \Bbb R$ is is called continuous at $x \in \Bbb R$ if

for any $\epsilon>0$, there is $\delta>0$ such that $|y-x|<\delta$ implies $|f(y)-f(x)|<\epsilon$.

This is also known as the $\epsilon-\delta$ definition of continuity. $f$ is called continuous (on $\Bbb R$) if it is continuous at each $x \in \Bbb R$.
Now that we're done with the basics, let's come to your question. As pointed out in the comments, there is an unique function that satisfies your criteria, the zero function i.e.

$f : \Bbb R \to \Bbb R$ such that $f(x)=0$ for any $x \in \Bbb R$.

Let's actually verify that it's continuous. Choose any $\epsilon>0$. Let $\delta=1$ (or anything else that you fancy). Then, $|y-x| < \delta$ implies $|f(y)-f(x)|=|0-0|=0<\epsilon$. So, the zero function is continuous.
Also, $\mathcal R(f)=\Bbb R$, so the density property is clearly satisfied.
That deals with existence. For the uniqueness part, let $g$ be another such function. Then, if for any $x \in \Bbb R$, consider $\epsilon =  {1 \over n}$ for some $n \in \Bbb N$. Then, by continuity, there must be $\delta$ such that $|y-x|<\delta$ implies $|f(y)-f(x)|<\epsilon={1 \over n}$.
By density of $\mathcal R(f)$, there is $y_0 \in (x-\epsilon,x+\epsilon)$ such that $f(y_0)=0$. But then $|f(x)-f(y_0)|=|f(x)|<{1 \over n}$. This is true for each such $n$, so $f(x)=0$.
This is true for each $x \in R$, so $f$ is the zero function. We are done.
