# A function in [0, 1] that has a local maximum which is not a global maximum

I am trying to come up with an example of a function $f:[0,1]\to\mathbb{R}$, that has a local maximum which is not a global maximum.

The picture in my mind looks like this:

what would be a function that has a local maximum which is not a global maximum?

Thank you

• You could use standard polynomial interpolation techniques to define the particular polynomial you want. Google "Lagrange Interpolation" if you want to do this. I'd probably just choose something "easier" to write that works, such as $f(x) = x\sin(\frac{x}{2\pi})$. While this is more complicated than an interpolating polynomial, it's easy to write down without having to figure out the particular polynomial to use. – Mark Sep 9 '17 at 3:44
• Why not use a piecewise linear function? It's hard to get simpler than that. – quasi Sep 9 '17 at 3:44
• What do you mean by “general equation”? – gen-z ready to perish Sep 9 '17 at 4:06
• The function $x(x-1/2)^2$ might be another option... – Fabian Sep 9 '17 at 4:54

$f(x)=(x-\frac{1}{4})^2(x-\frac{3}{4})^2$? That should have a local maximum at $x=0.5$

Edit: Oops, general equation. There's no way to parametrise something like this.

• This works totally fine. Thank you so much! – Jun Jang Sep 9 '17 at 4:05

Let $f(x) =0$ for $x\in [0,1),$ with $f(1) = 1.$ Then $f$ has a local maximum of $0$ at every $x\in [0,1),$ and a global maximum of $1$ at $1.$