If $X$ is compact and $f:X\to\mathbb{R}$ is continuous, then $f$ attains the values $\inf\{f(x):x\in X\}$ and $\sup\{f(x):x\in X\}$ I need to show that if $f$ is continuous real valued function on the compact space $X$,
then there exist points $x_1,x_2\in X$ such that $f(x_1)=\inf\{f(x):x\in X\}$ and $f(x_2)=\sup\{f(x):x\in X\}$.
Now since $X$ is compact then $f(X)$ is compact as the continuous image of a compact space. And what is next? Also in a T2 space a compact space is closed and bounded. So f[X] being in the Reals is compact thus bounded thus it has a infimum and a supremum?
 A: Since $f(X)$ is compact it is closed and bounded. Every closed set contains all it's limit points. $\inf\{f(x):x \in X\}$ and $\sup\{f(x):x \in X\}$ are limit points of $f(X)$ and thus in $f(X)$. Since $f$ is a function there must be a point in the domain which corresponds to every point in the image. This shows the existence of $x_1$ and $x_2$.
A: You can do it as follows. Since $f$ is continuous, $f(X)$ is a (bounded and nonempty) interval. Thus $\sup f(X)$ exists. Moreover, there exists a sequence of points in $f(X)$ such that $y_n\to \sup f(X)$. In particular, to each $y_n$ we can associate a value $x_n\in X$ where $f(x_n)=y_n$. Since $x_n\in X$, $\langle x_n\rangle $ is also bounded, so by the compactness of $X$, it has a convergent subsequence, $x_{n_k}\to \ell\in X$. What happens with $y_{n_k}=f(x_{n_k})$, by continuity and compactness of $f$ and $f(X)$ respectively? The infimum case is analogous.
SPOILERS AHEAD

 In the limit $y_{n_k}\to \sup f(X)$. But then $\sup f(X)=\lim f(x_{n_k})=^{1} f\left(\lim x_{n_k}\right)$ $=f(\ell)\in f(X)$, so the supremum is attained. ${}^1:$ We use that $f$ is continuous here.

A: Hint: What sort of subsets of $\mathbb{R}$ are compact?
