Construct a function to "increment" a value while asymptotically approaching a limit Suppose I have a value $a_1$ such that $-L < a_1 < L$. I need to compute $a_2$ from $a_1$ and $b$, while satisfying the following requirements:


*

*$-L < a_2 < L$

*if $b = 0$ then $a_2 = a_1$

*if $b < 0$ then $a_2 < a_1$

*if $b > 0$ then $a_2 > a_1$

*a chaining requirement, explained below.


The operation can be written as $a_2 = f(a_1, b)$ (with an implicit $L$ argument which I'll leave out for clarity). In this notation, the chaining requirement can be expressed as: $f(a, b+c) = f(f(a, b), c)$. In intuitive terms, adjusting $a$ by $b$ and then by $c$ produces the same result as adjusting $a$ by $b + c$.
Can you recommend a function $f$ that satisfies these requirements? If you constructed the function rather than just happened to know one that fits these, could you outline the steps?
(edited to fix the impossible $-L \le a \le $L requirement)
 A: This would be easy, if it weren't impossible :-)
It's impossible because if (say) $a_1 = L$ and $b > 0$, then a suitable $a_2$ would have to be both $\le L$ and $\gt a_1$.
But suppose we restate the problem, so that $-L \lt a_1 \lt L$ and we require $-L \lt a_2 \lt L$. Now it's easy. All we need is a strictly increasing, invertible function  
$g: (-L,L) \rightarrow \mathbb{R}$
For instance: $g(x) = \tan(\frac{\pi x}{2L})$, with inverse $g^{-1}(y)=\frac{2L}{\pi}tan^{-1}(y)$  
Now define  
$f(a,b) = g^{-1}(g(a)+b)$
and we're done.
A: Except for the restriction of domain and range to $(-L,L)$, ordinary addition would work: $f(a,b) = a+b$.  So if you take $g : \mathbb{R}\rightarrow(-L,L)$ to be any increasing bijection, then $f(a,b) = g\left(g^{-1}(a) + b\right)$ will satisfy the requirements.  A nice specific example is $g(x) = L\tanh(x)$, whose inverse is $$g^{-1}(x) = \frac{1}{2}\log\left(\frac{L+x}{L-x}\right).$$
The desired function becomes
$$
f(a,b) = L \tanh\left(b + \frac{1}{2}\log\left(\frac{L+a}{L-a}\right)\right).
$$
