Ten one-liners: handling power series in Haskell
I will show how to implement customary operations (arithmetic,
composition, functional inversion, calculus) and demonstrate
applications as diverse as map projections, combinatoric
generating functions, and solution of differential equations.
Example: this working code for trig functions
sinx = integral cosx
cosx = 1 - integral sinx
produces for sinx the list [0,1,0,-1/6,0,1/120, ...] of
coefficients of the familiar series x-x^3/3!+x^5/5! ...
Power series algorithms, a poster child for lazy evaluation,
attain remarkable elegance in Haskell. The neat package to
be described (http://www.cs.dartmouth.edu/~doug/powser.html)
illustrates how several distinctive features of Haskell
can be used to achieve mathematically appealing notation.
These mechanisms (polymorphism, type classes, and overloading)
apply equally well in packages for other algebraically
structured domains.
Assumed background: calculus and Taylor series, reasonable
comfort with type signatures and head-tail decomposition
of lists. Non-intuitive Haskell constructs will be explained.
------------------------------------------------------------------------
M. Douglas McIlroy
Department of Computer Science
Dartmouth College 6211
Hanover, NH 03750, USA