How to smooth out 2 corners in a piecewise function? I have been experimenting with this a lot, but it eventually proves itself to be trickier than I expected.
Let \begin{equation} f(z) =
      \begin{cases}
        1, &z<0  \\
        \frac{1}{2} + \frac{1}{10} \sqrt{25-20z + 20 \sin(\pi z)}, &0<z<1  \\
        \frac{1}{2} + \frac{1}{10} \sqrt5, &z>1
      \end{cases}
    \end{equation}
be a piecewise smooth function, smooth everywhere, and differentiable everywhere but $z=0$ and $z=1$.
My idea is to smooth out the "corners" possibly by extracting a small domain around them, and replace this with a function g such that f and g can be glued together into a new function H that is everywhere smooth.
I would extract a small stripe of width $2\delta$, for $\delta$ small enough, left and right of $z=0$, and do the same, left and right of $z=1$. This would result in:
\begin{equation} H(z) =
      \begin{cases}
        1, &z<-\delta  \\
         g_1 (z), &-\delta < z < \delta \\
        \frac{1}{2} + \frac{1}{10} \sqrt{25-20z + 20 \sin(\pi z)}, &\delta<z<1-\delta  \\
        g_2 (z), &1-\delta < z < 1+\delta \\
        \frac{1}{2} + \frac{1}{10} \sqrt5, &z>1+\delta
      \end{cases}
    \end{equation}
so that -finally- $H(z)$ is everywhere smooth. My question is: can someone give me a suitable example for $g_1$ and $g_2$ and preferably explain to me the thinking process?
Thanks in advance!
 A: "Rounding off the corners" of a function $f$ on an interval $[a, b]$ amounts to picking a continuously-differentiable function with specified values and specified derivatives at $a$ and $b$. That is, we want to pick a "rounding" function $r$ on $[a, b]$ so that
\begin{align*}
r(a) &= f(a), & r(b) &= f(b), \\
r'(a) &= f'(a), & r'(b) &= f'(b).
\end{align*}
One flexible scheme is to pick four functions $e_{1}$, $e_{2}$, $e_{3}$, $e_{4}$ satisfying
$$
\begin{array}{@{}c|cccc@{}}
  & e(a) & e'(a) & e(b) & e'(b) \\
  \hline
  e_{1} & 1 & 0 & 0 & 0 \\
  e_{2} & 0 & 1 & 0 & 0 \\
  e_{3} & 0 & 0 & 1 & 0 \\
  e_{4} & 0 & 0 & 0 & 1 \\
\end{array}
$$
The desired rounding function is
$$
r(x) = f(a)e_{1}(x) + f'(a)e_{2}(x) + f(b)e_{3}(x) + f'(b)e_{4}(x).
$$
For example, we can use cubic polynomials (the smallest degree with four degrees of freedom) by modifying Lagrange interpolation polynomials:
\begin{align*}
e_{1}(x) &= \frac{(2x - (3a - b))(x - b)^{2}}{(b - a)^{3}}, &
e_{3}(x) &= e_{1}(a + b - x), \\
e_{2}(x) &= \frac{(x - a)(x - b)^{2}}{(b - a)^{2}}, &
e_{4}(x) &= -e_{2}(a + b - x).
\end{align*}

The diagram below shows the result of interpolating from known heights and slopes at two points $a$ and $b$:

