# Family of functions with two horizontal asymptotes

I'm looking for the equation of a family of functions that roughly resembles the sketch below (with apologies for the crudeness of said sketch):

Properties I'm looking for:

• $\lim_{x\to-\infty}f(x)=y_1$ (i.e. approaches asymptote y=y1)
• $\lim_{x\to+\infty}f(x)=y_2$ (i.e. approaches asymptote y=y2)
• $|f'(x)|$ is at a maximum at x=0

I remember something involving ex/(??), but I can't remember exactly and can't seem to come up with the formula. I want to use it to weight tags in a tag cloud (i.e. the more recently a tag was used (smaller x), the more weight (larger y) the tag gets). The whole graph would be shifted up and to the right of what is shown in the sketch, but I know how to do that part once I have a formula.

-
In general, functions like this are called sigmoid, and wikipedia has a list of several types. I provided one that is typically very easy to compute/understand. – Larry Wang Aug 13 '10 at 17:27
Without looking at the wikipedia page ;) , the error function, the hyperbolic tangent, and the arctangent would have sigmoidal behavior. As a matter of fact, the integral of any "bell-shaped" curve will have sigmoidal behavior. – J. M. Aug 14 '10 at 0:19
@IlmariKaronen awesome thanks. there is ongoing discussion of this on metas- meta.stackexchange.com/questions/263771/… meta.stackexchange.com/questions/231613/… meta.stackoverflow.com/questions/300232/ban-imageshack-images/… – Kip Aug 17 '15 at 19:33

I think what you're looking for is a form of logistic function, such as $$f(x)=\frac{2}{1+e^x}-1.$$

edit: For your specific criteria with $y_1$ and $y_2$: $$f(x)=\frac{y_1-y_2}{1+e^x}+y_2.$$

edit 2: For comparison of my answer to the other two answers:

dashed/black: $\frac{2}{1+e^x}-1$; blue: $-\frac{2}{\pi}\arctan x$; red: $-\frac{x}{\sqrt{x^2+1}}$

-

Just take $- tan^{-1} x$. Vary it appropriately for additional constraints.

-
Indeed, when I looked at the graph, I thought "well that's the graph of $-\tan^{-1}(x)$". – Pete L. Clark Aug 13 '10 at 21:08

Another famous family of functions that behave as you describe is those of form $y=\dfrac{x}{\sqrt{x^2+1}}$. (This function is actually the sine of the arctan function George suggested)

Graph of $y=-\dfrac{x}{\sqrt{x^2+1}}$:

For a general y1 and y2, the formula would be $y=-\dfrac{y_1-y_2}{2}*\dfrac{x}{\sqrt{x^2+1}}+\dfrac{y_1+y_2}{2}$

-