Partial Sums

Wave · y = f(x, t)

y = Σ_(k=1)^(1 + floor(mod(t, 12))) sin((2k−1) · (x − t))/(2k−1)

Open in the app The dials and keys named below are the app's.

What it draws

A square wave, assembled one harmonic at a time. The first term alone is sin(x − t), an ordinary travelling sine whose crests are 2π ≈ 6.28 apart and which moves right at one unit a second at Speed 1. The clock then adds a term a second: sin(3(x − t))/3, then sin(5(x − t))/5, and so on to twelve before starting over.

Each new harmonic is odd, faster, and weaker in the same proportion. Their sum flattens the crests and steepens the crossings, so the sine turns into a row of plateaus joined by near-vertical walls.

Why only odd harmonics

A square wave is antisymmetric about its own half period: shift it by half a wavelength and it is the same shape upside down. Only odd multiples of the fundamental share that property, because an even one comes back unchanged instead of inverted. Every even harmonic therefore arrives with a coefficient of zero, and the series can skip them.

The overshoot that stays

The wave being built has height π/4 ≈ 0.785, yet the partial sums reach 0.93 just beside each wall and keep reaching it. Twelve terms overshoot as far as six do. Adding harmonics squeezes the bump sideways towards the jump but never flattens it, because the excess is a fixed share of the jump, about 9% of π/2. Those two ears are the Gibbs phenomenon.

Try

  • Hold the count at one term with sum(sin((2k−1)(x − t))/(2k−1), k, 1, 1). A plain sine, and the baseline for everything the other terms do.
  • Jump straight to forty with sum(sin((2k−1)(x − t))/(2k−1), k, 1, 40). The walls go vertical, and the ears sit right against them at the same height as before.
  • Divide by (2k−1)² instead. The harmonics fade faster, the corners round off, and a triangle wave appears with no overshoot at all.
  • Drop Ribbon depth to 1. Only the present curve is left, without its recent past behind it.

Read more

Wave · y = f(x, t)