Question on step in proof of Weierstrass thereom (of max and min)

compactnessmaxima-minimaproof-explanationreal-analysis

Let $(X,d)$ be a metric space and $A\subset X$ compact and not empty and $f: A \to \mathbb{R}$ a continuous function.
Then f assumes its maximum and minimum.

Our proof

Since $A$ is compact, so is $f(A) \subset \mathbb{R}$ and therefore bounded and closed.
Let $y^* := \sup_{a \in A} f(a) \in \mathbb{R}$.
Now there exists a sequence $(y_n)_{n \in \mathbb{N}} \subset f(A)$ with $y_n \to y^*$.

And here's the problem
But then there also exists a bounded sequence $(x_n)_{n \in \mathbb{N}} \subset A$ so that $y_k = f(x_k)$.

Why does this exist? If $f$ were invertible (it's continuous, so it would just have to be monotone as well), I would understand that the sequence $x_k = f^{-1}(y_k)$ is well defined for all $k$, but $f$ is not necessarily monotone.

The proof continues like this:

From the Bolzano-Weierstrass theorem we know that there exists a convergent subsequence $(x_{n_k})_{k \in \mathbb{N}} \subset (x_n)_{n \in \mathbb{N}}$ so that $x_{n_k} \to x^*$ for some $x^* \in A$.

Since $f$ is continuous, we have $f(x_{n_k}) \to f(x^*)$.
On the other hand, we have $f(x_{n_k}) = y_k \to y^*$, and therefore $y^* = f(x^*) \in f(A)$. $\square$

Best Answer

By definition, $f(A)=\{f(x):x\in A\}$. Hence, if $y\in f(A)$, there is $x\in A$ with $f(x)=y$. No invertibility needed.

Related Question