# Square Orbit

Curve · (x, y, z) = f(u, t)

`(3 · Σ_(k=1)^(1 + floor(mod(t, 10))) (−1)^(k−1) · sin((2k−1) · u)/(2k−1)²,  0,  3 · Σ_(k=1)^(1 + floor(mod(t, 10))) (−1)^(k−1) · sin((2k−1) · (u + π/2))/(2k−1)²)`

[Open in the app](https://www.wavelace.com/app#p=117) · [This page](https://www.wavelace.com/presets/square-orbit)

### What it draws

Both coordinates are the same Fourier partial sum, a quarter period apart. The series `Σ (−1)^(k−1) · sin((2k−1)u)/(2k−1)²` is the triangle wave, and the second copy takes `u + π/2` in place of `u`. The `y` expression is 0, so the path stays flat on the ground.

One term each makes them `sin(u)` and `cos(u)`, which is a circle of radius 3. The clock adds a term a second, and by the tenth the path is a diamond: at every sample `|x| + |z| ≈ 3.7`, which is the equation of a square standing on its corner.

### Why a triangle wave squares it

A square traced at constant speed moves along one edge, turns, and moves along the next. On the right-hand edge one coordinate holds steady while the other runs from one end to the other, so each coordinate rises linearly, holds, falls linearly, holds. That is a triangle wave, and the two coordinates are offset by a quarter of a period because the edges are.

The corners sharpen but never quite arrive. Measured from the centre, a true square reaches its corners at `√2 ≈ 1.414` times its edge distance. This path reaches 1.348 at four terms and 1.385 at ten, closing on the value without meeting it.

### Try

- Watch one cycle from `Rewind`. The circle grows corners over ten seconds at `Speed` 1, then snaps back to a circle.
- Raise `Trail` to 20. Older outlines stay behind, so every stage of the convergence is on screen at once.
- Drop the alternating sign, using `sum(sin((2k−1)u)/(2k−1)², k, 1, 8)` for both. The harmonics no longer line up with the corners, and the ratio falls to 1.16, much nearer a circle.
- Change both denominators to `(2k−1)`. That series is the square wave, not the triangle, and its overshoot throws the path far past the corners: the ratio leaps to 3.3 rather than settling near 1.41.

### Read more

- [Triangle wave](https://en.wikipedia.org/wiki/Triangle_wave)
- [Fourier series](https://en.wikipedia.org/wiki/Fourier_series)
- [Taxicab geometry](https://en.wikipedia.org/wiki/Taxicab_geometry)
- [Lissajous curve](https://en.wikipedia.org/wiki/Lissajous_curve)
