Smoothest Function for Generating a Vector from 0 to 1

124 Views Asked by At

I am working on a problem where I need to create a vector $ \mathbf{V} $ of dimension $ n + 1 $ such that $ \mathbf{V}[0] = 0 $ and $ \mathbf{V}[n] = 1 $. The vector should grow smoothly from $0$ to $1$. My idea is to find the "smoothest" function $ f(x) $ that grows from 0 to 1 over the interval $ [0, 1] $, and then sample this function $ n $ times to populate the vector.

  1. What are some mathematical criteria for a function to be considered "smooth" in this context?

  2. What functions $ f(x) $ satisfy these criteria and grow from 0 to 1 over the interval $ [0, 1] $?

3

There are 3 best solutions below

0
On

The function has to be continuous, differentiable and monotonic on the interval [0,1]. The "smoothest" function I could think of is a logistic function in the form $f(x) = \frac{1}{1 + e^{-kx}}$

1
On

I don't fully understood your question, but maybe a smooth transition function could do what are you aimming to achieve, like: $$f(x)=\begin{cases} 0,\qquad x\leq 0\\ 1,\qquad x\geq 1\\ \dfrac{1}{1+\exp\left(\frac{2x-1}{x^2-x}\right)},\ 0<x<1 \end{cases}$$

Check it in Desmos

5
On

Without knowing the reason you want this function, one can not present a precise answer. There is a smooth activation function often used when we want to analyze a mechanical structure under a harmonic load. We use this smooth activation to slowly excite the structure, in order to have a better numerical behavior when integrating the response over time.

It is defined to have the following properties:


$$f(0) = 0$$

$$f'(0) = 0 \;\;\;\text{($f$ is smooth at 0)}$$

$$f''(0) = 0 \;\;\;\text{($f'$ is smooth at 0)}$$

$$f(1) = 1$$

$$f'(1) = 0 \;\;\;\text{($f$ is smooth at 1)}$$

$$f''(1) = 0 \;\;\;\text{($f'$ is smooth at 1)}$$


This information can be used to uniquely define a degree-$5$ polynomial:

$$f(t) = c_0 + c_1\,t + c_2\,t^2 + c_3\,t^3 + c_4\,t^4 + c_5\,t^5$$

$$f(0) = 0 \Rightarrow \boxed{c_0 = 0}$$

$$f'(0) = 0 \Rightarrow \boxed{c_1 = 0}$$

$$f''(0) = 0 \Rightarrow \boxed{c_2 = 0}$$

$$f(1) = c_3 + c_4 + c_5 = 1$$

$$f'(1) = 3\,c_3 + 4\,c_4 + 5\,c_5 = 0$$

$$f''(1) = 6\,c_3 + 12\,c_4 + 20\,c_5 = 0$$

Solving the system for $c_3$, $c_4$ and $c_5$, we get:

$$\boxed{c_3 = 10}$$

$$\boxed{c_4 = -15}$$

$$\boxed{c_5 = 6}$$


Therefore, the activation function is given by:

$$\boxed{f(t) = \left\{\begin{array}{cc} 0 & ,\;\;\text{if}\;\;t < 0\hspace{1.3em}\\ t^3\,[6\,t^2 - 15\,t + 10] & ,\;\;\text{if} \;\;t\in[0,1]\\ 1 & ,\;\;\text{if}\;\;t > 1\hspace{1.3em} \end{array}\right.}$$


Here you can see the plot for the function and its derivatives.