Does extreme value theorem hold when continuous is replaced with bounded? The extreme value theorem says that if the domain of a 'continuous' function is compact then both the max and min of the function lies in the domain set. My question is: can the 'continuity' be replaced by 'bounded' function keeping the domain compact and the theorem continue to hold? I haven't seen a proof, but if not, I'd be interested in seeing a counterexample.
 A: I guess I found the counterexample myself. Consider the following function defined on $[0,1]$.
$$f(x) = \left \{ \begin{array}{ll} 2x & \mbox{ if } 0 \leq x < 0.5 \\
0.5 & \mbox{ if } 0.5 \leq x \leq 1 \end{array} \right .
$$
The sup of the function is $1$, but there is no point in the domain $[0,1]$ that 'attains' this point.
A: You cannot expect much help from compactness if you drop continuity. Take the function $x\mapsto\operatorname{sg}x-x$ on the compact interval $[-1,1]$ where 'sg' is the sign in $\{-1,0,1\}$, for a counterexample. Here the maximum and minimum of the function value do not exist, so the $\sup$ and $\inf$ of the function are not attained for any value in the domain.
In geneneral, for a function for which continuity is not demanded, topological properties of the domains and codomain have no influence on the kind of behaviour that the function can exhibit.
A: Consider the following bounded function defined on the closed interval $[0,1]$. 
Let $f(x)=x$ for $0\leq x < 1$, and $f(1)=0$.
Then
$$
\sup_{x \in [0,1]} f(x)=1,
$$
but there is no element $x_0$ in the domain for which $f(x_0)=1$.
A: Let $\varphi: \mathbb R \to [0,1]$ be your favourite bijection. Then consider the function $f(x) = \arctan \varphi(x)$. You have $\sup_{x\in [0,1]} |f(x)| = \sup_{y \in \mathbb R} \left\lvert\arctan y\right\rvert = \tfrac\pi2$ yet the supremum is never attained.
