Proving Lipschitz continuity of a piecewise function Define a locally lipschitz and nonnegative function $f\colon\mathbb{R}^n\to\mathbb{R}$. Let $M\in\mathbb{R}^{n\times n}$ and $\eta>0\in\mathbb{R}$. Consider the function $h\colon\mathbb{R}^n\to\mathbb{R}^n$ defined as 
$$h(\mathbf{x})=
\begin{cases}
\frac{1}{\Vert M\mathbf{x}\Vert}M\mathbf{x}, &\text{if }f(\mathbf{x})\Vert M\mathbf{x}\Vert\ge\eta,\\
\frac{f(\mathbf{x})}{\eta}M\mathbf{x}, &\text{if }f(\mathbf{x})\Vert M\mathbf{x}\Vert<\eta.
\end{cases}$$
Show $h$ is lipschitz on any compact subset $\mathcal{D}\subseteq\mathbb{R}^n$.

Let $\mathbf{x},\mathbf{y}\in\mathcal{D}$, then $h$ is Lipschitz on $\mathcal{D}\subseteq\mathbb{R}^n$ if 
$$\Vert h(\mathbf{x})-h(\mathbf{y})\Vert\le L\Vert \mathbf{x}-\mathbf{y}\Vert$$
for some Lipschitz constant $L>0\in\mathbb{R}$.

What is the best plan of attack for this? I initially split this into two cases when $f(\mathbf{x})\Vert M\mathbf{x}\Vert\ge\eta$ and when $f(\mathbf{x})\Vert M\mathbf{x}\Vert<\eta$. I then tried to write $\Vert h(\mathbf{x})-h(\mathbf{y})\Vert$ in terms of a const. multiplied by $\Vert\mathbf{x}-\mathbf{y}\Vert$ then we can take $L=$ const. but I come to difficulties since $f$ is only locally lipschitz.
 A: Define the two sets 
$$A:=\{x\in \mathbb{R}^n: f(x)\|Mx\|\geq \eta\}$$
$$B:=\{x\in \mathbb{R}^n: f(x)\|Mx\| < \eta\}$$
For simplicity, is assume that the provided matrixnorm satisfies
$$\|Mx-My\| \leq \|M\|\|x-y\|$$
Since we want to show that $h$ is locally lipschitz, we will only regard a compact subsert $\mathcal{D}\subseteq \mathbb{R}^n$ and denote
$$\bar{f} := \max_{x\in\mathcal{D}}\|f(x)\|,\ L_f := \max_{x\neq y\in \mathcal{D}} \frac{\|f(y)-f(x)\|}{\|y-x\|},\ \|\mathcal{D}\|:= \max_{y\in \mathcal{D}}\|y\|$$

Step 1: Show that $h$ is locally lipschitz on $A$
$$\|h(x)-h(y)\| = \left\|M\left(\frac{x}{\|Mx\|}-\frac{y}{\|My\|}\right)\right\|\leq \|M\| \left\|\frac{x}{\|Mx\|}-\frac{y}{\|My\|}\right\|$$
$$\leq \|M\| \frac{\|M\|\|\mathcal{D}\|+\|M\|\|\mathcal{D}\|}{\eta^2 (\bar{f})^{-2}}\|x-y\|$$

Step 2: Show that $h$ is locally lipschitz on $B$
$$\|h(x)-h(y)\| \leq \frac{1}{\eta}(\|f(x)-f(y)\| \|M\|\|x\|+\bar{f}\|M\|(x-y)$$
$$\leq \frac{1}{\eta}(L_f\|M\|\|\mathcal{D}\|+\bar{f}\|M\|)\|x-y\|$$

Step 3: Show that $h$ is continuous on $\partial A$
Let $x^*\in\partial A$ be arbitrary. Let $(x_n)_{n\in\mathbb{N}}$ be a converging sequence in $A$ satisfying $x^*=\lim_{n\in\mathbb{N}}x_n$, we get
$$h_1 := \lim_{n\in\mathbb{N}} h(x_n) =  \frac{1}{\|Mx^*\|}Mx^*$$
If the sequence is in $B$ i.e. $x_n\in B,\ n\in\mathbb{N}$, we have
$$h_2 := \lim_{n\in\mathbb{N}} h(x_n) =  \frac{f(x^*)}{\eta}Mx^*$$
since $x^*\in \partial A$ we have $f(x)\|Mx\|=\eta$ and therefore $h_1=h_2$
A: Note that if $x$ is such that $f(x)=0$ or $Mx=0$ then there is a neighbourhood $U$ of $x$ such that $f(y) \|My\| < \eta$ for $y \in U$. Hence $h$ is locally Lipschitz in a neighbourhood of any point such that $f(x)=0$ or $Mx=0$.
Suppose $x$ is such that $f(x) \neq 0$ and $Mx \neq 0$.
Let $\phi(y) = \min({1 \over \|My\|}, {f(y) \over \eta})$, this is well defined
in a neighbourhood of $x$ and furthermore it is locally Lipschitz in this
neighbourhood (since $f$ is locally Lipschitz and the function $t \mapsto {1 \over t}$ is locally Lipschitz and compositions of locally Lipschitz functions is again locally Lipschitz). Since $h = f \cdot \phi$ it follows
that $h$ is locally Lipschitz (since products of locally Lipschitz functions
are locally Lipschitz).
A slightly more involved approach would be to use the Rademacher theorem.
