Is this function Lipschitz? Let $f:X \rightarrow \mathbb R$ be a Lipschitz function  on a metric space $X$ and $K<M$ be some constants.
Is it such a function $g:X\rightarrow \mathbb R$ Lipschitz: 
$$
g(x)=f(x) \textrm{ if } \ K \leq f(x) \leq M,
$$
$$
g(x)=K \textrm { if } \ f(x)<K,
$$
$$
g(x)=M \textrm{ if } \  f(x)>M.
$$
Thanks
 A: Suppose $f_\alpha$ are Lipschitz with rank $L$. Let $\psi(x) = \sup_\alpha f_\alpha(x)$, and suppose that $\psi(x)$ is finite for all $x$. Then  $\psi$ is also Lipschitz. To see this, note that $f_\alpha(x) \leq f_\alpha(y) + L \|x-y\|$ for all $\alpha$. This gives $\psi(x) = \sup_\alpha f_\alpha(x) \leq \sup_\alpha (f_\alpha(y) + L \|x-y\|) = \sup_\alpha f_\alpha(y) + L \|x-y\| = \psi(y)+ L \|x-y\|$. Thus $\psi(x)-\psi(y) \leq L \|x-y\|$. Swapping the roles of $x,y$ gives $|\psi(x)-\psi(y)| \leq L \|x-y\|$.
A similar argument shows that $\eta(x) = \inf_\alpha f_\alpha(x)$ is Lipschitz (assuming finiteness, as before).
It follows that the function $x \mapsto \max (f(x), K)$ is Lipschitz (since a constant is Lipschitz), and hence it follows that the function $x \mapsto \min(\max (f(x), K), M)$ is Lipschitz. Since $g(x) = \min(\max (f(x), K), M)$, we have the desired result.
A: You can write your function as $\min(\max(f(x), K), M)$. Note that the composition of Lipschitz functions is Lipschitz. So you just have to show that the functions $\min(x,K)$ and $\max(x,M)$ are Lipschitz on ${\mathbb R}$, which is not hard.
A: We have $g(x)=\min\{\max\{f(x),K\},M\}$. Now, we just have to show that if $|f(x)-f(y)|\leq C|x-y|$, $|\max\{f(x),K\}-\max\{f(y),K\}|\leq C|x-y|$, which can be shown using the formula $2\max\{a,b\}=a+b+|a-b|$ and triangular inequality. 
By the way, the Lipschitz constant is the same.
