The maximum of the absolute value of a real-valued function

For a continuous real-valued function $f$ on a compact set $X\neq \emptyset$, we have \begin{equation*} \max_{x\in X}|f(x)| = \max \{\max_{x\in X} f(x), \max_{x\in X} -f(x)\}. \end{equation*}

Could someone please check if the proof is correct? Is there a much shorter proof? (Side note: Someone suggested to prove this statement in the context of another question that I posted here: Maximum value and the absolute value)

Proof: Let $x' \in X$ be such that $\max_{x\in X}|f(x)| = |f(x')|$, i.e. $|f(x')| \geq |f(x)|$ for all $x\in X$. Since for all $x\in X$ we also have $|f(x)| \geq f(x)$ and $|f(x)| \geq -f(x)$, it follows that \begin{equation} |f(x')| \geq f(x) \quad \forall x\in X \quad \text{(1)} \end{equation} and \begin{equation} |f(x')| \geq -f(x) \quad \forall x\in X \quad \text{(2)}. \end{equation} We now consider two cases.

Case 1: $f(x') \geq 0$. Then $|f(x')| = f(x')$, and by equation 1 we get $f(x') \geq f(x)$ for all $x\in X$, i.e. $\max_{x\in X}|f(x)| = \max_{x\in X} f(x)$. We now have to show that we also have $\max_{x\in X} f(x) \geq \max_{x\in X}-f(x)$. Let $x'' \in X$ be such that $\max_{x\in X} -f(x) = -f(x'')$. Since $|f(x)| \geq -f(x)$ for all $x\in X$ and $f(x') \geq |f(x)|$ for all $x\in X$, it follows that $f(x') \geq -f(x'')$, i.e. $\max_{x\in X} f(x) \geq \max_{x\in X}-f(x)$.

Case 2: $f(x') < 0$. Then $|f(x')| = -f(x')$, and by equation 2 we get $-f(x') \geq -f(x)$ for all $x\in X$, i.e. $\max_{x\in X}|f(x)| = \max_{x\in X} -f(x)$. We now have to show that we also have $\max_{x\in X} -f(x) \geq \max_{x\in X} f(x)$. Let $x''' \in X$ be such that $\max_{x\in X} f(x) = f(x''')$. Since $|f(x)| \geq f(x)$ for all $x\in X$ and $-f(x') \geq |f(x)|$ for all $x\in X$, it follows that $-f(x') \geq f(x''')$, i.e. $\max_{x\in X} -f(x) \geq \max_{x\in X} f(x)$.

• You could simply use that $\sup\bigcup_{i\in I}A_i =\sup_{i\in I}sup A_i$ – Hagen von Eitzen Apr 24 '16 at 18:47
• So in this case we'd have $\sup\{A_1 \cup A_2\} = \sup\{\sup A_1, \sup A_2\}$ with $A_1 = \{f(x)\colon x\in X\}$, $A_2 = \{-f(x)\colon x\in X\}$ and $A_1 \cup A_2 = \{|f(x)|\colon x\in X\}$? (The last equation doesn't seem correct, but it would be consistent with the first one, right?) – Georgios Apr 24 '16 at 19:01