37
$\begingroup$

Python's family of packages for scientific computing has matured rapidly. I can pretty much replicate all of Mathematica's functionalities, but with production level and open-source code using the following:

  • Numpy, Scipy, Sklearn for math and algorithmics
  • matplotlib for graphics
  • ipython notebooks for notebooks and cells
  • SWIG or Cython for c-speed enchancements
  • PYPY and many other project to cover other functionalities

Mathematica does still have a few advantages though:

  • Everything is nicely integrated and documented in one place
  • Dynamic's and Manipulates are fun!
  • Mathematica's functional language is neat and allows rapid prototyping

However,

  • It takes little effort to download and integrate any needed python package
  • Notebooks and their contents are not truly deployable (even pdf printing doesn't work)
  • Python already has much of the same functional constructs
  • Most Mathematica functions (especially anything with graphics, graphs, or images) are not compilable, but about everything in Python is!

As a developer I'd like to ask if there any other significant advantages to Mathematica - are there any areas where Mathematica is still vastly superior to the Python stack other than in computer algebra?

Are there any insightful Mathematica vs Python performance benchmark studies like this one for Mathematica vs. Maple?

$\endgroup$
  • 11
    $\begingroup$ I would hardly call that Maple comparison "insightful"!!! See (60124) $\endgroup$ – dr.blochwave Jun 16 '15 at 15:21
  • 3
    $\begingroup$ @N.J.Evans In my opinion printing pdfs usually always mangles the graphics. $\endgroup$ – M.R. Jun 16 '15 at 15:50
  • 7
    $\begingroup$ @N.J.Evans Mathematica could be so awesome if Wolfram offered more export flexibility. My "exporting wishlist": fully textured 3d graphics, (multi)Markdown!, latex (right now mostly broken for complex Box constructs), Dynamics to html5 widgets (wolfram cloud does not truly support Dynamic[] as everything is computed server-side causing horrible lag). $\endgroup$ – M.R. Jun 16 '15 at 17:29
  • 6
    $\begingroup$ For the record, I do not agree that the question was too broad. "Are there any areas where Mathematica is still vastly superior to the Python stack other than in computer algebra?" seems like quite a narrow question to me, actually. Perhaps it was the title that caused people to vote this way. If anyone else casts a reopen vote, I will add mine. $\endgroup$ – Oleksandr R. Jun 16 '15 at 23:35
  • 3
    $\begingroup$ Maybe this is a stupid question and until now, I had very little contact with python but which package of python lets you do analytical stuff like Integrate[Sqrt[x + Sqrt[x]], x]? $\endgroup$ – halirutan Jun 17 '15 at 12:25
28
$\begingroup$

You're asking for the biggest distinguishing feature of Mathematica - other than computer algebra. To give a really general answer, I would list as my number one choice the availability of curated knowledge, including free-form input. Other languages also have some limited ability to do this, but I think Mathematica has a head start and is moreover benefiting from simultaneous ongoing developments in Wolfram Alpha.

Given the nature of the question, I think it's pointless to start listing all the incarnation of curated knowledge. But as examples, version 10 offers things like DNA sequences, the current position of satellites, financial data with an elaborate array of visualization functions (often more polished than the "hard science" counterparts), "social" network data, etc. Being able to connect all this with the more traditional strengths of Mathematica, which clearly are in computer algebra, is in itself a strength. Of course, this also includes the availability of more traditional data from many fields of mathematics.

So to conclude, Mathematica seems to be ahead in the field of computable data.

$\endgroup$
19
$\begingroup$

General remarks

Before giving several (biased) answers to the question

As a developer I'd like to ask if there any other significant advantages to Mathematica - are there any areas where Mathematica is still vastly superior to the Python stack other than in computer algebra?

I would like to mention my Python background.

  • 17 years ago I programmed in Python a little, now I do not. But many of the people I work with do. I often support them with analysis, interfaces, and algorithms written in R and Mathematica.

  • I am fairly biased toward Mathematica. In principle, I like Python for its language design consistency, but I would rather program in R (which has all the characteristics of a design by a committee) than in Python.

Functional programming (Mathematica is better)

From what I have read about Functional Programming (FP) in Python the OP statement

Python already has much of the same functional constructs

should be interpreted as "Python provides functional programming lite support."

What Python's author is saying

In this post, “The fate of reduce() in Python 3000” Guido van Rossum discusses his difficulties understanding code that has reduce (Fold) and how he generally finds functional programming redundant within Python.

This, I would say, means that if you decide to use functional programming in Python you are not going to be supported by the language design much. (And probably you are going against Python's design fundamentals.)

What others are saying

Here is a very relevant quote from a recent interview with Larry Wall (the creator of Perl):

Some Pythonistas claim that Python is a good functional programming language, mostly on the strength of list comprehensions, but in my estimation Python has only half-hearted FP support; it really doesn't provide the benefits of lexical scoping, closures, laziness, or higher-order programming that I'd expect in a strong FP contender, nor does it encourage you to think that way.

(See "The Slashdot Interview With Larry Wall".)

And a more general programming statement from the same interview:

If Python's object model matches how you want to do things, it's fine for that. If it's not, Python doesn't really provide a coherent meta-object model underneath, just a lot of hooks, which might or might not give you the flexibility you need.

Here is a somewhat old (2009) discussion on Stack Overflow: "Why isn't Python very good for functional programming?"; but also see this newer (2012) presentation "Functional Programming with Python".

Pattern matching

From what I read Python does not have pattern matching of function signatures as Mathematica does. Of course Python has method / signature overloading capabilities, but that is not as powerful.

Numerical computations (Mathematica is better)

Sparse arrays

Python's scipy has support of sparse matrices, but not higher dimension sparse arrays. (Probably not very important numerics-wise, but really usefull sometimes in programming.)

Numerical integration

I consider Mathematica's NIntegrate to be much better than the integration algorithms in scipy. The algorithms in scipy do not have proper multi-dimensional integration rules and strategies.

See this related discussion: "Numerical integration — Mathematica vs Python (w/ Scipy) performance".

Numerical solutions of ODEs and PDEs

From what I see in scipy page ODEs and PDEs solving in Mathematica is much more sophisticated. NDSolve is more powerful, and provides a plug-in framework. The ODE algorithms in scipy seem to be based on old ODE software designs. For example, the methodology of feedback control theory applications to ODEs is a fundamental part of NDSolve's OOP design.

Special functions

Mathematica has extensive coverage of special functions. I really doubt that Python has such an extensive coverage too. Again, I have only looked at scipy. (An impressive list, by the way.)

Numerics with little symbolics

Often enough some algorithms are really hard without symbolics, and the symbolical part of these algorithms is really small. How easy it is with Python to program

-- this noisy time series peak detection algorithm, and

-- this integer optimization problem?

$\endgroup$
  • 2
    $\begingroup$ "I would rather program in R (which has all the characteristics of a design by a committee) than in Python." - ouch. :D $\endgroup$ – J. M. will be back soon Jul 19 '16 at 16:06
  • $\begingroup$ @J.M. :) I think, this is mostly saying things about me, than Python. After I read the linked interview with Larry Wall, I start to think that I do not like to program in Python for the same reasons I like its design -- Python is too monocultural. $\endgroup$ – Anton Antonov Jul 19 '16 at 16:10
  • 1
    $\begingroup$ @Jens, yes, which is why I think the Mathieu example is prolly more demonstrative. Not knowing how exactly is Mathematica evaluating those functions certainly does not help in working around those weaknesses. $\endgroup$ – J. M. will be back soon Jul 19 '16 at 16:57
  • 2
    $\begingroup$ @AntonAntonov Fair point, but the functions we're discussing are very important examples! Anyway, this is probably not the right place to vent such grievances. Although - where is the right place, I wonder. $\endgroup$ – Jens Jul 19 '16 at 17:04
  • 1
    $\begingroup$ Anton, @Jens' point, if I read him correctly, was that the "large coverage" is certainly a symbolic boon, but it is admittedly a bit spotty in the numerics front. Arbitrary precision sometimes helps, but not always. $\endgroup$ – J. M. will be back soon Jul 19 '16 at 17:05
8
$\begingroup$

Do not underestimate Mathematica's notebook. The fact that your code looks like math (you can make it be in fractions with the exponents up, etc.) can make it much easier to work with. This, and the fact that its FullSimplify and GroebnerBasis algorithms tend to perform pretty well for being such a generic package, make it still a staple in symbolic computing.

$\endgroup$
  • 1
    $\begingroup$ True (+1) but OP wants computer algebra to be excluded from the comparison... $\endgroup$ – Anton Antonov Dec 1 '16 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.