# Is there a simpler function with this shape?

I need a function that has the shape shown below. I don't care what the function does for $x < 0$ or $x > 1$.

I've experimented with a lot of different functions, configured first and second derivatives, and came up with this little monster. But I suspect there's something simpler.

$$\frac{1 + \sin \left[\frac{\pi}{2}(544x + 81)^{1/4}\right]}{2}$$

The origin of this problem is that I'm trying to turn a difference metric between a pattern and a model into a sort of "probability" that the model and the pattern are a bad match. So it should be zero for the model that best matches the pattern, and low for very similar patterns, but rising quickly for patterns that are less similar.

But as I look at it, it reminds me of a gravity well.

• Simple in what sense? Fast to calculate with computers? Short expression to write with symbols? Apr 29, 2016 at 11:25
• Does en.wikipedia.org/wiki/Smoothstep qualify?
– lhf
Apr 29, 2016 at 11:26
• Simpler in the sense that it's a short expression to write with symbols. Apr 29, 2016 at 11:33
• Any more information do you have? Apr 29, 2016 at 11:35
• I tried smoothstep, both third and 5th order, but I couldn't get it to rise quickly near the origin. Apr 29, 2016 at 11:36

If you need it to be smooth to a silly extent you can use the integral (or some approximation) of a bump function:

$$f(x) = \cases{\exp\left[-\frac{1}{1-x^2}\right] \hspace{1cm} x \in [-1,1]\\0 \hspace{3.cm} |x|>1}$$

This function is differentiable infinitely many times, and of course so will also it's integral be. But we will of course need to rescale it to fit the range for $x$: $[-1,1] \to [0,1]$ of course.

EDIT To answer to Bernards comment we may also need to renormalize it which we can do by dividing with $\int_{-\infty}^{\infty} f(x)dx$, that will ensure we get maximum of 1 (at $x=1$). Dividing by a constant won't change any of the other properties.

• But it won't be equal to $1$ at $x=1$! Apr 29, 2016 at 12:21
• @Bernard: you may rewrite it as $\;\displaystyle\exp\left[1-\frac 1{1-(1-x)^2}\right]\;$ and change the power of $(1-x)$ if you want. Another simple solution is $\;\displaystyle\int x(1-x)^3 dx$. Apr 29, 2016 at 12:31

I suggest the following family of functions: $$f_a(x)=1-\sin\left(\frac{\pi}{2}(1-x)^2e^{-ax^2}\right).$$ Where you can choose $a$ as you like to satisfy your requirement. In the next image you see the cases $a=1,10$.

• That's definitely an improvement over what I had, because the $a$ parameter can control the steepness of the curve. Apr 29, 2016 at 16:50

Since you mentioned 'probability' have you considered a Weibull CDF?

$$y = 1 - {e^{-(x/0.4)}}^{2.5}$$

Depending on your definition of "simple", you might want to consider a polynomial over a polynomial. These can be set up so that the difference in growth of the polynomial effectively "cancel" other terms, allowing you to set up regions in the curve of differing behavior.

Such equations are highly flexible and usually not too difficult to deal with, especially for further mathematical manipulation. They can also be fit to data fairly easily.

Here is an example I randomly came up with:

$$\frac{x+50x^{2.5}}{1+50x^{2.5}}$$

The function $f(x)=x^{1/x}$ could be used for your purposes, although as you pointed out, it isn't asymptotic at $y=1$. I haven't really worked out any variations of this function that could better suit your needs, but you claim that this would work too. If I do find a better variation, I shall edit this answer. Here is a graph of the function for reference.
EDIT: I forgot to mention, as pointed out by OP, that one could change the function to $f(x)=x^{1/x^b}$ where $b$ is a parameter that controls steepness.
The reciprocals "integer roots" are very simple and achieve at least a bit of the same look although extremely quick raise at close to 0 $$r_n(x) = x^{1/n}$$
$$L_{n+1}(x) = \cases{\log\left[1+(e-1)x\right] \hspace{2cm} n = 0\\\\\log\left[1+(e-1)L_{n}(x)\right]\hspace{1.24cm}n>0}$$
We plot side by side for a few $n$ in these families, left: reciprocals, right logtowers: