# Max and min on compact interval

I have trouble coming up with a counter-example, where

$f:[0,1]\to \mathbb{R}$ bounded, and $\min_{x\in[0,1]} \{f(x)\}$ does not exist.

I know if $f$ is continuous then it does achieve minimum, but what is an example where $f$ is not conitunous and it doesn't achieve minimum?

-
Hint: Redefine the function $f(x)=x$ at $x=0$ appropriately (this won't have a minimum, but the infimum will exist). – David Mitra Feb 7 '13 at 14:39
@DavidMitra I see now. Thank you very much! – mez Feb 7 '13 at 14:42

Hint: Define $f:[0,1]\to \mathbb{R}$ so that $f(x)= -1+2x$ when $x\in \mathbb{R}\setminus\mathbb{Q}$ and $f(x)=0$ when $x\in \mathbb{Q}$. Notice that $-1<f(x)<1$ for all $x\in [0,1]$, but there exists sequences $(r_{i})_{i=1}^{\infty}\subseteq [0,1]$ and $(s_{i})_{i=1}^{\infty}\subseteq [0,1]$ with $\lim_{i\to\infty} f(r_{i})= 1$ and $\lim_{i\to\infty} f(s_{i})= -1$. Hence $f$ does not attain a maximum nor a minimum on the interval $[0,1]$ and it is clearly a bounded function.
Think about it this way: you want to avoid there being a value that $f$ achieves which is smaller than any other value it achieves. So, pick an arbitrary value for $f(1)$, and there has to be some other point where $f$ is smaller. Say $f(\frac{1}{2}) < f(1)$. There has to be somewhere $f$ is smaller than that – try $f(\frac{1}{3}) < f(\frac{1}{2})$. (It doesn't really matter what numbers I use here – I'm picking some so it's obvious how I'll continue, and I'll never run out).
How can we define these values so that $f(1) > f(\frac{1}{2}) > f(\frac{1}{3}) > \dots$, but $f$ remains bounded below? We just need a sequence of reals which is decreasing but bounded below, and there are plenty of those.
Now complete $f$ to a function defined on $[0,1]$ by defining it on all so-far-undefined points to be something that won't cause any problems, e.g. something more than $f(1)$.