# Heartbeat

Wave · y = f(x, t)

`y = 3 · exp(−40(mod(x − t, 4) − 2)²) − 0.6 · exp(−6(mod(x − t, 4) − 2.6)²)`

[Open in the app](https://www.wavelace.com/app#p=19) · [This page](https://www.wavelace.com/presets/heartbeat)

### What it draws

Everything hangs on `mod(x − t, 4)`, a ramp that climbs from `0` to `4` and starts again. Because it is fed `x − t`, the pattern repeats every `4` units along the line and travels to the right at one unit per second. One pulse passes any fixed point every `4` seconds at `Speed` 1.

The two terms are Gaussian bumps placed on that ramp. `3·exp(−40·(u − 2)²)` is the spike, centred at `u = 2`, with a width at half height of `0.263`. `−0.6·exp(−6·(u − 2.6)²)` is the trough that follows it, `0.6` further along. The trough is two and a half times as wide, at `0.680`, and a fifth as deep.

### How the two bumps meet

The trough is broad enough to reach back under the spike. At the spike's centre it subtracts `0.069`, so the tallest point of the curve is `2.931` rather than `3`, and it sits a little to the left of `u = 2`. The lowest point is `−0.600` at `u = 2.6`. Between beats the line is flat.

The ramp's jump from `4` back to `0` would show as a break. At both ends of it, though, the spike is smaller than `10^(−60)` and the trough smaller than `0.000005`: a discontinuous formula draws as a continuous one.

### Why it reads as a pulse

A narrow spike with a shallow depression trailing it is the signature the eye files as a heartbeat. The resemblance to a cardiac trace is deliberate, and the formula is a drawing rather than a model of anything a heart does. It is a useful shape all the same: a periodic train of well separated Gaussians is what a sampling pulse or a radar train looks like.

### Try

- `Front` in the deck: the trace side on, running right, which is the way a monitor draws it.
- Double the rate with `Speed` at 2: a beat every `2` seconds, with the pulses still `4` apart along the line.
- Blunt the spike by changing `−40` to `−10`, which widens it at half height from `0.263` to `0.527`.
- Turn the trough into a second bump by changing `−0.6` to `0.6`: a tall thin peak followed by a low round one.
- Raise `Ribbon depth` to 40: each spike trails away through the ribbon as a slanted ridge, and the slant is its speed.

### Read more

- [Gaussian function](https://en.wikipedia.org/wiki/Gaussian_function)
- [Full width at half maximum](https://en.wikipedia.org/wiki/Full_width_at_half_maximum)
- [Pulse (signal processing)](https://en.wikipedia.org/wiki/Pulse_(signal_processing))
- [Modulo](https://en.wikipedia.org/wiki/Modulo)
