Math Phenomena, Visualized

An interactive collection of mathematical objects that I find interesting, rendered in the browser

Chaos Theory

Lorenz Attractor

The butterfly of chaos. A 3D shape born from weather equations where tiny differences lead to wildly different outcomes

Topology

Mobius Strip

A surface with only one side and one edge. Twist a strip and connect the ends

Topology

Klein Bottle

A closed surface with no inside or outside. It can only truly exist in four dimensions

Fractal

Sierpinski Triangle

Infinite self-similarity from a simple rule: remove the middle, repeat forever

Fractal

Mandelbrot Set

Infinite complexity from the simplest equation: z squared plus c, iterated forever

The Lorenz Attractor

A 3D shape born from weather equations, where tiny differences lead to wildly different outcomes

How a rounding error changed science

In 1963, an MIT meteorologist named Edward Lorenz was running a computer simulation of atmospheric convection. He wanted to re-examine a particular run, so he restarted the simulation from the middle. But instead of typing the full value 0.506127, he rounded it to 0.506.

That difference was less than 0.02%. It should not have mattered. But over time, the two simulations diverged completely. They started out nearly identical and ended up producing totally different weather patterns.

Lorenz had stumbled onto something fundamental: in certain systems, tiny differences in initial conditions get amplified over time until the outcomes are unrecognizable. This idea eventually became known as the "butterfly effect," and the mathematical structure behind it is called the Lorenz attractor.

What makes this so strange is that there is no randomness involved. The equations are entirely deterministic. If you plug in the exact same numbers, you get the exact same result every time. The problem is that you can never measure the real world with perfect precision. And in a chaotic system, "close enough" is never close enough.

Three coupled differential equations

The Lorenz system is built on three variables (x, y, and z) that represent a simplified model of atmospheric convection. Each equation describes how one variable changes over time, depending on the current values of all three.

\[\frac{dx}{dt} = \sigma\,(y - x)\]

The rate of change of x is proportional to the difference between y and x. When y is larger, x grows. When y is smaller, x shrinks. The parameter sigma controls how quickly x responds.

\[\frac{dy}{dt} = x\,(\rho - z) - y\]

This equation has a nonlinear term: x multiplied by (rho minus z). When z is small, this term drives y upward. When z is large, it suppresses y. The minus y at the end acts as a damping force that pulls y back toward zero.

\[\frac{dz}{dt} = x\,y - \beta\,z\]

The product of x and y pushes z upward, while beta times z pulls it back down. This competition between the two terms is what produces the attractor's characteristic double-lobed shape.

The nonlinear terms (x times z in the second equation, x times y in the third) are what make this system chaotic. Without them, the behavior would be straightforward.

The standard values

Lorenz chose these values to model convection rolls in the atmosphere. They have since become the standard test case for studying chaotic behavior. The attractor only appears for certain ranges of these parameters, and the classic values sit right in the heart of the chaotic regime.

SymbolValueMeaning
σ 10 Prandtl number. Controls how quickly heat spreads compared to how quickly the fluid flows.
ρ 28 Rayleigh number. Measures how big the temperature difference is between the top and bottom of the fluid.
β 8/3 Geometric factor. Related to the aspect ratio of the convection cell.

Where this shows up in practice

Chaos theory started with weather, but the same math turns up across a wide range of fields. Anywhere you find systems where outputs feed back into inputs, you're likely to find chaotic behavior.

  • Weather and climate modeling. This is where Lorenz's work began. Chaotic sensitivity is the reason weather forecasts lose accuracy after about 10 days, no matter how much data you collect.
  • Fluid dynamics. Turbulent flow in pipes, around aircraft, and through the ocean follows chaotic patterns. Understanding those patterns is a major part of modern engineering.
  • Cardiology. A healthy heart rhythm actually has a small amount of chaotic variability. When that variability disappears, it can be a warning sign of cardiac disease.
  • Cryptography. Chaotic systems produce outputs that look random but are fully deterministic. That property makes them useful for generating encryption keys and secure pseudo-random sequences.

The Möbius Strip

A surface with only one side and one edge. A fundamental object in topology

A surface with only one side

Imagine an ant walking along the surface of a Möbius strip. Without ever crossing an edge, the ant can reach every point on what appears to be "both sides" of the strip. That is because there is only one side. If you take a pen and draw a line down the center, you will trace a path that covers the entire surface before returning to its starting point.

