Thursday, 9 May 2019

One software to rule them all? Open source alternatives to Mathematica

This post is based on a joint talk with Riccardo Guida given at IPhT Saclay on May 7th.

Wolfram’s Mathematica has been the dominant computer algebra system for decades (at least in theoretical physics), and in an advertisement it even compared itself to Sauron’s One Ring.

Mathematica’s dominance however does not come from black magic, but rather from its quality and power compared to other available computer algebra systems. But dominant positions are often abused, and Wolfram’s commercial practices can verge on the abusive, though much less systematically than say Elsevier’s. In this blog post we will denounce the problems with Mathematica, and discuss four open source alternatives: SymPy, SageMath, Maxima, and FriCAS. In the case of SymPy, we will also provide a demonstration notebook.


The trouble with Mathematica


Since a Mathematica license comes at zero marginal cost to Wolfram, pricing is determined by Wolfram’s commercial policy, and can vary a lot between customers. Licenses are typically cheap for students; prices are higher for richer customers, and particularly high for non-academic institutions.

At IPhT Saclay, we have seen rather wild shifts in pricing: we used to get 200 institute-wide licences for about 25.000 euros a year, we now get 10 licences for the same price. (Anyone at IPhT can use these licences, but we can run no more than 10 instances of Mathematica simultaneously.) Such shifts do not obey consistent rules, and depend a lot on the particular salesperson we are dealing with at a given time. We are sometimes offered bargains: for example, we recently bought cheap perpetual licenses for individual users on MacOS. Alas, in this case, the so-called perpetual licenses turned out to be unusable on the next version of MacOS – unless we paid 700 euros per license for an upgrade.

The main issue with Mathematica may however not be its price, but more generally its availability. If you write some Mathematica code now, there is no guarantee that it can be run by your collaborators, the readers of your articles, or even by yourself in the future. (And the problem is compounded by the evolution of Mathematica, with one new major version every 2-3 years on average.) Your work is now subject to control by Wolfram: this is inconvenient and expensive nowadays, and could become disastrous if Wolfram got serious about milking the cow one day.


Advantages of open source software


In addition to solving the issues of cost and availability, open source software has a number of advantages:
  • You can examine what the software does, and need not trust a black box.
  • You can influence development not only by reporting bugs, but also by writing code yourself, or giving money for adding a particular feature.
  • Collaborative coding is easier with open source software, since people only need access to your code for being able to check, reproduce and improve it.
This may sound well and good, but are there viable open source alternatives to Mathematica? The answer would not have been obvious 10 or 15 years ago, but open source alternatives have progressed a lot since then, and the answer is a qualified yes nowadays. To be fair, Mathematica certainly remains the most complete and advanced computer algebra system. But we are not asking competitors to perform as well as Mathematica in all respects, we are only asking them to meet the needs of most researchers.

We will argue that open source competitors are good enough for allowing many researchers to do without Mathematica. The main remaining reasons that can prevent people from switching to open source are:
  • if they need a particular advanced feature of Mathematica that is absent in the competitors,
  • if they are captive of a large existing body of code and/or specialized Mathematica packages,
  • if they belong to large collaborations, which would require a concerted switch.


 Computer algebra systems at IPhT


We did a survey of computer algebra systems at IPhT, and got 42 answers (about half the researchers). The question was:
Which computer algebra system(s) did you use in the last 3 years?

NameOpen?# Users

As expected, Mathematica is more popular than all the alternatives combined. The nontrivial result is that most popular alternative is SymPy (together with other Python packages), which is used by nearly one quarter of respondents.


Four open source computer algebra systems

We begin with a technical fact sheet:

Initial release2007200519982007
Non-OS baseMacsyma 1982Axiom 1977
User LanguagePythonPython-ishMaximaSPAD
InterpreterCPython, PyPyCPythonCommon LispCommon Lisp
Expected speedC/50C/50 to CC/5C/5
NotebooksJupyter, TeXmacsJupyter, TeXmacswxMaxima, TeXmacsTeXmacs

The fine print:
  • By contributors we mean how many people did more than 9 commits between 2018-03-15 and 2019-03-15. Obviously SymPy and SageMath are much more actively developed than FriCAS and Maxima: this is particularly impressive in the case of SymPy, whose scope is narrower than SageMath’s. Both SymPy and SageMath regularly employ Google-funded interns.
  • Both SymPy and SageMath are based on the Python programming language, a very widespread and easy language. Google can quickly find an answer to almost any plausible question about Python. FriCAS has a dedicated language inspired by mathematics, and Maxima’s language is not far from Mathematica’s.
  • The expected speed is compared to that of the C programming language. Programs based on Python are slower, except when Python serves as an interface to code that actually runs in C. There is an ongoing effort to speed up SymPy and SageMath in this way.
SymPy, SageMath, Maxima and FriCAS are multi-platform, generalist computer algebra systems that have the expected basic features, including:
  • limits,
  • derivatives,
  • Taylor series,
  • basic integrals,
  • linear algebra,
  • special functions,
  • polynomial equations,
  • basic differential equations,
  • replacements,
  • arbitrary precision numerics.
They differ in the availability and quality of more advanced features. Strong points include
  • SymPy: Generalized hypergeometrics, automatic generation and execution of code, rule-based integration tools (RUBI).
  • SageMath: Manifolds, number theory, combinatorics.
  • FriCAS: Antiderivatives, noncommutative algebra, sparse polynomials.
The architecture of SageMath is peculiar, as it includes the other open source systems, plus some modules of its own:
SageMath = SageMathCore SymPy Maxima ⊕⋯⊕ FriCAS
This architecture has obvious advantages and disadvantages, in particular not all features of each included subsystem is available to users in a transparent way.

The best way to get an idea of the capabilities of a computer algebra system is a live demonstration. We have written a demonstration notebook for SymPy. It is publicly accessible in two versions: the .ipynb notebook itself, which can be run using Jupyter and SymPy, and the static .html output, which can be viewed in a browser. The end section of the notebook is a collection of useful weblinks on scientific Python.


  1. But what's the point you want to tell. Shall we conclude wxMaxima is the best open source alternate for symbolic computations?
    I used heavily wxMaxima, FriCAS and Mathematica.
    Though Mathematica is powerful among all, price tag is the dragger. (Not missing Wolfram)
    So I hope wxMaxima or FriCAS will be the choice.
    Please comment your views.

  2. Thank you for sharing your experience. The most suitable software for symbolic computations depends on the case: some users cannot escape Mathematica because they need specialized packages, others might be more or less sensitive to speed, etc. Personally I use SymPy but I also need SageMath for some specific calculations. Fortunately, SymPy and SageMath can cohabit in the same Jupyter notebook.