Suppose to have a continuous function $f:[a_1,b_1]\to\mathbb{R}$ and let $c_1<a_1$ and $d_1>b_1$. Suppose that you want to extend $f$ to all $\mathbb{R}$ to a new function $g:\mathbb{R}\to\mathbb{R}$ with the following properties:
- $g$ has to be continuous
- $g\equiv f$ on $[a_1,b_1]$
- $g$ is constant $(g\equiv M)$ outside $[c_1,d_1]$
- $g$ is linear on $[c_1,a_1]$ and $[b_1,d_1]$.
This can be easily done by setting: $$ g(x)= \begin{cases} M &\text{ if }x\leq c_1\\ M-\frac{c_1-x}{c_1-a_1} [M-f(a_1)]&\text{ if }c_1\leq x\leq a_1\\ f(x)&\text{ if }a_1\leq x\leq b_1\\ f(b_1)+\frac{x-b_1}{d_1-b_1} [M-f(b_1)]&\text{ if }b_1\leq x\leq d_1\\ M &\text{ if }x\geq d_1.\\ \end{cases} $$ My question is the following. How to generalize this result to a multidimensional setting? Precisely:
Suppose to have a continuous function $f:[a_1,b_1]\times\dots\times[a_n,b_n]\to\mathbb{R}$ and let $c_j<a_j$ and $d_j>b_j$ for every $j\in\{1,\dots,n\}$. Suppose that you want to extend $f$ to all $\mathbb{R}$ to a new function $g:\mathbb{R}^n\to\mathbb{R}$ with the following properties:
- $g$ has to be continuous
- $g\equiv f$ on $[a_1,b_1]\times\dots\times[a_n,b_n]$
- $g$ is constant $(g\equiv M)$ outside $[c_1,d_1]\times\dots\times[c_n,d_n]$
- $g$ is linear in each variable in between the two parallelepipeds.
I need an explicit formula like the one above. I tried an approach "componentwise" but I have problems in proving continuity and with the overlapping zones so generated.
Any hint will be greatly appreciated.