Question 1.7.5 (Differential Topology - Guillemin and Pollack) Exhibit a smooth map $f : \mathbb{R} \to \mathbb{R}$ whose set of critical values is dense.
From [Exercise 1.1.18], there is a function $g : \mathbb{R} \to \mathbb{R}$ such that $g(x) = 1$ if $|x| \leq 1/4 $ and $g(x) = 0$ if $|x| \geq 1/2 $. Now, write $ \mathbb{Q} = \{q_1, q_2,...\}$, and then for $i \in \mathbb{N}$, define $g_i :\mathbb{R} \to \mathbb{R}$ by $g_i(x) = q_ig(x-i)$. Now define $f := \sum g_i$, then all the rationals are critical values for $f$ and dense in R.
I understand roughly the solution, except for one point. How can I get the function $g$ from the exercise 1.1.18(a). I think we would have applied a composition of an unknown function or played with parameters of the function provided in the exercise.
Book of Guillemin and Pollack : http://math.ucr.edu/~res/math260s10/old/difftopGP.pdf
Let $f(x) = \exp (-1/(x(1-x)), x\in (0,1), f(x) = 0$ elsewhere. Then $f\in C^\infty(\mathbb {R}),$ and $f(1/2) = e^{-4}$ is a critical value. Let $q_1,q_2, \dots $ be the rationals. Then
$$F(x)=\sum_{n=-\infty}^{\infty}q_nf(x-n)$$
is $C^\infty$ on $\mathbb {R},$ and the critical values of $F$ include $q_1e^{-4},q_2e^{-4},\dots ,$ which comprise a dense subset of $\mathbb {R}.$