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

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):

    function 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.

share|cite|improve this question
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-……… – Kip Aug 17 '15 at 19:33
up vote 8 down vote accepted

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

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:

comparison graph

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

share|cite|improve this answer

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

share|cite|improve this answer
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}}$:
alt text

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

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.