The Weierstrass’ Extreme Value Theorem states that that given a compact subset $K$ $\subseteq$ $\mathbb{R}^n$ , if $f$: $\mathbb{R}^n$ $ \to $ $\mathbb{R}$ is continuous on $K$, then exists points $a$,$b$ $\in$ $K$| $f(a)$ $\leq$ $f(x)$ $\leq$ $f(b)$, $\forall$ $x$$\in$$K$.
Could you give me two examples on it? One basic illustrating the theorem in $\mathbb{R}^n$ = $\mathbb{R}$. And another with violation of the assumptions ($K$ is compact and $f$ is continuous on $K$). The theorem is a bit messy in my mind because I can't clearly visualize what is happening.
In all the following we take functions $\;f:[0,1]\to \Bbb R\;$:
$$\text{Examples:}\;\;\;\;f(x)=x\,,\;\;\; f(x)=x^2\;$$
$$\text{Counterexamples:}\;\;\;\;f(x)=\begin{cases}\log x\,,\,\,x\neq0\\{}\\1\,,\,\,\,\,x=0\end{cases}\;,\;\;f(x)=\begin{cases}\frac1x\,,\,\,x\neq0\\{}\\1\,,\,\,\,\,x=0\end{cases}$$
Find the maximum and/or minimum values in the first two, and show there are not such values for the last two.