65
$\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$
13
  • 14
    $\begingroup$ I would hardly call that Maple comparison "insightful"!!! See (60124) $\endgroup$ Commented Jun 16, 2015 at 15:21
  • 3
    $\begingroup$ @N.J.Evans In my opinion printing pdfs usually always mangles the graphics. $\endgroup$
    – M.R.
    Commented Jun 16, 2015 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.
    Commented Jun 16, 2015 at 17:29
  • 7
    $\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$ Commented Jun 16, 2015 at 23:35
  • 4
    $\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
    Commented Jun 17, 2015 at 12:25

3 Answers 3

42
$\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$
32
$\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$
14
  • 5
    $\begingroup$ "I would rather program in R (which has all the characteristics of a design by a committee) than in Python." - ouch. :D $\endgroup$ Commented Jul 19, 2016 at 16:06
  • 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$ Commented Jul 19, 2016 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
    Commented Jul 19, 2016 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$ Commented Jul 19, 2016 at 17:05
  • 1
    $\begingroup$ I challenge whoever downvoted to explain the reasons for the downvote. :) $\endgroup$ Commented Jul 14, 2021 at 7:38
16
$\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
  • 3
    $\begingroup$ True (+1) but OP wants computer algebra to be excluded from the comparison... $\endgroup$ Commented Dec 1, 2016 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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