# A Function with Exactly $k$ Minima in a Bounded Space

Is it possible to have a function with the following properties?

(i) The function maps a bounded $n$-dimensional space $\mathcal{X}$ (say $\left[0,1\right]^n$) onto a bounded interval $\mathcal{Y}$ (say $\left[0,1\right]$);

(ii) The function has exactly $k$ minima in $X$, whose locations are distributed randomly, and whose vaues are distributed randomly over $\mathcal{Y}$. Ideally, the value of the global minimum (in $\mathcal{X}$) should correspond to the lowerbound of $\mathcal{Y}$.

(i) It does not matter if the function has additional minima outside of $\mathcal{X}$;

(ii) The function does not need to be differentiable over $\mathcal{X}$: this means that the local minima could also be, for example, kinks;

(iii) The number of maxima in $\mathcal{X}$ does not matter;

(iv) It is also OK if the minima and maxima are interchanged (i.e. if the function has $k$ maxima and any number of minima).

-

On $\mathbb{R}^{n}$ define $f(x)=e^{-\frac{1}{1-|x|^{2}}}$ for $|x|<1$ and $f(x)=0$ for $|x|\geq 1$. This is a smooth function with a maximum at the origin that vanishes outside of the unit ball. Given a point $a\in\mathbb{R}^{n}$ and $\epsilon>0$ define $g_{a,\epsilon}(x)=f((x-a)/\epsilon)$ this has a single maximum at $a$ and vanishes outside of $B_{\epsilon}(a)$. Given arbitrary distinct points $\{a_{1},...,a_{k}\}$ in $[0,1]^{n}$ and arbirary $r_1,...,r_k>0$ define $F(x)=\sum_{i=1}^{k}r_i\cdot g_{a_{i},\epsilon}(x)$ where $\epsilon=\min_{i\neq j}(\{\frac{|a_i-a_j|}{2}\})$. Then the $B_\epsilon(a_i)$ are all pairwise disjoint so $F$ has exactly $k$ maxima.