Is it true that $\max\limits_D |f(x)|=\max\limits\{|\max\limits_D f(x)|, |\min\limits_D f(x)|\}$? I came across an equality, which states that 

If $D\subset\mathbb{R}^n, n\geq 2$ is compact, for each $ f\in C(D)$, we have the following equality
  $$\max\limits_D |f(x)|=\max\limits\{|\max\limits_D f(x)|, |\min\limits_D f(x)|\}.$$

Actually I can not judge if it is right. Can anyone tell me if it is right, and if so, how to prove it?
Thanks a lot.
 A: It is correct. Proving it is straight forward enough, so I'll just give you a hint. $|f(x)|=f(x)$, provided that $f(x)\geq 0$. And, $|f(x)|=-f(x)$ otherwise. Now, what happens if the RHS is not equal to the first possibility? What happens if it's not equal to the 2nd possibility? Look at if the max and mins are +ve or -ve. ect, do case work on this. You'll get it. 
A: I assume that you are assuming that $\max$ and $\min$ exists or that you are assuming that $f(x)$ is continuous which in-turn guarantees that $\max$ and $\min$ exists, since $D$ is compact.
First note that if we have $a \leq y \leq b$, then $\vert y \vert \leq \max\{\vert a \vert, \vert b \vert\}$, where $a,b,y \in \mathbb{R}$. Hence, $$\min_D f(x) \leq f(x) \leq \max_D f(x) \implies \vert f(x) \vert \leq \max\{\vert \max_D f(x) \vert, \vert \min_D f(x) \vert\}, \, \forall x$$
Hence, we have that $$\max_D \vert f(x) \vert \leq \max\{\vert \max_D f(x) \vert, \vert \min_D f(x) \vert\}$$
Now we need to prove the inequality the other way around. Note that we have $$\vert f(x) \vert \leq \max_D \vert f(x) \vert$$ This implies $$-\max_D \vert f(x) \vert \leq f(x) \leq \max_D\vert f(x) \vert$$
This implies
$$-\max_D \vert f(x) \vert \leq \max_D f(x) \leq \max_D\vert f(x) \vert$$
$$-\max_D \vert f(x) \vert \leq \min_D f(x) \leq \max_D\vert f(x) \vert$$
Hence, we have that $$\vert \max_D f(x) \rvert \leq \max_D\vert f(x) \vert$$ $$\vert \min_D f(x) \rvert \leq \max_D\vert f(x) \vert$$
The above two can be put together as $$\max \{\vert \max_D f(x) \rvert, \vert \min_D f(x) \rvert \} \leq \max_D\vert f(x) \vert$$
Hence, we can now conclude that $$\max \{\vert \max_D f(x) \rvert, \vert \min_D f(x) \rvert \} = \max_D\vert f(x) \vert$$
A: Since $f$ is continuous on a compact set $D$, the minimum and maximum of $f(x)$ over $D$ exist. Suppose that the minimum is $a$ and the maximum is $b$.
There are two cases, depending on the relative size  of $|a|$ and $|b|$. 
Case 1: $|a| \le |b|$. Then $\max |f(x)|=|b|$. (Actually, the absolute value sign around $b$ is unnecessary, since if $|a|\le |b|$ then $b$ must be $\ge 0$.) 
But $|\max f(x)|=|b|$ and $|\min f(x)|=|a|$,  so $\max\{|\max f(x)|, |\min f(x)|\}=|b|$.
Case 2: $|a| \gt |b|$. This can only happen if $a$ is negative.  Then $\max|f(x)|=|a|$. But $|\max f(x)|=|b|$ and $|\min f(x)|=|a|$,  so $\max\{|\max f(x)|, |\min f(x)|\}=|a|$.
