# a function which is 1. easy to compute and 2. equal to 1 inside a interval, and quickly transitions to zero towards the boundaries

I need a function which has a plot more or less like this: Basically, I need something which "smooths out" the indicator function of an interval, and which transitions to 0 at a calibratable rate.

The bump function times $e$, as it is, doesn't work, because the transition from 1 to 0 at the boundaries is too gradual. EDIT: I found out that changing the numerator of the argument of the exponential, i.e., going from

$$\exp\left(-\frac{1}{0.25-x^2}\right)$$

to

$$\exp\left(-\frac{0.001}{0.25-x^2}\right)$$

works perfectly: so I could as well as close the question now :) However, I'm still curious how this is done usually in (applied?) mathematics. I don't need strictly compact support, i.e., my function needs only to asimptotically vanish, but it doesn't need to be exactly equal to zero anywhere on the real line. Thus the following function works:

$$\frac{1}{(1+\exp(-100(x+0.5))(1+\exp(-100*(x-0.5))}$$

Is it usual to use this kind of function to "smooth out" the indicator function, or is it more common to use the bump function? I seem to remember that during university we were shown a lot of functions with a similar graph, so it must be something quite common, but I can't recall their expressions.

You could do a convolution with a small mean-preserving filter. The convolution of two continous functions can be defined:

$$(f*g)(t) \overset{def}{=} \int_{-\infty}^{\infty}f(\tau)g(t-\tau)d\tau$$

And for discrete functions:

$$(f*g)[n] \overset{def}{=} \sum_{m=-\infty}^{\infty}f[m]g[n-m]$$

A famous and easy to understand category of such filters to convolve with is the family of self-convoluted constants related to splines, pascals triangle, combinatorics, interpolation and many other things. Sometimes the convolution is called a convolution-product. In this sense if we let $o$ denote the exponent in this multiplicative sense we can write $f^{(*o)}(t) = (f\underset{o-1 \text{ times}}{\underbrace{*\cdots*f}})(t)$ $$\text{First few self convoluted mean-preserving filters}\cases{f^{(*1)} (t) = f(t)\\f^{(*2)}(t) = (f*f)(t)\\f^{(*3)}(t) = (f*f*f)(t)\\f^{(*4)}(t)= (f*f*f*f)(t)}$$ Where $f$ is the (blue) function - constant on an interval and 0 everywhere else. These can then be convolved with your big square to produce a "smoothing" effect. In practice you only need to calculate the convolution wherever the smaller filter overlaps two distinct values of the piecewise constant function. Since these are self convoluted by construction and your test function is ac constant, you can actually see the transition right in this image.