Smoothstep

Interpolation function
Reading time: about 3 minutes

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>

The following pages link here

Citation

If you find this work useful, please cite it as:
@article{yaltiraklismoothstep,
  title   = "Smoothstep",
  author  = "Yaltirakli, Gokberk",
  journal = "gkbrk.com",
  year    = "2024",
  url     = "https://www.gkbrk.com/smoothstep"
}
Not using BibTeX? Click here for more citation styles.
IEEE Citation
Gokberk Yaltirakli, "Smoothstep", November, 2024. [Online]. Available: https://www.gkbrk.com/smoothstep. [Accessed Nov. 12, 2024].
APA Style
Yaltirakli, G. (2024, November 12). Smoothstep. https://www.gkbrk.com/smoothstep
Bluebook Style
Gokberk Yaltirakli, Smoothstep, GKBRK.COM (Nov. 12, 2024), https://www.gkbrk.com/smoothstep

Comments

© 2024 Gokberk Yaltirakli