64

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?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
M.R.
  • 31,425
  • 8
  • 90
  • 281
  • 14
    I would hardly call that Maple comparison "insightful"!!! See (60124) – dr.blochwave Jun 16 '15 at 15:21
  • Since when does pdf printing not work? – N.J.Evans Jun 16 '15 at 15:30
  • 3
    @N.J.Evans In my opinion printing pdfs usually always mangles the graphics. – M.R. Jun 16 '15 at 15:50
  • 1
    @N.J.Evans Although printing can be made to work OK, it doesn't really work. E.g., hyperlinks aren't included in the generated PDF. So the question does have a point - however, I think it's too broad for me to be able to formulate a useful answer... by restricting it to other than computer algebra, the possible answers become rather subjective. – Jens Jun 16 '15 at 17:14
  • I guess I've never fully explored pdf printing, my documents usually come out looking pretty good with slightly fewer workarounds as I'd have to apply in any other environment I've ever used. – N.J.Evans Jun 16 '15 at 17:19
  • 7
    @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). – M.R. Jun 16 '15 at 17:29
  • 7
    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. – Oleksandr R. Jun 16 '15 at 23:35
  • Kind of a this vs that comparison, IMO... – ciao Jun 17 '15 at 00:23
  • 4
    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]? – halirutan Jun 17 '15 at 12:25
  • 2
    @halirutan sympy – rm -rf Jun 17 '15 at 14:59
  • 2
    @halirutan While your question is a good one to ask, note that the original question as asked in the next to last paragraph specifies "other than in computer algebra". Probably, the OP is aware of sympy which is, frankly, vastly inferior to Mathematica. Sympy fails on your suggested integral, for example. – Mark McClure Jun 17 '15 at 15:43
  • @halirutan, Mark McClure, SAGE can do that integral. I confirm that sympy fails on it. – den.run.ai Jul 23 '15 at 17:33
  • 2
    I do not really look for performance issues but rather consider Mathematica a luxurious Veblen good ready made for 'conspicious consumption'. After all you get to be seen using expensive proprietary software (and wearing/using Wolfram merchandise) - after all who wants to use the tools of the 99%? ;-)) – gwr Dec 13 '15 at 17:50

3 Answers3

42

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.

Jens
  • 97,245
  • 7
  • 213
  • 499
32

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?

Anton Antonov
  • 37,787
  • 3
  • 100
  • 178
  • 5
    "I would rather program in R (which has all the characteristics of a design by a committee) than in Python." - ouch. :D – J. M.'s missing motivation Jul 19 '16 at 16:06
  • @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. – Anton Antonov Jul 19 '16 at 16:10
  • Regarding numerical special functions, there are also severe shortcomings in Mathematica, see e.g. How to improve performance of BesselJ to the level of GSL? So if someone really needs that area to be reliable and fast, I wouldn't necessarily recommend Mathematica at this point. – Jens Jul 19 '16 at 16:46
  • @Jens, I'd say that's what you get when you aim for generality; note that the solutions in that thread (yes, including mine) are only good for a specific range of values. More troubling would be this Mathieu example. – J. M.'s missing motivation Jul 19 '16 at 16:49
  • @J.M. Yes, but the question asks for "vastly superior" areas... not including computer algebra. – Jens Jul 19 '16 at 16:51
  • 1
    @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. – J. M.'s missing motivation Jul 19 '16 at 16:57
  • @Jens I think the large coverage of ~300K special functions formulas is on the "vastly superior" side, and you and J.M. are discussing a deep issue for one of the functions... :) – Anton Antonov Jul 19 '16 at 17:03
  • 2
    @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. – Jens Jul 19 '16 at 17:04
  • 1
    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. – J. M.'s missing motivation Jul 19 '16 at 17:05
  • Isn't Mathematica's design even more monocultural than Python's? – Drux Dec 15 '17 at 16:39
  • @Drux "Isn't Mathematica's design even more monocultural than Python's?" -- No, it is not. Your comment makes me think that: 1) you are just trying to provoke a reaction, and/or 2) you really do not know much about Mathematica and programming languages in general. – Anton Antonov Dec 16 '18 at 14:49
  • @AntonAntonov So who else but Wolfram contributes significant innovations around Mathematica? – Drux Dec 17 '18 at 18:47
  • @Drux Right, you are trying to provoke a reaction... Good luck! – Anton Antonov Dec 18 '18 at 13:40
  • 1
    I challenge whoever downvoted to explain the reasons for the downvote. :) – Anton Antonov Jul 14 '21 at 07:38
16

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.