Problem: Let $(X, d )$ be a a metric space and $A,B$ be two nonempty subsets of $X$. Then the \emph{diameter} of $A$ is defined as
\begin{align*}
\mathrm{diam} (A) = \sup \left\{ d (x,y): x,y \in A \right\}.
\end{align*}
Also, the distance between $A$ and $B$ is defined by
\[
\mathrm{dist} (A, B) = \inf \left\{ d(a,b): a \in A \text{ and } b \in B \right\} .
\]
Show that
\[
\mathrm{diam} (A \cup B) \leq \mathrm{diam} (A) + \mathrm{diam} (B) + \mathrm{dist} (A, B).
\]
Solution: The diameter of the union will be
\[
\mathrm{diam} (A \cup B) = \sup \left\{ d(a,b): a,b \in A \cup B \right\}
\]
Note that for any $a_1, a_2 \in A$ and $b_1, b_2 \in B$, we have
\begin{align*}
d\left( a_1, a_2 \right) & \leq \sup \left\{ d (x,y): x,y \in A \right\} \\
& = \mathrm{diam} (A) \\[1ex]
d\left( b_1, b_2 \right) & \leq \sup \left\{ d (x,y): x,y \in B \right\} \\
& = \mathrm{diam} (B) \\
\end{align*}
Using the above relations, if $a\in A$ and $b\in B$, then for any $a'\in A$ and $b'\in B$,
\begin{align*}
d(a,b) & \leq d(a,a') + d(a', b') + d(b',b) \\
& \leq \mathrm{diam} (A) + d\left( a', b' \right) + \mathrm{diam} (B).
\end{align*}
From above, we can say that
\begin{align*}
& \sup \left\{ d(a,b): a, b \in A \cup B \right\} \leq \mathrm{diam} (A) + d\left( a', b' \right) + \mathrm{diam} (B) \\
\implies & \mathrm{diam} (A \cup B) \leq \mathrm{diam} (A) + d\left( a', b' \right) + \mathrm{diam} (B).
\end{align*}
Thus, $\mathrm{diam} (A \cup B) - \mathrm{diam} (A) - \mathrm{diam}(B) $ is a lower bound of the set $\{ d(a',b'): a'\in A,\ b'\in B\}$. Hence,
\begin{align*}
\mathrm{diam} (A \cup B) - \mathrm{diam} (A) - \mathrm{diam}(B) \leq \inf \left\{ d(a',b'): a'\in A,\ b'\in B \right\}.
\end{align*}
Therefore, we obtain the required relation
\[
\mathrm{diam} (A \cup B) \leq \mathrm{diam} (A) + \mathrm{diam} (B) + \mathrm{dist} (A, B).
\]