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

Quite simply, I need a function that will produce a graph similar to the one below. Important to note:

1) Y switches from negative to positive at X=1/3

2) Y ranges from -0.1 to +0.1, not to and from infinity

3) Y should be very close to 0 by X=1/6 and X=3/6.

4) It should have curves similar to those in the picture (Mod note: the original image link is dead, for context I'm replacing it with the graph of the function given in the accepted answer.)

enter image description here

A massive thank-you to whomever can figure this one out.

share|cite|improve this question
up vote 4 down vote accepted

I would suggest


and adjust the value of $c$ to speed up or slow the rate of decrease.

Yet another alternative:


share|cite|improve this answer
This looks to be exactly correct (according to WolframAlpha's grapher), however, it seems Lua doesn't have an arccotangent function... – Taehl Jan 3 '11 at 14:28
@Taehl: $\mathrm{arccot}(x)=\arctan(1/x)$ – non-expert Jan 3 '11 at 14:33
I must be expressing this wrong... (1/(5*pi))*atan(1/(x-1/3)) seems incorrect... – Taehl Jan 3 '11 at 14:40
Looks good to me. – non-expert Jan 3 '11 at 14:54
The tanh one worked even better. Thank you very much. – Taehl Jan 3 '11 at 14:59

Do you need continuity when you go through $x=\frac{1}{3}$? If not, you can use $y=0.1 \exp(-a(x-1/3))$ for $x \gt \frac{1}{3}$

$y=-0.1 \exp(a(x-1/3))$ for $x \lt \frac{1}{3}$

Pick $a$ to make it fall as fast as you want

share|cite|improve this answer
That was very close, and led me to a useable function - thank you! What I ended up with was: (n<1/3 and -.1^(-(n-1/3)) or .1^(n-1/3))/10) – Taehl Jan 3 '11 at 14:06

Using the Heaviside step function $H$, the following seems to be the simplest choice


share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.