Problem about the construction of a smooth function

120 Views Asked by At

I need to construct a function $f\in C^\infty(\mathbb{R})$, such that $$f(x)=\left\{\begin{aligned} &0,\quad x\leqslant 0,\\ &x,\quad x\geqslant 1. \end{aligned}\right.$$ I already know that we can construct some smooth functions using something like $e^{-\frac{1}{x}}$, but I don't know how to do this one, can anyone give me some help?

2

There are 2 best solutions below

0
On

I don't fully got your question, but I believe you are looking something like this function: $$h(x)=\begin{cases} 0,\quad x\leq -\frac18 \\ x,\quad x\geq \frac18\\ \int\limits_{-\frac18}^x \frac{1}{1+\exp\left(\frac{32u}{64u^2-1}\right)}\ du,\ \text{otherwise} \end{cases}$$

which makes a smooth transition from $f(x)=0$ into $f(x)=x$.

I built it following the method shown in Wikipedia for smooth Bump functions.

You could see the function on Desmos: Desmos example


Added later

In this answer it is found a series expansion for a similar function.

1
On

Asking a different question I found that there is a simple smooth version of the ramp function named in Wikipedia as Softplus function:

$$f(x) = \ln(1+e^x)$$

Achieves what you are aiming to do (you just need to displace and scale it - as example $f(8x-4)$), and it is smooth since its derivative is the Logistic function.

plot

Also, this function could be approximated by: $$\ln(1+e^x) \approx \begin{cases} \frac{x}{1-e^{-\frac{x}{\ln(2)}}},\quad x\neq 0\\ \ln(2),\quad x=0\end{cases}$$

as could be seen in their plot:

comparison of the plots

You could find other approximations in this Wikipedia page: Rectifier functions.