Experience report: Haskell and mathematics

Henning Thielemann · 2007

This report describes experiences with doing mathematics using Haskell in the fields of algebra and signal processing. It discusses advantages of several Haskell features and problems e.g. with re- spect to type classes and implicit contexts, that arise in mathemati- cal applications. We also propose solutions including references to the Numeric Prelude project. what the code is about and static type checking ensures that you can refactor the code later in a safe manner. Haskell can (still) not compete with specialized software in many fields of mathematics, due to the lack of sophisticated li- braries. Common computer algebra systems are great in symbolic integration, expression simplification and symbolic solution. Nu- merical linear algebra packages achieve high accuracy for impre- cise number representations at high speed. However Haskell al- lows applications that are not possible with those specialized pack- ages. Its strength is the lazy evaluation and the flexibility to com- bine many applications. With implementations of matrices and lazy computable reals you can immediately do matrix computa- tions over computable reals, which is possible with neither com- mon computer algebra systems, nor numerical linear algebra pack- ages. (TT06, Kar04) With an implementation of power series you can immediately work with polyphase matrices as needed in signal processing, you can solve differential equations by solving fixed point equations on lists. (Kar00) The same applies to time series and recursive filters. (Don03, Thi04, Thi07) Recursive filters for signal processing can be understood as the solution of a differential equation. To illustrate the elegance of Haskell for this kind of problems, here is a simple example for the approximative solution of an ordinary differential equation of the form y 0 (x) = f(x,y(x)) by the explicit Euler method in terms of a time series. The formulation of the problem is almost the solution in Haskell.

Read the paper · More papers on PaperTik