The diameter of a compact set. Let $(X,d)$ be a metric space and define the diameter of a set $A$ as follows: 
$\operatorname{diam}A$ = $\sup\{d(x,y)\mathrel|x,y\in A \}$ if this quantity exists. 
Show that if $A$ is compact, then there are $a_1,a_2 \in A$ such that $\operatorname{diam}A = d(a_1,a_2)$.
 A: I'll write an answer with some blanks for you to fill. Hope that's alright.


*

*$A$ is compact, therefore bounded, so $\operatorname{diam} A$ must exist. (Why can't $d(x, y)$ be arbitrarily large if $A$ is bounded?)

*There is a sequence $x_n \in A$ and a sequence $y_n \in A$ such that $d(x_n, y_n) \to \operatorname{diam} A$. Explanation: If we assume that there are actually $x$ and $y$ with $\operatorname{diam} A = d(x, y)$ then this is obvious - take constant sequences. Otherwise, this follows from the definition of a supremum (fill in the details).

*Since $A$ is compact, $x_n$ has a convergent subsequence. So does $y_n$.
A: Approach №1. Consider continuous function
$$
d: A\times A\to\mathbb{R}: (a_1,a_2)\mapsto d(a_1,a_2)
$$
defined on compact $A\times A$. Recall that each continuous function defined on compact attains its maximum.
Approach №2. Let $D=\mathrm{diam} (A)=\sup\{d(x,y):x,y\in A\}$, then from definition of $\sup$ it follows that there exist a sequence $\{(x_n,y_n):n\in\mathbb{N}\}\subset A\times A$, such that $D=\lim_{n\to\infty}d(x_n,y_n)$. Since $A\times A$ is compact we have convergent subsequence $\{(x_{n_k},y_{n_k}):k\in\mathbb{N}\}$ which converges to some $(a_1,a_2)\in A\times A$. Then we get
$$
\mathrm{diam}(A)=D=\lim\limits_{n\to\infty}d(x_n,y_n)=\lim\limits_{k\to\infty}d(x_{n_k},y_{n_k})=d\left(\lim\limits_{k\to\infty}x_{n_k},\lim\limits_{k\to\infty}y_{n_k}\right)=d(a_1,a_2)
$$
