Everything I do regularly in Mathematica can be done in Python. Even though Mathematica has a mind-boggling amount of functionality, I only use a tiny proportion of it. I skimmed through some of my Mathematica files to see what functions I use and then looked for Python counterparts. I found I use less of Mathematica than I imagined.

The core mathematical functions I need are in SciPy. The plotting features are in matplotlib. The SymPy library appears to have the symbolic functionality I need, though I’m as not sure about this one.

I don’t have much experience with the Python libraries listed above. I haven’t used SymPy at all; I’ve only browsed its web site. Maybe I’ll find I’d rather work in Mathematica, particularly when I’m just trying out ideas. But I want to experiment with using Python for more tasks.

As I’ve blogged about before, I’d like to consolidate my tools. I started using Emacs again because I was frustrated with using a different editor for every kind of file. One of the things I find promising about Python is that I may be able to do more in Python and reduce the number of programming languages I use regularly.

**Related posts**:

Languages that are easy to pick back up

Where the Unix philosophy breaks down

There is the little fact that these commercial tools (Mathematica, Maple, Matlab) tend to do some vendor lock-in. The more you invest in one particular tool, the more you have an incentive to continue. That’s a risky proposition on the long run.

I have promoted Python as an alternative to Matlab for a long time now. I had not realized we could use it as an alternative to Mathematica, but why not?

While it is slightly off-topic, Maxima is an excellent open source symbolic tool: http://maxima.sourceforge.net/

I have used Maxima, for serious work, in two research papers. Once in 2002 and once this year. I had maxima crunching polynomials for days a few months ago. It works well. It is not as smart as Mathematica or Maple, but good enough for my needs. There is a nice GUI which is very Maple-like.

Another open source symbolics package is GiNaC. This is actually a C++ library but there are Python bindings available via the PyGiNaC package.

Daniel: I’ve felt the vendor lock-in. I’ve used Mathematica off and on for two decades. It’s a great piece of software. How could I ever learn something else as well? But it looks like it’s not as hard as I thought.

…and if you use Sage (http://www.sagemath.org) you get an amazingly powerful CAS which is based on Python, so all your Python knowledge gets carried across. Sage actually contains Maxima (as well as lots of other open-source mathematical software) within it.

Alasdair: I’ve heard good things about SAGE. However, you can’t install it on Windows, and I’ve heard people say you can hardly install it on Linux: the best thing is to download a virtual machine with SAGE installed.

When I looked briefly at Maxima, the syntax looked awkward compared to Mathematica. Maybe it’s just a matter of familiarity. I’m sure Maxima is quite powerful.

@Alasdair, you beat me to the punch. Additionally, though I haven’t used it, I know that you can access Mathematica from within Sage, if for some reason there were a Mathematica function you needed or preferred.

Lets not forget Sage: a full-blown Python-based Computer Algebra System.

+1 for Sage. Though you need to run it in a VM on Windows, I’ve found it trivial to install on Ubuntu 9 and 10 as well as Mac OS X 10.6.

The nice thing about Mathematica is that it Just Works, and that all the tools from different fields are consolidated into one program, with consistent naming conventions. Not so for Python scientific tools; I wish they will move in this direction too.

If I understand correctly, Sage is trying to do it too, but I think that their disregard for normal, non-technical people is their big problem. I spoke to them and they pretty much said that they care mostly about Linux users because most of the developers of Sage are on Linux. I personally hate this attitude… There are so many scientists on Windows and in my opinion anyone who ignores Windows will end up in obscurity.

Lately I stopped using mathematica because of the vendor lockin and because mathematica took too much control of the problem solution. And replaced it with C++ and libraries usable from C++ for numerical work, for the symbolic part I realized that in general I needed it less that I though.

I see Sage has been mentioned. There is also the Enthought distribution of Python which is specifically aimed at computational science needs. A second option is the Python(x,y) distribution. It is a huge set of tools for Python (though you can customize it as needed) and comes with the Spyder terminal (used to be pydee). Spyder gives an interactive terminal much like MatLab.

I played around with Sage but it’s way too powerful for most everything I do. And I have never learned Python – I know Perl, R and Ruby.

I’ve used Maxima but found it hard to use until I got the wxMaxima GUI version. But for general numerical computing, I’m perfectly happy with R.

I really like NumPy/SciPy, etc. But regarding SymPy, are you sure it’s good enough? I know I looked at it some months ago and ruled it out for what I was trying to do (or maybe I just couldn’t do what I needed due to unfamiliarity).

I’ve compiled various versions of Sage on my Linux box over the years. It wasn’t at all difficult – however it does take hours to compile.

As for their disregard for Windows, perhaps they were careless in phrasing. They probably meant that their developers are Linux developers, and don’t know much about Windows. Likely they want a Windows version, but need developers familiar with Windows, and few/none have signed up. That’s a common problem with many open source projects (and it’s not their fault).

Also, knowing how Sage is built, it’d be a *major* challenge to get it running on Windows. It basically has custom versions of many large Linux projects within it. Some distributions don’t like it for that reason (redundancy). So to get it working on Windows, you have to port those other projects to Windows as well.

So, it’s been almost half a year, what’s the verdict?

Yaroslav: I still use Mathematica regularly, especially for symbolic computation. But I do use Python for more tasks than I used to.

I like that Mathematica’s syntax is very memorable. I can just fire it up and get down to business without having to look anything up. It’s convenient for quick calculations. If I needed to do extensive programming, I’d rather use Python.

For symbolic computation you might take a glance at Racket, which is a dialect of Lisp. (It grew out of a very mature implementation of Scheme.)

http://racket-lang.org/

As far as the syntax differences go, it really depends on how you used Mathematica. I tended to tackle problems from a functional perspective and so my Mathematica expressions were reminiscent of the Lisp style – the only differences being that function application looked like F[…] instead of (F …).

Hi, I just came across this posting of yours. I would like to ask a question about SymPy (perhaps you have more experience with it now?). Does SymPy, or Python itself, has the “patterns” feature of Mathematica? Certainly there are some “pattern” feature in Python. Moreover it can incorporate Perl codes in it. But how good is it compared to Mathematica?

I ask because I do not have the time yet to learn about Python (I mean, I can program in Python, but I have not learn NumPy and SymPy yet). If it is not better than Mathematica in this part, I would choose to stay with Mathematica.

Moreover, now Mathematica has built-in support of parallel and GPU computing interface. If you want to have complicated and fully optimized parallel/GPU programs, this is not enough. But this saves a huge amount of program developing time if the computation is straight forward.