Equation for a smooth step function

11.9k Views Asked by At

https://i.stack.imgur.com/t1PlV.jpg

The equation must be smooth and satisfy the following two conditions:

  • When $x \leq -10, y=-50$
  • When $x \geq 10, y=50$

Is there an equation (or multiple equations) that lets me graph a curve that looks like that?

3

There are 3 best solutions below

0
On BEST ANSWER

The sigmoid function, $S(x) = \frac{1}{1+e^{-x}}$, achieves close to what you need (with appropriate scaling and shifting of the function).

Do you need the function to be exactly $\pm 50$ when evaluated at $\pm 10$? If so, a polynomial option would be to use something called the smoothstep function, built using the function $f(x) = 3x^2-2x^3$. Modified to your problem, the desired function, denoted by $g(x)$, is $$ g(x) = \begin{cases} -50 & \text{ if } x\le -10\\ 100\left(3(0.05x+0.5)^2-2(0.05x+0.5)^3 - 0.5\right) & \text{ if } -10<x\le 10\\ 50 & \text{ if } x>10 \end{cases}$$

0
On

If necessary you could scale a sine function to make the transition:

$$ f(x) = \begin{cases} -50 & \quad x<-10\\ 50\sin(\pi x/20) & \quad -10 \le x \le 10 \\ 50 & \quad x >10 \end{cases}$$

0
On

There exist smooth complactly supported functions on $\mathbb{R}$, namely bump functions. Pick any such function and integrate it to obtain a monotonic smooth function $F$ that is zero for small enough values and is some non-zero constant for large enough values. Then you can obtain a graph like on the picture with an appropriate affine transformation. ($aF(bx+c)+d$ for some $a,b,c,d\in\mathbb{R}$)