# Chain Rule

Wave · y = f(x, t)

`y = d/dx (sin(x² − t))`

[Open in the app](https://www.wavelace.com/app#p=127) · [This page](https://www.wavelace.com/presets/chain-rule)

### What it draws

The slope of a chirp. The wave underneath is `sin(x² − t)`, whose crossings fall where `x²` is a multiple of `π`, at `1.77`, `2.51`, `3.07`, `3.54` and so on. They crowd together further out, because squaring makes the phase run faster the larger `x` becomes.

What is plotted is not that wave but its derivative, and the derivative is a different shape: `2x · cos(x² − t)`. It keeps the crowding, since the cosine turns over exactly where the sine did, and it gains something the original never had. The height grows.

### Where the height comes from

That growth is the chain rule, drawn. Differentiating `sin(f)` gives `cos(f)` multiplied by the slope of `f` itself, and here `f = x² − t`, whose slope is `2x`. So the wave is bounded between `−1` and `1` while its slope is bounded by `±2x`: at `x = 3` the envelope is 6, and at `x = 5` it is 10.

It makes sense from the picture alone. Out at the edges the wave completes a whole turn in a very short distance, so it must climb and fall steeply to do it. Near the origin it has all the room it needs and barely leans at all.

### Try

- Look at the wave itself with `sin(x² − t)`. Same crowding, flat envelope, and the contrast between the two is the whole idea.
- Make the inside linear with `d/dx (sin(3x − t))`. The slope is now a constant 3, so the envelope is flat: the growth came from the square, not from differentiating.
- Cube it instead, `d/dx (sin(x³ − t))`. The inner slope is `3x²`, so the envelope curves upward rather than climbing straight.
- Take the slope of the slope, `d/dx (d/dx (sin(x² − t)))`. It works, and it is visibly rougher: a difference of differences keeps about half the digits.

### Read more

- [Chain rule](https://en.wikipedia.org/wiki/Chain_rule)
- [Chirp](https://en.wikipedia.org/wiki/Chirp)
- [Instantaneous phase and frequency](https://en.wikipedia.org/wiki/Instantaneous_phase_and_frequency)
- [Numerical differentiation](https://en.wikipedia.org/wiki/Numerical_differentiation)
