# (Computationally) Simple sigmoid

I'm looking for the analytic expression of a computationally cheap sigmoid that passes through the points (0, 1) and (1, 0). Thoughts?

-
Is it okay if it's only defined on the interval $[0,1]$? If you want it to also be defined on all real axis, should it stay $0$ for inputs $x>1$ and $1$ for negative inputs? –  user53153 Feb 6 '13 at 20:05
Ok just for [0, 1]; it really doesn't matter what happens outside that interval. –  Hugo S Ferreira Feb 7 '13 at 17:11

An extremely cheap option is the cubic spline with zero derivatives at both endpoints: $$f(x)=1-3x^2+2x^3.$$

-
Rahul Narain, if I want to have even smoother curve at the endpoints, then I must use a higher order spline (5th, 7th etc), right? Is there another option, where I can have controllable smoothness (via parameter), which doesn't increase computational complexity with the increase of smoothness? (The second answer doesn't work for me, as I must strictly satisfy end point conditions). –  Anton Apr 8 '13 at 4:32
You can try just using $f(x)=\dfrac{g(1-x)}{g(x)+g(1-x)}$ where $g(x)=\exp(-1/x)$, whose derivatives of all orders are zero at the endpoints. –  Rahul Apr 8 '13 at 5:39
Thank you. Seems like I can also use $$g(x) = p^{-1/x}, p \ge 2$$ to control the shape. –  Anton Apr 8 '13 at 8:36
The logistic function is computationally cheap, and with a linear transform it can be adapted to $[0,1]$ interval: $\displaystyle \varsigma (x) = \frac{1}{1+\exp(6\cdot(2x-1))}$ is shown here.
Strictly speaking, the curve misses both target points by $1/(1+e^6)\approx 0.002$. If this is a problem, tweak it: $$\varsigma (x) = \frac{a}{1+\exp(6\cdot(2x-1))}-b \ \text{ where } a= \frac{1+\exp(-6)}{1-\exp(-6)}, \ b = \frac{1}{\exp(6)-1}$$ satisfies $\varsigma(0)=1$ and $\varsigma(1)=0$. Here $a\approx 1.005$ and $b\approx 0.0025$ are computed only once.
Of course, $6$ can be replaced by another number throughout the formulas.