# How do you combine the bipartite function $y=2^{x-1}$ for $x\lt0$ & $y=1-2^{-x-1}$ for $x\ge0$?

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

$f(0)=\frac{1}{2}$

$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?

$$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.
• @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
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.