Drawing a graph that is flat, but then spikes

2.9k Views Asked by At

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

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

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

Any help?

3

There are 3 best solutions below

2
On BEST ANSWER

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

2
On

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.

0
On

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}$ Plot of exp(-1/(1-x^2))
(Image from Wikimedia Commons, created and released into the public domain by Oleg Alexandrov.)