Function Curves

Learn how to make function curves.

We'll cover the following

Function curves

Sometimes, we might want to draw a curve based on a mathematical function. Here is an example of a function:

y = f(x):

y = math.sin(10*x) * math.exp(-x/2)

This function is a decaying sine wave. It represents a simple damped oscillation. An example of this is the sound created when we pluck a guitar string, which starts off loud and gradually fades away. Don’t worry too much about the details of the function. We are only using it because it looks quite nice.

This is a graph of the function, created using Pycairo:

Get hands-on with 1200+ tech skills courses.