Tutorials › Topology (Undergraduate) › The Extreme Value Theorem For Metric Spaces

Compactness in Metric Spaces · Tutorial 515 of 799

The Extreme Value Theorem For Metric Spaces

Learn why compactness guarantees that continuous real-valued functions attain their extreme values, and how to check the theorem in familiar Euclidean examples.

Intermediate 9 min read

What You'll Learn

  • Prove that the continuous image of a compact space is compact.
  • Show that a nonempty compact subset of the real line has a maximum and a minimum.
  • Combine these facts to prove the Extreme Value Theorem for compact metric spaces.
  • Identify the points where extrema occur in examples on intervals, circles, and disconnected Euclidean sets.
  • Distinguish a maximum or minimum from a supremum or infimum.
  • See why a bounded but noncompact domain may not have attained extreme values.

Why Compactness Guarantees Extreme Values

A continuous function can preserve the closeness of nearby points without having any value that is largest or smallest. The domain matters: on a compact space, continuity forces the set of output values to have enough structure for both extremes to be attained. The proof has two parts. First, continuity carries compactness from the domain to the image. Second, a nonempty compact subset of the real line contains its supremum and infimum.

Throughout, \((X,d)\) is a metric space with its metric topology, and \(\mathbb{R}\) has its standard topology. A space is compact if every open cover has a finite subcover. A function \(f:X\to\mathbb{R}\) is continuous if the preimage of every open set in \(\mathbb{R}\) is open in \(X\). For a nonempty subset \(K\subseteq\mathbb{R}\), a maximum is a value \(M\in K\) such that \(t\le M\) for every \(t\in K\); a minimum is a value \(m\in K\) such that \(m\le t\) for every \(t\in K\). A supremum or infimum need not belong to the set.

Theorem 1 (Continuous images preserve compactness): If \(X\) is compact and \(f:X\to Y\) is continuous, then \(f(X)\), with its subspace topology, is compact.

Proof. Let \(\{V_\alpha\}_{\alpha\in J}\) be an open cover of \(f(X)\), where each \(V_\alpha\) is open in the subspace \(f(X)\). By the definition of the subspace topology, for each \(\alpha\) there is an open set \(O_\alpha\subseteq Y\) such that \(V_\alpha=O_\alpha\cap f(X)\). Continuity makes \(f^{-1}(O_\alpha)\) open in \(X\). These preimages cover \(X\): for each \(x\in X\), \(f(x)\in f(X)\), and some \(V_\alpha\) contains \(f(x)\), so \(x\in f^{-1}(O_\alpha)\). Compactness of \(X\) gives finitely many indices \(\alpha_1,\ldots,\alpha_n\) whose preimages cover \(X\). For every \(y\in f(X)\), write \(y=f(x)\) for some \(x\in X\). That \(x\) belongs to one of the selected preimages, so \(y\in V_{\alpha_i}\) for some \(i\). Thus the selected \(V_{\alpha_i}\) cover \(f(X)\), proving it compact. If \(X=\varnothing\), then \(f(X)=\varnothing\), which is compact because every open cover of the empty set has the empty finite subcover. \(\square\)

Compact Subsets of the Real Line Have Extremes

Theorem 2: Every nonempty compact subset \(K\) of \(\mathbb{R}\) has a maximum and a minimum.

Proof. First we show that \(K\) is bounded. The open intervals \((-n,n)\), for \(n\in\mathbb{N}\), cover \(K\), since every real number lies in one of them. Compactness gives a finite subcover. If \(N\) is the largest index in that finite subcover, then all its intervals lie in \((-N,N)\), so \(K\subseteq(-N,N)\). Since \(K\) is nonempty and bounded above, completeness of \(\mathbb{R}\) gives \(M=\sup K\).

