Find derivable function with given shape?

86 Views Asked by At

I am trying to model a phenomenon where the output depends linearly on a variable $x$, except when $x$ becomes large where its contribution is less important.

I would like to use a function looking like:

  • $f(x) \sim x$ for $x < x_0$
  • $f(x) \sim \alpha x $ for $x_0 < x < x_{max}$ ($ 0 < \alpha < 1$)
  • Ideally, $f(x) = $ constant for $x > x_{max}$

with three parameters ($x_0$, $\alpha$ and $x_{max}$).

But I would like the function to be derivable everywhere except maybe on 0 (minimization) and slope changes to be smoother (ok this last criteria is just because it is nicer :) ).

I have investigated

  • $argsh$ but I have no freedom on the second slope (aka $\alpha$)
  • generalized logistic functions but couldn't find a parametrisation that make it close to identity for small $x$.

If someone do have an idea about a function looking like this, it would be much appreciated!

Thanks.

2

There are 2 best solutions below

1
On BEST ANSWER

Piecewise linear functions can be approximated using for example $\theta_n(x) = \frac1n \ln(1+e^{nx}),$ which are good approximations of $$\theta(x) := \begin{cases}0 & \text{if $x<0$} \\ x & \text{if $x>0$} \end{cases}$$

Your function can be written exactly as $$f(x) = x - (1-\alpha)\theta(x-x_0) - \alpha\theta(x-x_{\text{max}})$$ and therefore approximated as $$f(x) \approx x - (1-\alpha)\theta_n(x-x_0) - \alpha\theta_n(x-x_{\text{max}})$$

Test different values of $n$ to see what is good enough for you.

1
On

There is a general way of approximating a function with a smooth function using a smoothing kernel. For $\epsilon > 0$ let

$$g_\epsilon(x) = \begin{cases}&C_\epsilon \exp({-\frac{1}{1-(x / \epsilon)^2}}), \space x\in(-\epsilon, \epsilon)\\ &0, \text{ otherwise} \end{cases}$$

and choose the constant $C_\epsilon = (\epsilon \int_{-\epsilon}^{\epsilon} \exp({-\frac{1}{1-(x / \epsilon)^2}}) dx)^{-1} $ to make $g_\epsilon$ have integral $1$. This function is smooth everywhere. Now define the smooth approximation to a function $f$ by

$$f_{\epsilon}(x) = \int_{-\infty}^\infty f(y)g_\epsilon (x-y) dy.$$

This approximation will converge to your function as $\epsilon \to 0$.

This maybe is too theoretical for your purposes and a better approximating function found by other means, but this is a general method.