Computer Algebra Programs

In order to work with the mathematics on this site it is useful to have a computer algebra program. It is possible to do numeric arithmetic, involving integers, floating point, complex numbers, vectors, quaternions, matrix and so on, in most programming languages. Most languages have mathematical libraries that that help with these sort of numeric calculations.

However, when we want to do more general computer algebra, involving symbolic values and more abstract algebra concepts, then things get a bit more complicated. We could either try to code these things using a mainstream computer language or use a CAS (Computer Algebra System) that is a language or program specifically designed for computer algebra. There does not seem to be an ideal solution here, each approach has disadvantages as well as advantages.

There are many good open source CAS programs but many of them are specific to certain types of mathematics. Since I wanted an open source program with capability across a wide range of mathematics then I narrowed the choice down to two options.

Sage - Uses Python to call other programs alongside its own Python code.

Axiom and its forks - Uses Lisp but is programmed in its own language SPAD.

Both systems have their pros and cons but overall I like the power of the SPAD language which is designed specifically for mathematics and uses static typing as opposed to Pythons dynamic typing. The typing system in SPAD is very powerful in certain areas such as supporting 'dependant types' which most languages don't. However there are other aspects of the SPAD which is not as powerful as say Haskell. Also SPAD is very quirky, has a steep learning curve and the error messages and general infrastructure can be challenging.

For a wider discussion of computer projects for mathematics see this page.

Axiom/FriCAS/Aldor

These programs all derive from an experimental maths program by IBM. There are now various versions which can be confusing for new users.

I suggest potential new users try FriCAS first, since it seems to be the most actively developed version, see page here.

Axiom uses a language called 'SPAD' (a shortened form of the word 'Scratchpad') to allow users to define algebras. It comes with a big library of algebras which interwork with each other, users can add their own algebras to interwork with these. I have described SPAD on this page, axiom comes with both an SPAD compiler and an interpreter.

SPAD is built on top of the language 'Lisp'. The development environment for SPAD is minimal, programs are edited using any text editor and run form the command line. The error messages are often very unhelpful and frequently refer to the underlying Lisp code.

The learning curve for SPAD is very steep, many feature of the language such as the pattern matching used to dispatch functions can be difficult to understand and try to work out what function will be called. A mathematics program really needs to be more predictable than this. The type system does have its limitations, its not possible to represent category theory concepts such as monads in the way that languages like Haskell or Scala can.

Having said all this, SPADs tradeoff between dependant types and type safety is very powerful, I think the language deserves to be much more widely used if only some of these issues could be tackled. I have put my 'wish list' for improvements that I would like to the FriCAS program on the page here.

Axiom is a free (open source) general purpose computer algebra system. It has been in development since 1971 originally as Scratchpad by researchers at IBM under the direction of Richard Dimick Jenks. In the 1990s it was sold to NAG and given its current name. In 2001 it was withdrawn from the market and released to Tim Daly, the project lead developer, under the Modified BSD License. In 2007, Axiom was forked into two different open source projects: OpenAxiom, and FriCAS. The amount of developer activity seems very low at the moment and it is a pity that the developer effort and user resources are fragmented in this way.

Documentation

I'll quote what Tim Daly wrote here: "In general, Axiom was created as a piece of research software used
only by fellow researchers, usually to complete their thesis work.
Thus, the algorithms are world class. But the documentation isn't."

Tims answer is 'Literate Programming' as explained here. Although many people would agree with its aims I don't think there is a lot of agreement in its methods. It seems to require an extra layer of non-standard tools for programmers and I don't think everyone wants to read programs+documentation in a linear manor like a book. In the case of Axiom the literate programming experiment seems not altogether successful (yet?), its hard to see how such a heavyweight methodology can fill in the gaps in so much undocumented code. The leaders of the forks of Axiom seem (how can I put this politely?) ambivalent, at best, to the whole topic of documentation, even for new code.

The result of all this is that documentation is incomplete, often out-of-date and fragmented. Potential users and programmers have to search in lots of places and this makes a steep learning curve worse.

Being removed or left as comments. Spread over about 400 files and it is not always clear which one might hold the information that is being sought.

HyperDoc - from program

Potentially a powerful idea, for example '++' comments are picked up by HyperDoc. But HyperDoc has an old fashioned interface, in a small window on the screen. Hard to write and hard to use. I gave up using because it often crashed (may be fixed now?)

SPAD Language

Although the Axiom/FriCAS computer algebra system is written in Lisp, users of the program don't need to know Lisp. The SPAD (a contraction of Scratchpad) language is used when we want to implement custom algebras and mathematical structures.

Other Options - Idris

Since Axiom / FriCAS is not ideal I am also looking at other languages such as Idris. When it was written SPAD was far ahead of its time but modern languages are finally now catching up and implementing these things in a more consistent way, Some of the issues with SPAD are:

SPAD does not conform to modern expectations and so has a steep learning curve.

Pattern matching is unpredictable for users.

Problems with type system, for example difficult to implement higher order types (kinds), so cant implement category theoretic structures such as monads.

Uses a non-standard parser, this means that error message are not very helpful.

Low level code is written in Lisp, this causes a number of problems, for example it is not possible to write parallel code.

Proofs are not implemented and messy code would make that difficult.

I am therefore experimenting with Idris (see this page), it looks very promising however I am finding some problems in implementing some thing in Idris, although Idris has the kind of structure that I want there are problems when it comes to the user interface (input/output). I think it is really important that mathematical structures are represented using a notation that mathematicians can recognise (both in REPL and compiler). Some of these issues are:

Hard to notate variables, expressions and equations.

Assignment uses '=' instead of ':=' which means that '=' cant be used for equations.

No way to output REPL session to formats such as MathML, LaTeX, etc.

metadata block

see also:

For a wider discussion of computer projects for mathematics see this page.