The same is true of the boundary. An ordinary paper loop has two edges: an inner edge and an outer edge. The Möbius strip has only one. You can verify this by running your finger along the edge: you will travel the full length of the boundary without lifting your finger, arriving back where you started.

This means there's no way to label one side "top" and the other "bottom" across the whole thing. Any attempt to paint one side red and the other blue will fail. The two colors inevitably run into each other.

Parametric construction

The Möbius strip can be described by three parametric equations that map two parameters, u and v, to a point in 3D space. The parameter u sweeps around the loop from 0 to 2π, while v sweeps across the width of the strip.

\[ x(u,v) = \bigl(1 + v\cos\tfrac{u}{2}\bigr)\cos u \]

The x-coordinate combines the circular sweep (cos u) with a width modulation that depends on half the angle (cos u/2). This half-angle term is what creates the twist.

\[ y(u,v) = \bigl(1 + v\cos\tfrac{u}{2}\bigr)\sin u \]

The y-coordinate works the same way as x, but with sin u instead of cos u. Together, x and y trace a circle in the horizontal plane, modulated by the strip width.

\[ z(u,v) = v\sin\tfrac{u}{2} \]

The z-coordinate lifts the strip out of the plane. The sin(u/2) term starts at zero, rises to 1 at u = π, and returns to zero at u = 2π. But because it uses u/2 instead of u, the strip makes only a half-twist before closing, which is exactly what produces the one-sided topology.

The key insight is the u/2 factor. A full loop around the strip (u goes from 0 to 2π) produces only a half-rotation (u/2 goes from 0 to π) of the cross-section. This half-twist is what connects the "top" to the "bottom," creating a single continuous surface.

From Möbius to Klein

If you take two Möbius strips and glue them together along their single edges, the result is a Klein bottle, a closed surface with no inside or outside. The Klein bottle cannot exist in three-dimensional space without intersecting itself, but it lives naturally in four dimensions. The Möbius strip, then, is the simplest building block of non-orientable geometry.

The Möbius strip also shows up in surprisingly practical places. Conveyor belts are sometimes given a half-twist so that the belt wears evenly on "both sides." Since there is really only one side, every part of the belt surface contacts the rollers equally. The same principle has been applied to continuous-loop recording tapes and printer ribbons.

In mathematics, the Möbius strip is a key example in the study of shapes and surfaces. It demonstrates that not all surfaces are orientable, and it plays a role in understanding how different surfaces relate to each other.

The Klein Bottle

A closed surface with no inside and no outside. It can only truly exist in four dimensions

A surface with no inside

The Klein bottle is a closed surface, like a sphere, it has no edges. But unlike a sphere, it has no inside or outside. If you tried to paint the "outside" of a Klein bottle, you'd end up painting the "inside" too, because they're the same surface.

In three dimensions, the surface has to pass through itself to close up. This self-intersection is an artifact of being stuck in 3D. In four dimensions, the Klein bottle closes up cleanly without any intersection, the same way a figure-eight on paper seems to cross itself but a circle in 3D doesn't.

Classic bottle immersion

The classic Klein bottle is defined by a set of equations that work differently for each half. The parameter u sweeps from 0 to 2π while v sweeps from 0 to 2π. The tube radius r = 4(1 − cos(u)/2) varies so the neck narrows as it curves back through the body.

\[ \text{For } u < \pi: \quad x = 6\cos u\,(1+\sin u) + r\cos u\cos v, \quad y = 16\sin u + r\sin u\cos v \]

When u is in the first half, the tube shape attaches to the body surface, creating the bulging bottle shape. The 6cos(u)(1 + sin(u)) term traces the overall profile while the r·cos(v) terms add the circular tube cross-section.

\[ \text{For } u \geq \pi: \quad x = 6\cos u\,(1+\sin u) - r\cos v, \quad y = 16\sin u \]

In the second half, the tube detaches from the body axis and passes through the surface. The x-equation subtracts r·cos(v) independently of sin(u), forming the characteristic neck that dips back inside the bottle.

\[ z(u,v) = r\sin v, \quad r = 4\!\left(1 - \tfrac{\cos u}{2}\right) \]

The z-coordinate is the same for both halves. It simply lifts the tube shape out of the xy-plane. The varying radius r is what gives the bottle its recognizable shape: wide at the base, narrow at the neck.

