# Heat Kernel

Wave · y = f(x, t)

`y = ∫_(x − 12)^(x + 12) sign(sin(u)) · exp(−(x − u)²/(0.2 + mod(t, 20))) du/sqrt(π · (0.2 + mod(t, 20)))`

[Open in the app](https://www.wavelace.com/app#p=103) · [This page](https://www.wavelace.com/presets/heat-kernel)

### What it draws

The curve is an integral, computed at every point: `y = ∫ sign(sin u) · e^(−(x − u)²/(0.2 + τ)) du / √(π·(0.2 + τ))`, with `τ = t mod 20`. `sign(sin u)` is a square wave of period `2π ≈ 6.28`, at `+1` for half a period and `−1` for the other half. The rest is a Gaussian centred on `x` with unit area, so `y` is a weighted average of the square wave around `x`. That is a convolution, and the width of the blur grows with the clock.

At `τ = 0` the kernel is only `√0.2 ≈ 0.45` wide, and the square wave shows with its corners softened. The blur then widens as `√(0.2 + τ)` and the wave melts, until at `t = 20` seconds at `Speed` 1 the modulo restarts the cycle. The limits `x ± 12` stand in for `±∞`, the kernel being negligible beyond them.

### The heat equation

A Gaussian whose variance grows in step with time is the heat kernel, the fundamental solution of the heat equation `∂u/∂τ = D · ∂²u/∂x²`, which turns an initial temperature into a later one by convolution. Here the initial profile is the square wave, and the diffusivity is `D = 1/4`, because the kernel's denominator `4Dτ` is `0.2 + τ`.

The square wave is a Fourier series, `(4/π)·(sin x + sin 3x/3 + sin 5x/5 + …)`, and the heat equation damps each harmonic `sin kx` by `e^(−k²(0.2 + τ)/4)`. The high harmonics are the corners, and they go first. The third harmonic is `22%` of the fundamental at the start and `3%` one second in, when the curve is already nearly a sine of height `0.91`. The fundamental halves every `4·ln 2 ≈ 2.77` seconds: `0.34` at `t = 5`, under `0.1` by `t = 10`.

### History

Joseph Fourier wrote down the heat equation and solved it with trigonometric series in a memoir of 1807, which the Paris Academy's referees, Lagrange among them, declined to publish. His book of 1822, Théorie analytique de la chaleur, set out the method in full: any profile is a sum of sines, and here each sine cools on its own.

### Try

- Start from a sine, `integral(sin(u)·exp(−(x − u)²/(0.2 + mod(t, 20))), u, x − 12, x + 12)/sqrt(π·(0.2 + mod(t, 20)))`: one harmonic only shrinks, never changes shape, its height exactly `e^(−(0.2 + τ)/4)`.
- Double the frequency, `sign(sin(2u))` in place of `sign(sin(u))`: the crests are half as far apart and the wave melts four times as fast, since the decay rate goes as `k²`.
- Change both `0.2` to `2`: the cycle starts already smoothed, a near sine of height `≈ 0.77`.
- Change both `20` to `5`: the reset comes while the crest still stands at `≈ 0.34`.

### Read more

- [Heat kernel](https://en.wikipedia.org/wiki/Heat_kernel)
- [Heat equation](https://en.wikipedia.org/wiki/Heat_equation)
- [Convolution](https://en.wikipedia.org/wiki/Convolution)
- [Fourier series](https://en.wikipedia.org/wiki/Fourier_series)