We next show that \(K\) is closed. Fix \(x\in\mathbb{R}\setminus K\). For each \(y\in K\), let \(r_y=|x-y|/3\), which is positive because \(x\ne y\). The intervals \(V_y=(y-r_y,y+r_y)\) cover \(K\). Compactness gives a finite subcover \(V_{y_1},\ldots,V_{y_n}\). Let \(U=\bigcap_{i=1}^n(x-r_{y_i},x+r_{y_i})\), an open neighborhood of \(x\). Each interval \((x-r_{y_i},x+r_{y_i})\) is disjoint from \(V_{y_i}\), since the distance between their centers is \(3r_{y_i}\), while the sum of their radii is \(2r_{y_i}\). If a point of \(U\) belonged to \(K\), it would belong to some \(V_{y_i}\) and also to \((x-r_{y_i},x+r_{y_i})\), which is impossible. Therefore \(U\cap K=\varnothing\). Every point outside \(K\) has an open neighborhood disjoint from \(K\), so \(\mathbb{R}\setminus K\) is open and \(K\) is closed.

For each \(n\in\mathbb{N}\), \(M-1/n\) is not an upper bound for \(K\), because \(M\) is its least upper bound. Thus there is \(k_n\in K\) with \(M-1/n<k_n\le M\). These inequalities imply \(0\le M-k_n<1/n\), so \(k_n\to M\). A closed subset of \(\mathbb{R}\) contains the limit of each convergent sequence of its points: if \(M\notin K\), the open complement would contain an interval around \(M\), contradicting \(k_n\to M\). Hence \(M\in K\), and \(M\) is the maximum of \(K\). Applying the same argument to \(-K=\{-t:t\in K\}\), which is nonempty and compact because \(t\mapsto-t\) is continuous by Theorem 1, shows that \(-K\) has a maximum. Its negative is the minimum of \(K\). \(\square\)

Theorem 3 (Extreme Value Theorem for metric spaces): If \((X,d)\) is a nonempty compact metric space and \(f:X\to\mathbb{R}\) is continuous, then there are \(x_{\min},x_{\max}\in X\) such that \(f(x_{\min})\le f(x)\le f(x_{\max})\) for every \(x\in X\).

Proof. By Theorem 1, \(f(X)\) is compact in \(\mathbb{R}\). It is nonempty because \(X\) is nonempty. Theorem 2 gives a minimum \(m\in f(X)\) and a maximum \(M\in f(X)\). By the definition of image, there are \(x_{\min},x_{\max}\in X\) with \(f(x_{\min})=m\) and \(f(x_{\max})=M\). Since \(m\le t\le M\) for every \(t\in f(X)\), substituting \(t=f(x)\) proves the required inequalities for every \(x\in X\). \(\square\)

Applying the Theorem in Euclidean Sets

Worked Example: A Polynomial on a Closed Interval

Find the maximum and minimum of \(f(x)=x^2-2x\) on \(X=[0,3]\), with the metric inherited from \(\mathbb{R}\).

The interval \([0,3]\) is compact by the Heine–Borel theorem: in Euclidean space, a set is compact if and only if it is closed and bounded. The polynomial \(f\) is continuous, so the Extreme Value Theorem guarantees both extreme values are attained. To find them, complete the square: \(f(x)=(x-1)^2-1\). For \(0\le x\le3\), we have \(0\le(x-1)^2\le4\): the lower bound is attained at \(x=1\), and \(|x-1|\le2\) gives the upper bound. Therefore \(-1\le f(x)\le3\).

At \(x=1\), \(f(1)=1^2-2(1)=1-2=-1\). At \(x=3\), \(f(3)=3^2-2(3)=9-6=3\). Thus the minimum is \(-1\), attained at \(1\), and the maximum is \(3\), attained at \(3\).

Check: substituting the points into the completed-square form gives \(f(1)=(1-1)^2-1=0-1=-1\) and \(f(3)=(3-1)^2-1=4-1=3\), agreeing with the original formula.

Worked Example: A Linear Function on the Unit Circle

