# Is it possible for function $f : \mathbb{R} \to \mathbb{R}$ have a maximum at every point in a countable dense subset of its domain?

Is it possible for function $f : \mathbb{R} \to \mathbb{R}$ have a maximum at every point in a countable dense subset of its domain ? The motivation for this question is I have a sequence of functions $\{f_n\}$ where the number of maxima increases with $n$ and I am interested to know what happens to the sequence of functions.

PS : every function of the sequence has a finite number of maxima.

EDIT : $f$ should not be constant function.

-
What if the function $f$ was constant?... ;) Or do you want to have the set of maximas to be countable? If you can allow ''more'' maximas, the constant function would be an example of one such function. – Patrick Da Silva Jun 3 '11 at 5:04
@Patrick: Or, if you insist on countable, the characteristic function of the rationals. – Ross Millikan Jun 3 '11 at 5:06
@Patrick : maxima means second derivative should be negative. – Rajesh Dachiraju Jun 3 '11 at 5:07
@Rajesh: So you want your function to be twice differentiable. Please include that in the statement of your question. – Yuval Filmus Jun 3 '11 at 5:08
@Yuval : Ok, i do not need it to be differentiable but i do not want constant function either. – Rajesh Dachiraju Jun 3 '11 at 5:10

Thomae's function has a strict local maximum at each rational number.

I believe the Weierstrass function is another example.

Another question on this site posed the problem of showing that if $f$ is continuous and not monotone on any interval, then $f$ has a local maximum at each point in a dense subset of $\mathbb{R}$.

-
You're quick, aren't you. XD – Patrick Da Silva Jun 3 '11 at 5:13
I'd like to know if it's possible for the sequence of functions $\{f_n\}$ where each one is smooth to converge to such a function ? – Rajesh Dachiraju Jun 3 '11 at 5:20
@Rajesh: The Weierstrass function is a uniform limit of smooth functions. – Jonas Meyer Jun 3 '11 at 5:22

Sample paths of Brownian motion have this property (with probability $1$), see here.

-
See the third item in that subsection (Qualitative properties). – Shai Covo Jun 3 '11 at 5:17