# Drawing a graph that is flat, but then spikes

I'm trying to create a function that makes a graph like this:

|
|
|           -
|          - -
|         -   -
|        -     -
|--------       --------
|-----------------------


I'm stuck with: $1/((x-1.5)^2)$

Any help?

-
What about like a bell curve? –  mathguy Dec 23 '12 at 19:28
I used a tent function in the end. Thanks! –  Todd Davies Dec 23 '12 at 20:00

Sometimes such functions are called triangular or tent functions.

The most basic example centered at $0$ looks like : $$f(x) = \begin{cases} 1- |x|, & \text{if }|x|<1\\ 0, & \text{ else} \end{cases}$$

-
I'd like it to be a curve ideally. Unfortunately, my graph doesn't really get that across very well... –  Todd Davies Dec 23 '12 at 19:31
Can I have an example of the function for this please, I can't work it out from wikipedia –  Todd Davies Dec 23 '12 at 19:37

You can do $y=e^{-x^2}$ It isn't exactly flat on the sides, but it pretty much is. You can edit either the $e$, $2$, coefficient, or the denominator to change the shape (and translate it wherever you need).

As the comment below suggests, it's a Gaussian Curve.

-
such functions are often known as gaussian curves, see : en.wikipedia.org/wiki/Gaussian_function –  MSEoris Dec 23 '12 at 19:33
Thanks, didn't know the name for it. –  mathguy Dec 23 '12 at 19:34

If you want your function to be both smooth and zero everywhere outside a finite interval, what you need is a bump function. A classic example is $$f(x) = \begin{cases} e^{-1/(1-x^2)} & \text{for } -1 \le x \le 1 \\ 0 & \text{otherwise}, \end{cases}$$ which looks like this:

$\hspace{70px}$
(Image from Wikimedia Commons, created and released into the public domain by Oleg Alexandrov.)

-

The function $1/(x-1.5)^2$ that you pointed couldn't have such that shape. But doing some changes can make it to have that desire shape. It is $$f(x)=\frac{1}{(x^2+1.5)^2}$$

-