How to construct a non-piecewise differentiable S curve with constant quick turning flat tails and a linear slope? I need to find an example of a non-piecewise differentiable $f:\mathbb{R}\to\mathbb{R}$ such that
$$
\begin{cases}
     f(x)=C_1 &\text{ for } x<X_1,\\
     C_1 < f(x) < C_2 &\text{ for } X_1 < x < X_2,\\
     f(x)=C_2 &\text{ for } X_2<x.
\end{cases}
$$
For example, $\log(1+e^{Ax})$ is sort meets some characteristics in that 


*

*quickly flat lines around 0 for large A

*has a linear slope for 0 < x < Xc


But it 


*

*does not flatline for Xc < x

*I can't seem to control the slope of the linear section


So am looking for something different
Is there some other differentiable function that exhibits the above behavior?
 A: How about:
$$f(x)= \begin{cases}
C_1 & \text{if } x \le x_1 \\
\\
\dfrac{C_1-C_2}{2}\cos\left(\dfrac{\pi}{x_2-x_1}(x-x_1) \right) + \dfrac{C_1+C_2}{2}  & \text{if } x_1 < x < x_2 \\
\\
C_2 & \text{if } x \ge x_2 \\
\end{cases}$$
A: The following is a standard example in this regard: The function
$$\psi(t):=\cases{e^{-1/(1-t^2)}\quad&$(|t|<1)$\cr 0&$(|t|\geq1)$\cr}\ .$$
is defined piecewise, but is $C^\infty$ on all of ${\mathbb R}$. It  has a bump over the interval $[-1,1]$. Put $\int_{-\infty}^\infty \psi(x)\ dx=:C$. Then the antiderivative
$$\Psi(x):={1\over C}\int_{-\infty}^x \psi(t)\ dt $$
is $C^\infty$,  is $\equiv0$ for $x\leq-1$, and is  $\equiv1$ for $x\geq1$. Now adjust $\Psi$ to your data.
You cannot have a "single analytic expression" that does the desired job, because an analytic function that is constant on some interval has to be constant throughout.
A: After a bit of trying to mix various segments I came up with the following for my problem
f(x) = (1/(1+e^(100*(x-1))))(1/(1+e^(-100(x+1))))x-(1/(1+e^(100(x+1))))+(1/(1+e^(-100*(x-1))))
Which atleast seems to be in the right direction to meet all the requirements


*

*Has a slope between -1 to +1.

*Flatens quickly > 1 and < 1. How quickly can be controlled by changing the constant 100 

*is continuous and not pieceswise

*is differentiable


I still haven't generalized it yet, but the general idea is to build it out of 3 segments


*

*(1/(1+e^(100*(x-1))))(1/(1+e^(-100(x+1)))) multiplied by a slope and X for the sloping part

*bottom flatline -(1/(1+e^(100*(x+1))))

*top flat line (1/(1+e^(-100*(x-1))))

