Every closed curve hides a square? Draw one and watch the hunt (open since 1911).
Toeplitz asked in 1911 whether every closed curve passes through the four corners of a square: proven for smooth curves, still open in general, and in 2020 Greene and Lobb showed smooth curves inscribe rectangles of every aspect ratio. The curve here is a 20-harmonic Fourier series, so it is smooth with an exact derivative. Every pair of 240 samples is tried as a diagonal, the other two corners are predicted, and a spatial hash checks whether both land near the curve; the best seeds are polished by Newton's method on four curve parameters with the exact 4x4 Jacobian. Found squares are tracked frame to frame as the curve morphs, so they slide along it and are born and die in pairs. The inset shows pair space, the torus of diagonal endpoints, where each square appears as a crossing of two color boundaries.
Try it. Draw a closed loop anywhere to test your own curve. Drag the curve to bend it and watch the squares follow. Switch between Squares and Rectangles with the chips or S and R; rectangles sweep through aspect ratios. N morphs to the next curve and Space freezes the wobble.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build an inscribed square finder with JavaScript and the HTML canvas element: I draw a closed curve and the program finds squares whose four corners all lie on it. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window. Paint it an off-white paper color.
- Start with a smooth blob given in polar form, for example r(a) = 1 + 0.2 cos(3a) + 0.1 cos(2a + 1), and draw it as a thick dark line.
- Sample about 200 points along the curve. Try every pair of samples as a diagonal of a square: the other two corners are the midpoint plus and minus half the diagonal turned 90 degrees.
- Measure how far each predicted corner is from the nearest sample. Keep pairs where both corners are within about one sample spacing, skip near-duplicates, and draw the best matches as translucent colored squares with small circles at the corners.
- Let me draw my own closed loop with the pointer, resample it evenly by arclength, and search again.
Once that works, make it beautiful:
- Refine each match so its corners sit exactly on the curve: treat the four corner positions as curve parameters and use Newton's method on the conditions 'diagonals share a midpoint' and 'one diagonal is the other turned 90 degrees'.
- Animate the curve slowly and re-solve from the previous answers each frame, so the squares slide smoothly instead of flickering.
- Give the squares soft drop shadows so they look like paper cutouts.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as rectangles of any aspect ratio, a spatial hash to speed up the search, or a plot of the pair space where squares appear as crossings.