# 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.

• It seems that I've made the mistake of not checking wikipedia first. This page has a nice proof along the same lines of some of these answerers: en.wikipedia.org/wiki/… – Omnomnomnom Jul 7 '13 at 13:11
• Note, this problem is badly formed - you define the domain of $f$ as $\mathbb R$ and then ask about a maximum. What you want is the maximum on $[a,b]$ – Thomas Andrews Nov 29 '13 at 20:38
• Is their anything around for if a function is continuous on [a,b] attains a min value on [a,b]. I know how to prove it using sequences and compact sets. I need a third way to go about it. Any suggestions? – OLE Nov 27 '16 at 6:20
• @EduardoO. are you asking specifically about attaining the minimum as opposed to the maximum? Then of course, all the same arguments work. If you'd prefer not to slightly rephrase one of the arguments below, it suffices to show that the function $g(x) = -f(x)$ attains a maximum, then use one of the arguments directly. – Omnomnomnom Nov 27 '16 at 6:24
• @Omnomnomnom To be honest some of the arguments below get me lost as some of things I have yet to learn or are completely new to me. I need a proof that I can interpret to show the $minimum$, yes opposed to the maximum. Thanks for any guidance you can provide – OLE Nov 27 '16 at 6:30

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$.

• I really like this proof! I think you do need to show that $u$ is finite before extracting a suitable sequence, otherwise you can't use convergence. Perhaps that needs its own proof, then. – Omnomnomnom Jul 5 '13 at 11:02
• Of course, this is just the compactness proof in disguise. It contains a proof that $[a,b]$ is sequentially compact. – Chris Eagle Jul 7 '13 at 9:28
• @user14111 good catch, I think you're right about that. As for my earlier comment: if $f$ is unbounded on $[a,b]$, then by the construction described $f$ would map a convergent sequence to an unbounded sequence, which is a contradiction of continuity, so boundedness doesn't require its own proof after all. – Omnomnomnom Jul 7 '13 at 13:09

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$

This theorem ultimately depends on the completeness of real number system and can't be proven without using any result equivalent to the completeness of real number system. If we assume that every continuous function on a closed interval is bounded then we can provide a very simple proof of the current problem being discussed here.

Under this assumption we have the existence of $M = \sup\{f(x)\mid x \in [a, b]\}$. If $f(x)\neq M$ for all $x \in [a, b]$ then the function $g(x) = 1/(M - f(x))$ is continuous in $[a, b]$ and hence bounded in $[a, b]$. On the other hand by definition of $M$ we can find $x \in [a, b]$ such that $M - f(x)$ can be made arbitrarily small. Thus $g(x)$ can be made arbitrarily large. This contradiction shows that we must have $f(x) = M$ for some $x \in [a, b]$.

The result that every continuous function is bounded on a closed interval is itself another property of continuous functions which can't be proved without using completeness of real number system.

I have presented various proofs of these properties of continuous function here.

• Thank you for your answer, that's a neat twist! I looked through your linked proofs, which do an impressive job of explaining the topological notion of compactness on $\mathbb R$. However, I think the better way to approach the proof that "continuous function on a closed interval is bounded" is to use the fact that sequential continuity is equivalent to continuity for metric spaces, and proceed via the B-W theorem (which itself has a neat little proof here en.wikipedia.org/wiki/Bolzano%E2%80%93Weierstrass_theorem#Proof ) – Omnomnomnom Jul 7 '13 at 13:23
• Omnomnomnom, actually the kind of proofs which I have put in my blogs are somewhat easier to understand but limited in their generality (especially they will need lot of development if we want to go for $\mathbb{R}^{n}$). Whereas the proofs based on BW and sequential continuity are the ones which can be applied in a very general context. It also depends on the intended audience and my blog is targeted at people who probably never had undergraduate / graduate education in maths (like myself), but who find maths exciting. – Paramanand Singh Jul 8 '13 at 4:17
• I think sequential continuity is a lot easier to understand than the Heine Borel principle. In this case, it means we don't need to worry about compactness. – Omnomnomnom Jul 8 '13 at 4:47
• I agree the proofs based on Heine Borel are on a higher level. Even I had a very difficult time understanding Heine Borel when I first studied from Hardy's Pure Mathematics. – Paramanand Singh Jul 8 '13 at 5:08
• It seems I didn't give your link a good enough look before making my judgment. I think your direct use of Dedekind's Theorem is far more intuitive that the notion of sequential compactness. – Omnomnomnom Jul 8 '13 at 12:07

I don't know how you can avoid compactness entirely. Here's one that uses sequential compactness in the form of the Bolzano-Weierstrass theorem, "every bounded sequence has a convergent subsequence". (To justify that theorem to beginners, you could take it as an axiom that every bounded monotonic sequence converges, and show them the proof that every sequence has a monotonic subsequence.) For some reason that escapes me, this proof is often done in two stages, first proving that the function is bounded and then showing that the it attains a maximum.

Given a continuous real-valued function $f$ on $[a,b]$, we will show that the set $Y = f([a,b])$ has a greatest element.

For each positive integer $n$, define a finite set $Q_n = \{p/q: p,q \text{ integers, } 0 < q \le n, |p| \le n\}$.