The self-intersection where the neck passes through the body is unavoidable in 3D. In four dimensions, the Klein bottle closes seamlessly without any crossing.

Two Mobius strips

If you cut a Klein bottle in half along a certain curve, you get two Mobius strips. This connection goes both ways: gluing two Mobius strips edge-to-edge produces a Klein bottle. The one-sidedness of the Mobius strip is inherited by the Klein bottle. Both surfaces have only one side.

Mathematicians use a number called the Euler characteristic to tell surfaces apart. The Klein bottle scores 0, making it fundamentally different from the sphere (which scores 2). The torus also scores 0, but the torus is orientable and has a well-defined inside and outside. The Klein bottle is the simplest closed surface that is both one-sided and has no boundary.

The Sierpinski Triangle

A fractal that looks the same no matter how far you zoom in, more than a line, less than a plane

Self-similarity at every scale

The Sierpinski triangle looks the same no matter how closely you zoom in. Pick any corner of the triangle and magnify it, and you get the exact same shape. This property is called self-similarity (it looks the same at every scale), and it's the defining characteristic of a fractal.

The construction is deceptively simple: start with a triangle, remove the middle quarter, and repeat forever. At each step, you're left with three copies of the previous step, each half the size. The process never ends, and the result exists somewhere between a one-dimensional line and a two-dimensional surface.

Recursive construction

Two key quantities describe the Sierpinski triangle: the number of filled triangles at each depth, and its fractal dimension.

\[ N_n = 3^n \]

After n iterations, there are 3n filled triangles. At depth 7, that's 2,187 triangles. At depth 9, it's 19,683.

\[ D = \frac{\log 3}{\log 2} \approx 1.585 \]

The Sierpinski triangle has a fractal dimension of about 1.585. It's more than a line (dimension 1) but less than a filled surface (dimension 2). Each iteration triples the number of pieces while halving their size, and log(3)/log(2) captures exactly that ratio.

The chaos game

There's an entirely different way to construct the Sierpinski triangle. Pick three points as vertices. Start from any random point. Then, repeatedly: choose one of the three vertices at random and move halfway toward it. Plot the new point.

It seems like this should produce random noise. But after a few hundred points, the Sierpinski triangle begins to emerge. After thousands of points, it's unmistakable. This is called the "chaos game," and it reveals a deep connection between random processes and fractal patterns.

The Mandelbrot Set

Infinite complexity from the simplest possible equation: z squared plus c

RENDERING
Click anywhere to zoom in

The simplest equation with infinite complexity

The Mandelbrot set comes from iterating one equation over and over:

\[z_{n+1} = z_n^2 + c\]

Start with z = 0 and pick a complex number c. Square z, add c, and repeat. If the result stays bounded (never flies off to infinity), then c is in the Mandelbrot set. If it escapes, c is outside. That's the entire definition.

What makes this remarkable is that such a simple rule produces a shape of literally infinite complexity. No matter how far you zoom in, you find new detail: spirals, tendrils, miniature copies of the whole set, structures that never repeat exactly.

What the colors mean

Points inside the Mandelbrot set are colored black because their iterations never escape. Everything else is colored based on how quickly the iteration escapes. Points near the boundary take many iterations to escape, so they get "hotter" colors. Points far away escape almost immediately.

\[\text{escape: } |z_n|^2 > 4\]

We check whether the squared magnitude of z exceeds 4. Once it does, we know the sequence will shoot off to infinity. The number of iterations it took to reach this threshold determines the color.

The boundary of the Mandelbrot set, the edge between "stays bounded" and "escapes," is where all the visual complexity lives. Zooming into this boundary reveals an endless parade of intricate structures.

The shapes within the shape

The largest region is the main cardioid, the heart-shaped central body. Attached to its left is the period-2 bulb, a perfect circle. Smaller bulbs branch off at precise angles, each corresponding to a specific repeating cycle of the iteration.

At the tips of the filaments and in the valleys between bulbs, you can find miniature copies of the entire Mandelbrot set. These "mini-brots" appear at every scale, surrounded by their own spiraling decorations. The set is connected, meaning every part of it is joined together, no matter how thin the connecting filaments may appear.

The Mandelbrot set lives in the complex plane, where the horizontal axis represents the real part of c and the vertical axis represents the imaginary part. The full set fits within a circle of radius 2 centered at the origin.