2
$\begingroup$

Ideally, the function f(x) would tend toward zero as x tends towards negative infinity, and f(x) would tend towards 1 as x tends towards infinity, all the while being monotonically increasing.

for example, I know that I could modify the inverse tangent function to achieve this, by doing something like:

f(x) = (InverseTan(x) + pi/2) / pi

I'm looking for other functions which satisfy the same criteria but are computationally cheap to calculate on a computer. It's been a decade since my last math course and I can't seem to recall any other functions that would do the trick.

$\endgroup$
5
  • $\begingroup$ try math.stackexchange $\endgroup$
    – Will Jagy
    Jul 7, 2011 at 4:04
  • $\begingroup$ The "computationally cheap" part makes this an interesting question, although it might depend on your computer and how accurately you need to evaluate it. $\endgroup$ Jul 7, 2011 at 4:55
  • 3
    $\begingroup$ $ (1/2) + (1/2) x / (1 + |x| ) $ $\endgroup$
    – Will Jagy
    Jul 7, 2011 at 4:59
  • $\begingroup$ Use the quadratic formula to invert $y = x/(1-x^2)$. $\endgroup$ Jul 7, 2011 at 18:32
  • $\begingroup$ This is actually a common question. See sigmoid functions. en.wikipedia.org/wiki/Sigmoid_function $\endgroup$ Jul 11, 2011 at 6:37

1 Answer 1

0
$\begingroup$

You could, for example, take the function $f(x) = \dfrac{1-e^{-x}}{2}$ for $x\ge 0$ and $f(x) = \dfrac{e^{x}}{2}$ otherwise.

Any other base for the exponent would work as well; 2 might be useful for computational purposes, depending on how exactly you're computing the function. Are there any other criteria you want your function to satisfy? If it doesn't need to be continuous, you could take some sort of modified step function, with value $\frac{1}{2}$ at 0, adding $\dfrac{1}{4^n}$ at each positive integer, subtracting $\dfrac{1}{4^{-n}}$ at each negative integer. You could also average that function out with a linear approximation at each point between integers, if it needs to be continuous. (In short, there are any number of things you can do; one nice way to approach the problem might be to narrow down exactly what you want, draw the simplest function you can that satisfies those criteria, and then find a function that looks like it.)

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.