Smoothstep is a mathematical function that can smoothly interpolate between two values.

Smoothstep

In [2]:
def smoothstep(x: float) -> float:
    return x * x * (3 - 2 * x)
In [3]:
x = np.linspace(0, 1, 1000)
y = [smoothstep(i) for i in x]

_ = plt.plot(x, y)
Out:
<Figure size 1280x960 with 1 Axes>

Smootherstep

In [4]:
def smootherstep(x: float) -> float:
    return x * x * x * (x * (x * 6 - 15) + 10)
In [5]:
x = np.linspace(0, 1, 1000)
y = [smootherstep(i) for i in x]

_ = plt.plot(x, y)
Out:
<Figure size 1280x960 with 1 Axes>

Comparison

Here’s a comparison of the two functions.

In [6]:
x = np.linspace(0, 1, 1000)
y1 = [smoothstep(i) for i in x]
y2 = [smootherstep(i) for i in x]

_ = plt.plot(x, y1, label="Smoothstep")
_ = plt.plot(x, y2, label="Smootherstep")
_ = plt.legend()
Out:
<Figure size 1280x960 with 1 Axes>