Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I've been playing with what seems to me to be a pretty simple function, constructed as follows:


$f(n+1)=f(n)+\frac{1-f(n)}{2}$ for $n\gt0$

$f(n-1)=\frac{f(n)}{2}$ for $n\lt0$

More generally, $f$ starts midway between two boundaries. With each increment of $x$, starting at zero, the distance to the upper boundary is halved. With each decrement of $x$, starting at zero, the distance to the lower boundary is halved.

Or another way:

$f(x) = 2^{x-1}$ for $x \lt 0$

$f(x) = 1 - 2^{-x-1}$ for $x \ge 0$

This draws a nice S-shaped curve between $0$ (at $x=-\infty$) and 1 (at $x=\infty)$. I'm looking for a single unified way of expressing this function, preferably one that intuitively follows from the construction of the function.

I'm searching for a process more than an answer. It's unclear to me how to jump from the definitions above to a unified definition of $f(x)$ -- I'm not looking for answers in the class of "Oh well this is just a sigmoid function with the following parameters...", I'm looking for a way to jump from the intuitive definition to a formula.

In other words, how do I translate "$f(x)$ starts in the middle and each step forward/backward halves the distance to the upper/lower boundary" into a mathematical formula?

share|cite|improve this question

$$f(x)=\begin{cases}2^{x-1}&\text{if }x\lt 0,\\1-2^{-x-1}&\text{if }x\ge0\end{cases}$$ is just fine as a function definition.

share|cite|improve this answer
Sure -- but is their a unified equation for the function? It feels like there should be. – Nate Jun 12 '13 at 6:54
@Nate: Is there a unified equation for $f(x)=|x|$? Do think expressions such as $f(a,b)=\frac{a+b+|a-b|}{2}$ are somehow more useful than $f(a,b)=\max\{a,b\}$? Or is $f(x)=\lim_{n\to \infty}\lim_{m\to\infty}\cos^{2m}(n\pi x)$ somehow more comprehensible that $f(x)=\begin{cases} 1&\text{if }x\in\mathbb Q\\0&\text{otherwise}\end{cases}$? – Hagen von Eitzen Jun 15 '13 at 21:24
My confusion was rooted in the fact that the function is not continuously differentiable. Now I feel silly. – Nate Jun 17 '13 at 20:41
up vote 1 down vote accepted

You can't do what you that, silly. The function described above is continuous and once-differentiable, but it's not twice-differentiable. It is S-shaped, but it's not a sigmoid function. You can't cleanly generate that function in one sweep.

For context: I had stumbled onto the function, quickly verified that it was continuous and differentiable, thought that I had found an interesting derivation of sigmoid functions. However, I couldn't get from my simple bipartite formulae to a function of the form $\frac{1}{1+e^{\phi x}}$. I thought this was due to my own inability to manipulate the formulas. It took me an embarrassingly long time to realize that the described function isn't continuously differentiable.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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