# wave()

## Example

![](https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FtHhdB25yOWPOIr394yBn%2Fwave.gif?alt=media\&token=ffe70ae4-10d3-41b2-9eca-c3436657daac)

```python
def draw():
  ...  
  y = wave(0,height,10)
  circle(200,y,20)
```

![](https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2F5TUKk0KMU2XtL4cwYiAv%2Fwave3.gif?alt=media\&token=121556e6-7cc1-444a-af41-066e55d4c466)

```python
def draw():
  ...
  y = wave(0,height,10)
  x = x + 1
  circle(x,y,20)
```

### Syntax

```python
wave(edge1, edge2, speed)
```

<table><thead><tr><th width="162">Input</th><th>Description</th></tr></thead><tbody><tr><td>edge1</td><td>value for the start/first limit of the wave motion</td></tr><tr><td>edge2</td><td>value for the end/second limit of the wave motion</td></tr><tr><td>speed</td><td>the speed of wave motion</td></tr></tbody></table>

### Description

The `wave` function provides a method for generating a value that changes over time in a sinusoidal (wave-like) manner between two specific values: `edge1` and `edge2`.

`edge1` and `edge2` act as boundaries. `edge1` is the lowest value that can be returned, and `edge2` is the highest. The function will continuously generate a new value that lies somewhere between these two boundaries, following the pattern of a wave.

The rate at which this value changes follows a pendulum-like pattern and is controlled by the `speed` parameter. A higher `speed` will cause the wave to oscillate more rapidly between `edge1` and `edge2`, while a lower `speed` will make the oscillation slower.

Unlike a function that changes values linearly, `wave` produces values in a smooth, cyclic pattern, similar to the rise and fall of waves on the ocean, or the swinging of a pendulum. This is especially useful for simulations, animations, or other dynamic processes where a smooth, natural, and periodic variation is needed.

{% hint style="info" %}
Find these documents helpful? Let the people who made them help your child learn to code at [**Strivemath**](https://www.strivemath.com/)<mark style="color:blue;">**!**</mark>

We'd love to hear your Feedback/Comments [here](https://docs.google.com/forms/d/e/1FAIpQLSeqorBAGTya-YBRI-VFjJxtgQtCz3ucGDI96K96sNyuaGuvdw/viewform?usp=sf_link).
{% endhint %}
