[Haskell-cafe] Implementing Mathematica

Andrew Coppin andrewcoppin at btinternet.com
Fri Jun 1 14:27:21 EDT 2007

jerzy.karczmarczuk at info.unicaen.fr wrote:
> Andrew Coppin cites me and asks:
>> I find that statement interesting. I have never come across *any* 
>> other package that can perform _symbolic_ mathematics.
>> (Sure, there are packages that can perform specific operations - 
>> solving certain kinds of equations, transforming matricies, 
>> rearranging formulas. But I have never seen any other package where 
>> you can just do *anything*.)
> You must be joking, but OK, I am naive, and I will answer as it were
> serious. Really, haven't heard about Maple???
> http://www.maplesoft.com/

Last I heard, Maple is simply another fast number-chrunking engine.

> Its limited library is integrated within Matlab Symbolic Toolbox, and if
> you *have* Maple and Matlab, the latter can use the full force of the
> former.

Now Matlab I have heard of. (And I hate it with a passion.)

> Maple is commercial as Mathematica, but there are perfectly
> usable free packages as well, for example Axiom and Maxima (Macsyma
> rekindled).
> http://wiki.axiom-developer.org/FrontPage
> http://maxima.sourceforge.net/

Now this actually looks vaguely promising. (Rather confused at this 
point as to what the relationship between Axiom, Maxima, Reduce and Sage 

> The are more free stuff, GAP, MaCaulay,... In general, check
> http://en.wikipedia.org/wiki/Comparison_of_computer_algebra_systems

I did indeed check that list a while back. I looked at a whole heap of 
systems listed, but... half of them didn't seem to exist any more, and 
the other half looked very clunky, had strange syntax, and only handled 
a few specific constructs.

>> But yes - I have tried to implement that pattern matching engine a 
>> couple of times in Pascal. (Remember Pascal?)  Getting it to work for 
>> a few test cases is easy. Getting it to *properly* handle 
>> associativity and commutivity is really nontrivial. (I mean *really* 
>> nontrivial! Or perhaps I am an inferior programmer - one of the two!)
> The mathematically sensitive matching/substitution is a hard task even if
> you have at your disposal a reasonably full unifier. Forget Pascal, take
> Prolog, which will save several days/weeks of the implementation of basic
> stuff. Even then, it will be quite tedious to write a package able 
> say, to
> reduce rational formulae, to reduce a polynomial modulo an ideal, to
> implement the basic trig identities, find a reasonable common form for
> expressions containing complex exponentials AND trigonometrics, etc.

LOL! I did try to learn Prolog once... I never did understand how it was 
able to make impossible leaps of deduction like that. And yet, in other, 
similar cases, it couldn't figure out the result.

Of course, now I know that the answer is a magic trick known as 
unification (although I still don't know much about that topic). Not 
really sure how a unifyer would help you manipulate symbolic expressions...

If I get time, I might have another go at implementing the pattern 
matching algorithm in Haskell. Of course, even if it works, that's still 
a pretty small problem compared to finding a set of transformation rules 
that cover all the cases you care about, is reasonably efficient, 
produces the right answers...etc...etc...

More information about the Haskell-Cafe mailing list