I'm trying to create a function that makes a graph like this:
| | | - | - - | - - | - - |-------- -------- |-----------------------
I'm stuck with: $1/((x-1.5)^2)$
Any help?
I'm trying to create a function that makes a graph like this:
| | | - | - - | - - | - - |-------- -------- |-----------------------
I'm stuck with: $1/((x-1.5)^2)$
Any help?
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} $
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.
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}$