Prove that a continuous function on a closed interval attains a maximum
As the title indicates, I'd like to prove the following:
If $f:\mathbb R\to\mathbb R$ is a continuous function on $[a,b]$, then $f$ attains its maximum.
Now, I do have a working proof: $[a,b]$ is a connected, compact space, which means that because $f$ is continuous, $f([a,b])$ is compact and connected as well. Therefore, $f([a,b])$ is a closed interval, which means it has both a minimum and, as desired, a maximum.
What I would like, however, is a proof that doesn't require such general or sophisticated framework. In particular, I'd like to know if there's a proof that is understandable to somebody beginning calculus, one that (at the very least) doesn't invoke compactness. Any comments, hints, or solutions are welcome and apreciated.
Here’s a sketch of one possible argument. Let $u=\sup_{x\in[a,b]}f(x)$. (Note that I allow the possibility that $u=\infty$.) There is a sequence $\langle x_n:n\in\Bbb N\rangle$ in $[a,b]$ such that for each $n\in\Bbb N$, $u-f(x_n)<\frac1{2^n}$ if $u\in\Bbb R$ and $f(x_n)>n$ if $u=\infty$. Extract a monotone subsequence $\langle x_{n_k}:k\in\Bbb N\rangle$. Being a monotone, bounded sequence, $\langle x_{n_k}:k\in\Bbb N\rangle$ converges to some $y$. (Note that you have to use the completeness of $\Bbb R$ in some way, and this is the most elementary that occurs to me.) Moreover, $y\in[a,b]$, and $f$ is continuous, so $f(y)=\lim\limits_{k\to\infty}f(x_{n_k})=u$.
Yes, quite a few such proofs exist. You first prove that a continuous function is bounded, and apply the Bolzano-Weierstrass theorem. Here’s such a proof from my lecture notes in a first course in analysis:
By the earlier result, $\,f$ is bounded. Consider the image of $[a,b]$ under $f$: $$A = f([a,b]) = \left\{f(x) : x \in [a,b]\right\}.$$ $f$ bounded means that $A$ is bounded as a subset of $\mathbb{R}$. We also have that $A\neq \emptyset$. We will prove the existence of $x_2$, and the existence of $x_1$ is proved similarly.
Since $A$ is bounded and non-empty, there is a supremum: $M=\sup A$. Given any positive integer $n$, $M-1/n$ cannot be an upper bound for $A$. Then there exists some $x_n \in [a,b]$ such that % $$M-\frac{1}{n} < f(x_n) \leq M. \tag{$*$}$$ By Bolzano-Weierstrass, $x_n$ has a convergent subsequence $x_{n_{j}} \to x$. Since $a\leq x_{n_{j}}\leq b$, $a\leq x\leq b$. By the continuity of $f$, $\,f(x_{n_{j}}) \to f(x)$. But by $(*)$, $\,f(x_{n_{j}}) \to M$. By the uniqueness of the limit, $\,f(x)=M$. Now set $x_2=x$. $\square$