Let \(X=S^1=\{(x,y)\in\mathbb{R}^2:x^2+y^2=1\}\), with the Euclidean metric, and let \(f(x,y)=3x+4y\). Find its extreme values.

The circle is closed and bounded in \(\mathbb{R}^2\), hence compact by Heine–Borel. The function \(f\) is continuous, so both extremes are attained. The Cauchy–Schwarz inequality gives \(|3x+4y|\le\sqrt{3^2+4^2}\sqrt{x^2+y^2}=5\cdot1=5\). Thus \(-5\le f(x,y)\le5\) on \(S^1\).

At \((3/5,4/5)\), the circle condition holds because \((3/5)^2+(4/5)^2=9/25+16/25=1\), and \(f(3/5,4/5)=9/5+16/5=25/5=5\). At \((-3/5,-4/5)\), the condition is again \(9/25+16/25=1\), and \(f(-3/5,-4/5)=-9/5-16/5=-25/5=-5\). The maximum is \(5\), and the minimum is \(-5\).

Check: at the first point, the Cauchy–Schwarz bound is attained because \((3/5,4/5)\) is a positive multiple of \((3,4)\); at the second, it is attained with the negative sign. Both points belong to the domain, so neither bound is merely a supremum or infimum.

Worked Example: A Function on a Disconnected Compact Set

Let \(K=[-2,-1]\cup[1,3]\subseteq\mathbb{R}\), with the subspace metric, and define \(g(x)=2x+1\). Find its maximum and minimum.

Each interval is closed and bounded, so their finite union \(K\) is closed and bounded. Heine–Borel makes \(K\) compact, and \(g\) is continuous. On the first interval, if \(-2\le x\le-1\), then \(-3\le2x+1\le-1\). On the second, if \(1\le x\le3\), then \(3\le2x+1\le7\). Combining the two ranges gives \(-3\le g(x)\le7\) for every \(x\in K\).

The value at \(x=-2\) is \(g(-2)=2(-2)+1=-4+1=-3\), and the value at \(x=3\) is \(g(3)=2(3)+1=6+1=7\). Hence the minimum is \(-3\) at \(-2\), and the maximum is \(7\) at \(3\). The set \(K\) is disconnected, but connectedness is not required for the Extreme Value Theorem.

Check: the endpoint values are in the ranges computed on their respective intervals, and both endpoints belong to \(K\); thus both bounds are attained.

Common Pitfall: A Supremum Is Not Always a Maximum

The Extreme Value Theorem guarantees values actually taken by the function. It does not say that every continuous function on every bounded set attains its supremum and infimum. For example, on \(X=(0,1)\), the function \(f(x)=x\) is continuous and bounded, and its supremum is \(1\) and infimum is \(0\). Neither is a maximum or minimum, because \(1\notin X\) and \(0\notin X\).

A mistaken calculation might say, “\(x<1\) for every \(x\in(0,1)\), so the maximum is \(1\).” The inequality proves only that \(1\) is an upper bound, not that \(1\) is a value of \(f\). Indeed, \(f(x)=1\) would require \(x=1\), which is outside the domain. The domain is bounded but not compact: the open sets \(U_n=(1/n,1)\), for \(n\in\mathbb{N}\), cover \((0,1)\), but no finite selection covers it. If \(N\) is the largest selected index, their union is \((1/N,1)\), which misses points of \((0,1)\). Compactness is the hypothesis that rules out this failure.

Check Your Understanding

For each question, distinguish bounds from values actually attained.

  1. Why does continuity imply that \(f(X)\) is compact when \(X\) is compact?
  2. Find the maximum and minimum of \(h(x)=x^2\) on \([-2,1]\), and state where each is attained.
  3. On \(S^1\), find the maximum and minimum of \(p(x,y)=x-y\).
  4. For \(f(x)=1-x\) on \((0,1)\), identify the supremum and infimum and decide whether either is attained.
  5. In the Extreme Value Theorem, where is nonemptiness used?