How do I define a function that's first exponential and then logarithmic?

48 Views Asked by At

I want to define a continuous function $f(x)$ such that the following properties hold true.

  1. $f(0) = 1$
  2. $f(-1) = 1 - 0.5 = 0.5$
  3. $f(1) = 1 + 0.5 = 1.5$
  4. $f(-2) = 1 - 0.5 - 0.25 = 0.25$
  5. $f(2) = 1 + 0.5 + 0.25 = 1.75$
  6. $f(-3) = 1 - 0.5 - 0.25 - 0.125 = 0.125$
  7. $f(3) = 1 + 0.5 + 0.25 + 0.125 = 1.875$
  8. And so on, ad infinitum.

So, I know that I'm looking for some kind of a sigmoid function. My first approximation was to use the hyperbolic tangent.

$$f(x) = 1 + tanh(x)$$

This function ranges from $0$ to $2$, with $f(0) = 1$, just like I want. But, now I'm stuck. How do I scale it to match the function that I want?