Having fun while exploring topology
I never really studied topology but it sure feels like a field of math with a lot of nerd-snipes. In particular: let's talk about the Borsuk-Ulam theorem. Or at least: a simple version of it. The theorem says that any line you draw around a circle that connects back to itself you will always have two points on opposite sides of each-other with the same height.
What's fun with these topology theorems is that they are incredibly easy to demo now that we have widgets in Python notebooks! So I started a notebook with a widget that lets you draw points on a canvas.
Next, I would smoothe a line through these points and plot it on a polar coordinate system. The x coordinate would represent the angle and the y coordinate would represent the height. With that, I can now render these charts:
If you want to play around with the notebook yourself, you can do that here:
You can so much intuition when you're able to interact with the math directly. Not just with visual elements but also with Python code! There have been plenty of moments where the math doesn't immediately make sense to me and a Python implementation makes it much easier to wrap my head around it.
Why does this always work?
In this particular case, the math proof is pretty simple and satisfying too. Let $f(\theta)$ be our original function that goes around in a circle in the polar coordinate system.
Define $g(\theta) = f(\theta) - f(\theta + \pi)$.
Then:
$$g(0) = f(0) - f(\pi)$$
$$g(\pi) = f(\pi) - f(2\pi) = f(\pi) - f(0) = -g(0)$$
So $g(0)$ and $g(\pi)$ have opposite signs (unless one is already zero). By the Intermediate Value Theorem, $g$ must cross zero somewhere in between.
That zero is your antipodal pair: $f(\theta^) = f(\theta^ + \pi)$.
This is the 1D case of the Borsuk-Ulam theorem. The full theorem says: for any continuous map $f: S^n \to \mathbb{R}^n$, there exists a point $x$ where $f(x) = f(-x)$.