Bounded function on compact space Let $X$ be a compact space, and let $f:X\rightarrow\mathbb{R}$ be a continuous function. Show that there exists $C>0$ such that $|f(x)|<C$ for all $x\in X$. Then show that there are points $x_1,x_2\in X$ such that $f(x_1)=\inf f(x)$ and $f(x_2)=\sup f(x)$
So I understand that this works intuitively, but I'm not sure how to go about proving it.
 A: Consider the set $S = \{f(x) : x \in X\}$. Then $\sup f(x) = \sup S$. Clearly, either $\sup S \in S$ or $\sup S$ is a limit point of $S$. If $\sup S \in S$, then there exists $x_1 \in X$ such that $f(x_1) = \sup f(x)$ and we're done.
Suppose now that $\sup S$ is instead a limit point of $S$. Then there exists a sequence of function values $f(y_n) \to \sup S$ as $n\to\infty$. Since $X$ is compact, $(y_n)$ has a convergent subsequence $(y_{n_k})$ converging to a limit $x_1$. By continuity, $\sup f(x) = \lim_{n\to\infty} f(y_n) = \lim_{k\to\infty} f(y_{n_k}) = f(x_1)$. 
The proof for $\inf f(x)$ is entirely analogous.
A: I'm gonna assume you're aware of the following: if $K \subset (X,d)$ is compact and $f:(X,d) \to (Y,d')$ is continuous, then $f(K) \subset (Y,d')$ is compact. In particular, if $Y = \mathbb{R}$ with the usual distance, it is bounded and closed.
Now, in this particular case, this implies that $f(X)$ is bounded, and therefore there exists $C > 0$ such that $|f(x)| < C$ for all $x \in X$. and $\inf f(X)$, $\sup f(X)$ exist. 
Let's show that $\inf f(X) = f(y)$ for some $y$. Let $z = \inf f(X)$. Since $z$ is an infimum, there exists $(x_n) \subset f(X)$ such that $x_n \to z$. Since $f(X)$ is closed, we know that $z \in f(X)$, i.e. that there exists $y \in X$ with $f(y) = z$. You can prove it likewise for $\sup f(X)$.
A: $f(X)\subseteq{\bf{R}}$ is compact, it is bounded and closed, in particular, $\sup f(X)\in f(X)$.
