Complexplorer

A Python library for visualizing complex functions — phase portraits, 3D landscapes, the Riemann sphere, Riemann surfaces, and STL export to 3D-printable mathematical ornaments. On PyPI.

Language: Python

License: MIT

Version: 3.1

Install: pip install complexplorer

Complexplorer turns a complex function into something you can look at — and, if you want, hold. It draws phase portraits and enhanced domain colorings, lifts them into 3D landscapes, onto the Riemann sphere, and onto the Riemann surfaces of multivalued functions, and exports the results as STL files for 3D printing.

Riemann relief map of f(z) = z/(z^10 − 1)

From mathematical function to physical sculpture: f(z) = z/(z¹⁰ − 1)

Highlights:

Recent releases

3.1.0 — 26 September 2026. Ornament geometry. Surfaces are now normalized so that arbitrary constants in a function no longer change the printed shape; the default transfer is logarithmic, and new pointiness and contrast controls tune how sharp the tips are. Six polyhedral ornament presets, built from Klein’s relative invariants, carry full tetrahedral, octahedral, or icosahedral symmetry. size_mm now measures true tip-to-tip width, and exported STL meshes are closed with consistent outward normals. Default geometry changed from 3.0 — see the migration guide.

3.0.0 — 19 September 2026. A full modernization: PyVista as the single 3D backend, Riemann surfaces, perceptual colormaps, the function catalog, engineering mode, a CLI, a typed public API, and a documentation site (migration guide).

Full notes are on the releases page.

The magic of complex numbers

The library takes its spirit from a passage that argues complex numbers are not a convenient fiction but something woven into nature itself:

We cannot directly see the minute details of a Dedekind cut, nor is it clear that arbitrarily great or arbitrarily tiny times or lengths actually exist in nature. One could say that the so-called ‘real numbers’ are as much a product of mathematicians’ imaginations as are the complex numbers. Yet we shall find that complex numbers, as much as reals, and perhaps even more, find a unity with nature that is truly remarkable. It is as though Nature herself is as impressed by the scope and consistency of the complex-number system as we are ourselves, and has entrusted to these numbers the precise operations of her world at its minutest scales. …

Moreover, to refer just to the scope and to the consistency of complex numbers does not do justice to this system. There is something more which, in my view, can only be referred to as ‘magic’.

— Sir Roger Penrose, The Road to Reality, Ch. 4: “Magical Complex Numbers”