Some code for generating the mathematical surfaces described by Catastrophe theory
Find a file
Bruno Postle 1aaa7751bc Widen butterfly ranges and increase grid resolution
Increase GRID to 400 for smoother fold ridges, widen X_RANGE and
C_RANGE, and reduce D_SCALE to compensate. Also mark the script
executable with a shebang.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-31 09:44:22 +01:00
.gitignore Add README and GPLv3+ license 2026-07-31 09:41:52 +01:00
butterfly_catastrophe.py Widen butterfly ranges and increase grid resolution 2026-07-31 09:44:22 +01:00
butterfly_catastrophe.stl Widen butterfly ranges and increase grid resolution 2026-07-31 09:44:22 +01:00
CLAUDE.md use xz plane instead of xy 2026-03-25 21:53:25 +00:00
LICENSE Add README and GPLv3+ license 2026-07-31 09:41:52 +01:00
README.md Add README and GPLv3+ license 2026-07-31 09:41:52 +01:00

Catastrophe

3D-printable STL models of surfaces from catastrophe theory — a branch of mathematics studying how small changes in parameters can cause sudden, discontinuous changes in a system's equilibrium state.

This is a personal, exploratory project rather than a polished library — code and comments are kept up to date, but no API stability or reuse outside this repo should be assumed.

Butterfly catastrophe

butterfly_catastrophe.py generates butterfly_catastrophe.stl, a height-field mesh of the equilibrium manifold for the potential

V(x) = x^6 + a*x^4 + c*x^2 + d*x   (a = -3 fixed, b = 0)

Equilibria satisfy dV/dx = 0, which rearranges into a single-valued height field d(x, c), avoiding root-finding or branch-tracking across fold lines. See CLAUDE.md for the full derivation, tuning parameters, and printing notes.

Usage

pip install numpy
python butterfly_catastrophe.py

Output: butterfly_catastrophe.stl, ready to slice and print.

License

GPLv3-or-later — see LICENSE.