Choose $y_n\in Y$ so as to maximize the number of elements in the set $\{r\in Q_n: y_n > r\}$, and choose $x_n\in[a,b]$ with $f(x_n) = y_n$.

The sequence $\{x_n\}$ has a subsequence converging to a point $c\in[a,b]$. Since $f$ is continuous, the corresponding subsequence of $\{y_n\}$ converges to $f(c)$. We will show that $f(c)$ is the greatest element of $Y$.

Assume for a contradiction that $f(c)<y\in Y$. Choose a rational number $r$ so that $f(c)<r<y$. Because of the way $y_n$ was chosen, we have $y_n > r$ whenever $r\in Q_n$. Since $r\in Q_n$ for all sufficiently large $n$, we have $y_n > r > f(c)$ for all sufficiently large $n$. But this is absurd, since $\{y_n\}$ has a subsequence converging to $f(c)$.

I found the following proof by Takeshi Saito in "How to Learn Mathematics(New Edition)" edited by Kunihiko Kodaira.

Let $$X$$ be a non-empty compact space.
Let $$f(x)$$ be a real valued continuous function on $$X$$.
Assume that $$f(x)$$ doesn't attain a maximum value on $$X$$.
Then for any $$x \in X$$, there exists $$t \in X$$ such that $$f(x) < f(t)$$.
Let $$U_t := \{x\in X | f(x) < f(t)\}$$ for $$t \in X$$.
$$f(x)$$ is continuous on $$X$$, so $$U_t$$ is an open set of $$X$$.
$$f(x)$$ doesn't attain a maximum value on $$X$$, so $$(U_t)_{t\in X}$$ is an open cover of $$X$$.
$$X$$ is compact, so there exists a finite subcover $$U_{t_1}, \cdots, U_{t_n}$$.
Let $$k \in \{1, \cdots, n\}$$ be an integer such that $$f(x_k) = \max \{f(t_1), \cdots, f(t_n)\}$$.
$$t_k \in X$$. So there exists an integer $$l$$ such that $$t_k \in U_{t_l}$$.
Then, $$f(t_k) < f(t_l) \leq f(t_k)$$. This is a contradiction.
So, $$f(x)$$ attains a maximum value on $$X$$.

Let $$a, b \in \mathbb{R}$$ such that $$a \leq b$$.
Then, $$[a, b]$$ is a non-empty compact space.
So, if $$f(x)$$ is a real valued continuous function on $$[a, b]$$, then $$f(x)$$ attains a maximum value on $$[a, b]$$.

We now prove that $$[0, 1]$$ is compact.
The discrete space $$\{0, 1\}$$ is finite. So $$\{0, 1\}$$ is compact. So, $$\{0,1\}^{\mathbb{N}}$$ is compact.
Let $$f : \{0,1\}^{\mathbb{N}} \to \mathbb{R}$$ be a function such that $$f(\{a_n\}) := \sum_{n=1}^\infty \frac{a_n}{2^n}$$.
Then, $$f$$ is continuous, so the image of $$f = [0,1]$$ is compact.

Theorem. Let $$f:[a,b]\to\mathbb{R}$$ be continuous. Then $$f([a,b])$$ is bounded.

Proof (indirectly) avoiding compactness: Since $$f$$ is continuous at $$a,$$ there exists $$\delta>0$$ such that for any $$x\in [a,a+\delta),$$ we have $$f(a)-1< f(x) Hence $$f$$ is bounded on $$[a,a+\delta/2].$$ Write $$A=\{x\in [a,b]: f \mbox{ is bounded on } [a,x]\}.$$ Then $$a+\delta/2\in A,$$ and $$b$$ is an upper bound of $$A.$$ So, let $$c=\sup(A).$$ Now, $$a+\delta/2 \leq c\leq b.$$ Continuity of $$f$$ at $$c$$ implies that there exists $$\delta_1>0$$ such that for any $$x\in (c-\delta_1,c+\delta_1)\cap [a,b],$$ we have $$f(c)-1 That is, $$f$$ is bounded on $$(c-\delta_1,c+\delta_1)\cap [a,b].$$ Let $$d\in (c-\delta_1,c).$$ Then $$f$$ is bounded on $$[a,d].$$ It follows that $$f \mbox{ is bounded on } [a,d]\cup\big( (c-\delta_1,c+\delta_1)\cap [a,b]\big).$$
Since $$[a,c]\subseteq [a,d]\cup\big( (c-\delta_1,c+\delta_1)\cap [a,b]\big),$$ we have $$c\in A.$$

Further, if $$c then choose $$\delta_2=\min\{\delta_1,(b-c)/2\}.$$ Then $$[a,c+\delta_2]\subseteq [a,d]\cup\big( (c-\delta_1,c+\delta_1)\cap [a,b]\big).$$ It follows that $$f$$ is bounded on $$[a,c+\delta_2].$$ So, $$c+\delta_2\in A.$$ This contradicts the fact that $$c=\sup(A).$$ Therefore, $$c=b.$$

Hence $$c=b$$ and $$c\in A.$$ That is, $$b\in A.$$ Therefore, $$f$$ is bonded on $$[a,b].$$ QED