How can I find the smoothest transition between two straight lines? Let's say I have the function
$$f(x)=\begin{Bmatrix}
x & \textrm{,} & \textrm{if } x\leqslant 1.5\\ 
\frac{x}{3}+1 & \textrm{,} & \textrm{otherwise}
\end{Bmatrix}$$
which has a sharp edge at 1.5, i.e. a discontinuity in the first derivative. I would like to smooth that transition with some other function. In practice I would like to set a window around the sharp edge in which the transition happens:
$$f(x)=\begin{Bmatrix}
x & \textrm{, } & \textrm{if } x\leqslant 1.5-t\\
s(x) & \textrm{, } & \textrm{if } 1.5-t\leqslant x\leqslant 1.5+t\\
\frac{x}{3}+1 & \textrm{, } & \textrm{otherwise}
\end{Bmatrix}$$
with s(x) being my transition function and t being half the window width. I could choose a quadratic but that would create a sharp edge in the first derivative (i.e. a discontinuity in the second derivative). I'd like a function f(x) that ends up with no discontinuities in any of the derivatives and is monotonically nondecreasing.
If anyone can point me in the right direction of what I'm looking for, I'd be thankful.
 A: Take a look at the Wikipedia articles on bump functions and non-analytic smooth functions, in the latter especially the section on smooth transition functions. The function
$$
g(x)=\frac{f(x)}{f(x)+f(1-x)}
$$
with $f(x)=\mathrm e^{-\frac 1x}$ has all derivatives zero at $x=0$ and $x=1$, and $f(0)=0$, $f(1)=1$. Here’s the image from Wikipedia:

And here’s a Wolfram|Alpha plot.
Thus the function
$$
h(x)=g(x)a_2(x)+(1-g(x))a_1(x)
$$
smoothly interpolates between the functions $a_1(x)$ for $x\le0$ and $a_2(x)$ for $x\ge1$. You can obtain your function $s(x)$ by an appropriate rescaling.
A: I see 3 solutions :
1) Convolving the initial function with an adequate bump function (https://en.wikipedia.org/wiki/Bump_function) ; or in general using mollifiers (https://en.wikipedia.org/wiki/Mollifier).
2) Using "clothoids" (aka as "Euler spirals" en.wikipedia.org/wiki/Euler_spiral or Cornu spirals). This kind of curves that have been used for long for the connection of railway straight rails like in your issue.
3) If you are happy with functions that are $C^{n-1}$ but not $C^n$, it suffices to use spline curves of degree $n$. 
For example, here is a 3rd degree spline function connecting the first and the second affine functions in the case $t=0.5$ (your notations) giving  a $C^2$ but not $C^3$ solution. See the following figure :

Fig. 1 : The connecting third degree spline curve $\frak{S}$ (in red) that guarantees a continuous second derivative everywhere, and in particular at the connection points. The little circles represent the control points of curve  $\frak{S}$, i.e., $A(1,1)$, $(4/3,4/3)$, $(5/3,14/9)$, $(2,5/3)$. Please note that the abscissas of $A,B,C,D$ are regularly spaced with $AB$ prolongating the first straight line and $CD$ prolongating the second straight line.
See https://en.wikipedia.org/wiki/Spline_interpolation for an algorithm giving the spline interpolation.
