Smooth approximation of three-phased linear models I am looking for a smooth (continuous differentiable) approximation of the following two three-phased functions with breakpoints at $B_1$ and $B_2$:$$
y_1(x, B_1, B_2, a, b) = \begin{cases}
a; & x < B_1\\
a + b(x - B_1); & B_1 \leqslant x \leqslant B_2\\
a + b(B_2 - B_1); & x > B_2
\end{cases},
$$

and$$
y_2(x, B_1, B_2, a, b_1, b_2, b_3) = \begin{cases}
a + b_1(x - B_1); & x < B_1\\
a + b_2(x - B_1); & B_1 \leqslant x \leqslant B_2\\
a + b_2(B_2 - B_1) + b3(x - B_2); & x > B_2
\end{cases}.
$$

The derivative equals $b$ or $b2$ at $\dfrac{1}{2}(B_1+B_2)$ for functions $y_1$ and $y_2$, and equals $b1$ at $x\ll B_1$ and $b3$ at $x\gg B_2$ for function $y_2$.
I would like one additional parameter $s$ that would describe how closely the smooth function would approximate the piecewise linear versions. The function should extrapolate more or less linearly on both sides.
Any thoughts about what could be good functions for this?
I want the functions to be smooth and continuously differentiable as that would help me to fit these parameters as I could then provide the analytical first-order derivative.

Ha with the help of my brother found the answer myself in the end.
If we define 
\begin{align*}
f(x, b, s) &= \frac{1}{2}\sqrt{\smash[b]{b(4s+bx^2)}}\\
&\mathrel{\phantom{=}}{}
\end{align*}
then my piecewise linear function $y_1(x, a, b, B1, B2, s)$ can be approximated as
\begin{align*}
y_1(x, a,b,B1,B2,s) &= a + f(x-B1,b,s)-f(x-B2,b,s)
\end{align*}
if the intercept is $a$ and slope of the middle part $b$.
Likewise, my piecewise linear function $y_2(x, a, b1, b2, b3, B1, B2, s)$ with slopes $b1$, $b2$ and $b3$ in the 3 linear parts can be approximated as
\begin{align*}
y_2(x, a,b1,b2,b3,B1,B2,s) &= a + b1.x + f(x-B1,b2-b1,s)-f(x-B2,b2-b3,s)
\end{align*} 
These will approach the original piecewise model more as $s\to0$.
The same system can be used for functions with any number of breakpoints.
They are much easier to fit than the original piecewise model though, due to them being continuously differentiable.
