# Construct function with $2$ local minima at $x_1$ and $x_2$

I am trying to construct a continuous differentiable function $f(x)$ that for $x_1$ and $x_2$ takes the value $0$ and have global minimum at these points, i.e. $f(x_1)=f(x_2)=0$ and $f'(x_1)=f'(x_2)=0$, where $x_2>x_1$.

No other local minimum can exist than those at $x_1$ and $x_2$.

So far, I have been able to construct a function $g(x)$ that in principle looks what I am looking for:

$$g(x) = 2(e^{x-x_1}+e^{x_2-x})-\cos(2\pi x)-(1+2e).$$

A plot of this function for the constants $x_1=0$ and $x_2=1$ can be found here at WolframAlpha.

As can be seen in the plot, $g(x)$ fulfills the idea of only having two local and global minima, however these are not position at $x_1$ and $x_2$.

Q: Any suggestions on either how to modify $g(x)$ or how to construct a new function that fulfills the demands?

Try $f(x) = (x-x_1)^2(x-x_2)^2$.

Then $f(x) \geq 0$ for all $x$, and $f(x) = 0$ iff $x \in \{x_1, x_2\}$, and $f'(x_i) = 0$.

How about$(x-x_1)^2(x-x_2)^2?$

• Bingo ${}{}{}{}{}{}$. – copper.hat Feb 13 '13 at 18:21

Assuming that $x_1 \neq x_2$ then a simple quartic will do the trick.

How about $y=(x-x_1)^2(x-x_2)^2$?

We see that $dy/dx = (x-x_1)(x-x_2)(2x-x_1-x_2)$ meaning that $x=x_1$ and $x=x_2$ are both stationary points. Moreover, $(d^2y/dx^2)(x_1) = 2(x_1-x_2)^2 > 0$ and $(d^2y/dx^2)(x_2) = 2(x_1-x_2)^2 > 0$. Hence $x=x_1$ and $x=x_2$ are both local minima.

What about the other turning point: $x=\frac{1}{2}(x_1+x_2)$? Well:

$$\left.\frac{d^2y}{dx^2}\right|_{x=\frac{1}{2}(x_1+x_2)} =-(x_1-x_2)^2 < 0 \, .$$

It follows that $x=x_1$ and $x=x_2$ are the only minima and they are on the same level, i.e. $y(x_1) = y(x_2)$. The only other extremum is a maximum.