# Twice Differentiable Threshold Function

Does there exist any known twice differentiable function that can approximate a threshold as $f(x)= 0$ for $x\leq a$ and $f(x) = L$ for $x\geq a+\epsilon$ and $f(x)$ can take value between these two for $a\in (a,a+\epsilon)$, where $\epsilon$ is a small constant?

## 1 Answer

By scaling we may assume $a = 0$ and $\epsilon = 1$. One idea is to fit a polynomial: $$f(x) = \begin{cases} 0& x \le 0\\ p(x)& 0 < x < 1\\ 1& x \ge 1,\end{cases}$$ where $p(x)$ is a polynomial satisfying certain conditions on its value and first two derivatives at $0$ and $1$. It can be done with a degree 5 polynomial: $p(x) = x^3(6x^2 - 15x + 10)$.

Another way to do it: Suppose you have a $C^k$ function $h$ on $\mathbb{R}$, satisfying $h(t) = 0$ for $t \le 0$ and $h(t) > 0$ for $t > 0$. Then $$f(x) = \frac{h(x)}{h(x) + h(1-x)}$$ is also $C^k$, and has the required values. For this problem we could use $$h(t) = \begin{cases} 0 & t \le 0,\\ t^3 & t > 0. \end{cases}$$ Here's a way to do it that in fact gives a $C^\infty$ function: Define $$h(t) = \begin{cases} 0 & t \le 0,\\ e^{-1/t} & t > 0. \end{cases}$$ Then $h$ is $C^\infty$ everywhere (you should verify this).