The Factory

Beauty may be in the eye of the beholder (which is about as good a thing as you could ever want stuck in your eye), but it's surely a myopically specky polyester-wearing geek who sees the beauty in maths. One thing you can say is that the subject is a remarkably blot-free land-scape. If something's wrong, nobody keeps banging-on about how much better it would have been if people had just bought into it. I also like the way that they've planned the route ahead, laying out the trickiest puzzles, before sitting down & scratching their egg-heads; it's like having sat-nav.

If one divides the human-race into two (technically just arithmetic), taking care not to vivisect accidentally any odd individual, then I'd be in the geekier half. I might still be in the rubbish-at-sports side after twenty or so more bisections, but even I find a lot of those things about which mathematicians rant, utterly incomprehensible; & their writing would probably make a lot more sense to a Greek (if they didn't have sovereign-default to occupy their thoughts). Whilst I learned nothing (AKA "zero") in maths-classes at school, (discounting the ability to spell words in beghilos, on the inverted display of my calculator), I learned no more in any other class, & the maths-class was as good a place as I could find, to give my weary brain a welcome break from the relentless push-ups that the education-system inflicted upon it. As a side-note, the aptly named Edmund Burke, who claimed that those failing to learn history were destined to repeat it, was on reflection, wrong; I swapped it for geography. Of course, school wasn't as much about education, as segregating fearful oiks like me, from fully qualified members of the human race.

Maths is often seen as a massive chore, but it's not an infinite chore, nor is this chore indivisible, & breaking it down into its prime-factors, we find that a small percentage of these sub-domains are little more than merely annoying; like statistics. So, feeling that the old brain-noodle had been a bit feeble lately, I thought I'd give it a stiff work-out on a few of the least annoying bits. I'm not about to deal a death-blow to any of the unsolved problems of mathematics (that would imply talent), but rather have fun implementing some known algorithms.

This may all be an obtuse-angled bum-steer as far as you're concerned, & whilst I confess that it's hard to compete with getting completely trousered in the pub, since though you'll have a sore head either way, at least this way you won't be factoring the cost. It has to be said that once this simple mission got rolling, it built a head of steam & turned into a run-away train. Then I started enjoying it & wearing more polyester; it's a dangerous game.

This web-site isn't primarily about maths, it's more about functional-programming & Haskell; maths is merely the current focus of my short attention-span. The result is that I've implemented several algorithms in each of the following domains, most of which concern number-theory (a senseless homographic pun), but I've left the mathematical description to those bald enough to know better. The functions I've implemented are intended to form an API, but have also been linked into an application, to facilitate measurement of their performance. The following modules are the most significant in the package "factory":


To support these, there are several ancillary modules:

Arithmetic-geometric mean:

To support the Brent-Salamin algorithm for Pi.


The Ackermann-Péter function, tetration, pentation …


Supports basic (& modular) polynomial arithmetic, including division, & exponentiation, as required to support the AKS primality-test.


Implements algorithms for fast modular exponentiation by squaring, & to detect square numbers & perfect powers.


Permitting the expression of integers in alternative number-systems, including support for negative bases.


Generation of sample populations with either Normal or Poisson distribution.


Calculation of; mean, variance, standard-deviation, nCr, nPr.