Manifolds as Haskell types
Although its name would have you believe that numerical programming is about numbers (or “vectors of numbers” / matrices…), this is often not a good abstraction to start with.
The defining trait of the discipline is that it deals with approximate values on continuous scales. Often, those correspond to physical, measurable quantities (which are always only known up to some measurement-uncertainty). For many of those quantities, the description as a number or vector is the way to go, but for example for angles of direction, it quickly leads to problems: after a full rotation, you’re back at the starting point, and an algorithm that treats 390° and 30° as disparate values will not work reliably, nor one that considers 357° and 2° to be far apart.
The most common solution for such issues is to add problem-specific, ad-hoc special case distinctions; however that is error-prone and prevents the writing of generic algorithms. A safer option is to annotate through the type system that e.g. an angle lives not in ℝ but in the periodic space S1, the one-dimensional sphere. In other applications it may be higher-dimensional spheres, tori, etc.. To actually be able to use such values, one needs an abstraction that still allows expressing the relevant numerical operations.
Enter manifolds: topological spaces that look locally like a vector space, but not necessarily globally. In several dynamical CAS systems, this has been implemented by explicitly specifying charts, bijective mappings from a region in the space to a vector space.
Haskell’s type classes offer a particularly convenient alternative: an interface that generalises affine spaces, allowing directly considering the displacement between points in a sensibly typed manner. This introduces the notions of tangent vectors, cotangent vectors, Riemannian metrics etc. in an intuitive way, and allows generalising many numerical algorithms directly from their usual vector formulation to one that also works in non-flat spaces.
Geophysicist, Haskell hacker and musician.
Always in search of ways to bridge the gaps between these disciplines – in particular, bringing nice constructive, well-typed FP techniques to physics.
I’m currently writing a master’s thesis on the magnetic field of Neptune.
Thu 27 SepDisplayed time zone: Guadalajara, Mexico City, Monterrey change
14:30 - 15:10 | |||
14:30 40mTalk | Manifolds as Haskell types NPFL Justus Sagemüller Universität zu Köln, Institut für Geophysik und Meteorologie |