25
$\begingroup$

During a typical (possibly with alcohol mixed) discussion among some academic peers in regards to numeric calculation and general modern use of computers in science and engineering settings, it become a heated argument (as it has in many instances in the past) into the comparisons of MATLAB and Mathematica, namely what appears to me, to be a misunderstanding as to what Mathematica really is...or what it really can do.

Typically, most people seem to understand Mathematica as a purely symbolic solver, and MATLAB a numeric one, both very strong in their respective fields, but if one wants to do "real" research, Mathematica isn't the software to use. As a couple year user of Mathematica, I find this a huge misunderstanding in Mathematica's breadth of capabilities.

However, I must also admit before I started actually using the software, I've also only really understood it as a symbolic notebook styled software that I knew some people used to do homework with. I am also not old enough to know how Mathematica used to be compared to other software in the same period to know if it wasn't as "good" as it is now.

I've read other mentions in comments around the Stack Exchange sites that Mathematica treats everything as an expression and MATLAB everything a matrix, and both are heavily optimised for this. However, I still don't quite understand the inherent philosophy between the software and Mathematica's exact numeric solving strengths to be able to discuss with MATLAB or Maple users on how Mathematica is just as good as them in its abilities.

Without getting into fanboy arguments of which software is better, what is Mathematica's specific strengths compared to other software, under a 'philosophy of design' standpoint? Is this solely a marketing problem?

Or maybe more specific: What can one say to peers (and potential new users) to try and reduce the misconception that Mathematica is solely a symbolic homework solver?

$\endgroup$
  • 8
    $\begingroup$ "Without getting into fanboy arguments of which software is better." -- :) When I see or hear statements like this I simply do not believe them. People are very defensive and reactive to criticisms of their (favorite) software languages, platforms, or workflows. At this point in presentations I discuss reasons why not to use a wide list of languages, platforms, etc. $\endgroup$ – Anton Antonov Jul 18 at 15:51
  • 2
    $\begingroup$ I rarely touch Matlab these days, but in my experience Mathematica is extremely versatile and great for doing "scratch work". Perhaps the one aspect of MMA that I find most useful is creating 3D graphics for visualization, which I do not know of any other software that allows me to play around so easily with visualizations the way I can in MMA. In the end I will say that it is often difficult without considerable effort/expertise/hours on SE to maximize efficiency of MMA code, so for anything "heavy duty" I default back to Fortran (har har), but then I do all my plotting in MMA $\endgroup$ – Kai Jul 18 at 21:51
  • 4
    $\begingroup$ Mathematica is definitely more fun to use :-) Having fun, and getting work done, are not the same thing though. MATLAB always felt kinda dry to me. It doesn't make me want to go and explore. $\endgroup$ – Szabolcs Jul 19 at 14:55
  • 2
    $\begingroup$ Personally I prefer a sliderule. $\endgroup$ – copper.hat Jul 19 at 22:03
  • 2
    $\begingroup$ I still have a lingering distaste for mathematica, but it's largely based on the fact that MATLAB was the first language I was taught in undergrad and their syntaxes are so different. This is probably also the case for a lot of science types, rather than really being based on the actual abilities of the languages $\endgroup$ – llama Jul 20 at 19:07
8
$\begingroup$

I have abused Mathematica since version 3 and right out of the gate I will say that the Notebook interface remains unparalleled compared to other platforms: MATHLAB, Python, R, Stata (of which I have working experience). Although Livescripts have been a welcome addition to MATLAB, I still prefer Mathematica as a comfortable graphical interactive workspace. I have only used MATLAB for the past 3 years, so my experience is limited. I find working with matrices cleaner in MATLAB and the documentation/implementation of higher-level matrix functions more informative (and easier to relate to textbook instruction of Linear Algebra). (I have, respectively, a love-hate relationship with MATLAB and Mathematica when it comes to pre-multiplying a matrix by a column vector.)

In data analysis: I like Mathematica’s handling of statistical distributions, but I find its statistical modelling limited and awkward to extend beyond Master’s level applied statistics. MATLAB is has a much richer implementation and output. Mathematica’s Bayesian capabilities (including various MCMC offerings) are no where to be found. (I recognize this last statement is not literally true; but it may as well be because efforts to create Bayesian models for undergraduate-level applications requires considerable competence (as indicated by the coding examples offered by Community contributions). MATLAB has more extensive statistical modelling offerings but likewise gets complicated, but possible, to use for Bayesian stats. I find Mathematica’s handling of temporal data (and date/time functions) and time series analysis superior to MATLAB. And when it comes to data munging, I also prefer Mathematica (due largely to the ease of intermediate display of data in the Notebook). I do not have experience in MATLAB with stochastic processes; but the Mathematica implementation is very impressive and enjoyable to use.

I prefer to work with text data and strings in Mathematica and my limited experience with MATLAB suggests that Mathematic’s string manipulation capability is superior.

Neural networks: At the moment, my knowledge of the Machine Learning implementations in both environments is limited; but I prefer MATLAB and my early experience suggests autodidactic ingestion of Deep Learning and Neural Nets is more approachable and rewarding in MATLAB. The Deep Network Designer in MATLAB is a superior environment for building and experimenting with NN. I have no direct comparison, but I find MATLAB faster, especially with the Parallel Computing Toolbox.

I find MATLAB’s Regression and Classification Learner “apps” superior and much faster (especially Gaussian Process modelling) to Mathematica’s Predict and Classify. However, if I supplement the latter with the Find… family of commands; I think I would lean to Mathematica. The issue here is more my knowledge as a User (ease of use and immediate functionality often become less attractive as the user’s capability and the problems’ complexity increases; and I am at the lower end of the scale on both of these considerations).

I have not used MATLAB long enough to have an opinion on its evolution. But Mathematica has gone through significant changes. I had the impression that Stephen Wolfram took his eyes off the ball between, say v8 and v10, but has returned to press for a strategic and consistent language-level implementation. The vision of this endeavor is breath-taking. For example, the Entity Framework design is awesome, if awkward. And more generally, I find the improvements are impressive but sometimes difficult to grok and work with without a lot of fine tuning. As well, it seems some of the implementations run out of gas before they get to a full maturity (where they are worth the time and effort to learn in detail and by rote). I would suggest Wolfram’s database access and instantiation in Mathematica’s knowledge representation and access framework as an example of the latter. In my experience Mathematica’s database access is superior to MATHLAB. The impressive RelationalDatabase, EntityStore, EntityValue, EntityClass, and family of …EntityClass commands are so full of promise. But, for me, they wander into a jungle of syntax that is so difficult to get right that I fall back to what I did five versions ago with SQLExecute. (My bad, I just found the “Relational Databases Quick Start “ Technote which is “New in 12.0”. But I think this underlines my point. I had given up trying to master the Entity Framework and SQL because the implementation and documentation were incomplete in V11. And, I will get back to you when I finish what looks like the longest Technote in Mathematica. But I will not mind if the implementation does meet the promise and my expectation). (By the way, I feel this is similar to @Szabolcs point: “too many operators and the need to remember their precedence never bothered me, but I agree that one must have discipline and exercise self-restraint when using operator forms. I think I use them less, and them more and more restrictively, as time passes, not more.”

I will not address the Symbolic capability here. I have made primitive use of MATLAB’s Symbolic Math and Partial Differential Equation Toolbox but I would NOT give them a moment’s thought if I wanted to produce something akin to Nachbar’s “Epidemiological Models for Influenza and COVID-19” Notebook (https://www.wolframcloud.com/obj/rnachbar/Published/Epidemiological%20Models%20for%20Influenza%20and%20COVID-19--full%20version.nb).

Both platforms are now so rich, extensive, and complicated that they require a support Community and third-party publications. In terms of texts: I find MATLAB has out paced Mathematica and that it is easier to find reference works for MATLAB. As to community support, I find Mathematica Stack Exchange particularly good. But, in my experience MATLAB’s Community support and offerings is more active and richer than Mathematica’s.

As to the Philosophy, I think, with Stephen Wolfram actively at the head and pushing his Company towards a strategic goal with adequate and consistent documentation, Mathematica holds a clear edge in vision and thematic endeavor. And it does feel like a Computational Engine with scary, almost unmanageable power. Something well-placed in a Consulting firm versus a manufacturing plant. MATLAB, on the other hand feels like a comfortable enterprise engineering application platform, squarer and more manageable.

I work with Mathematica everyday (as a hobbyist) but I enjoy some autodidactic exploration with MATLAB. I would accept either as my working environment in whatever Company I worked for; but when I got home at night I would prefer a fight with Mathematica’s syntax (and the eventual reward) than a dry serving of MATLAB.

| improve this answer | |
$\endgroup$
35
$\begingroup$

Well, here's my reply to a similar question from a while back:

I'm looking for comprehensive and rather long answers to these questions.

  1. What's the difference between Mathematica and MATLAB?

Several letters in the names.

  1. Can MATLAB do what Mathematica does and vise versa?

Yes. Both are Turing complete. Good luck writing heavy symbolic work in MATLAB though.

  1. What are the pros and cons of each of them?

Many pros here at this site, a few users have done prison time. No idea re: Matlab expertise or criminality.

  1. Who are the appropriate users of each tool?

Ones that make up their own mind based on experience with the two vs taking polls.

  1. Will it benefit someone if he knows both of them?

Sure, they can answer comparison questions.

  1. What are the capabilities of Mathematica that makes it unique?

Stephen Wolfram. 'nuf said. And if you disagree, he'll send a pack of wild cellular automata your way to... "evolve" your opinion.

  1. Can Mathematica play the role of an easy to use advanced scientific calculator for an engineer who is most of the time dealing with multi-variable calculus and partial differential (electromagnetism) equations?

Yes.

In all seriousness, I use (daily) Mathematica and MATLAB, and weekly Maple, NumPy, SageMath, and PARI/GP.

They are all capable of doing what the others do, with varying degrees of effort and/or self-flagellation depending on the task at hand.

I think a large part of the tribalism re: Mathematica/MATLAB is simply a case of knowledge passing - the engineering professor was taught and used MATLAB, so torpedoes be damned, that's what they'll mandate. It kind of makes sense - the tool does what they need, and there isn't any need to fix it if it's not broken.

For much of what I do, the symbolic capabilities of Mathematica along with its comprehensive probability capabilities make my tasks much, much easier than trying to do the same in the other tools.

If I were forced to pick one and only one of my tools in the mathematical toolbox, it would be Mathematica, simply because I can do in it anything my other tools can do, and I can easily do in it things the other tools are either intrinsically incapable of doing and/or require me to write my own symbolic CAS.

On my deserted island, Mathematica is my Wilson...

Enter image description here

| improve this answer | |
$\endgroup$
  • 8
    $\begingroup$ Stephen Wolfram. 'nuf said. And if you disagree, he'll send a pack of wild cellular automata your way to... "evolve" your opinion - Funniest stuff I've heard today $\endgroup$ – Ferca Jul 19 at 14:08
  • 1
    $\begingroup$ How did you end up on / with a deserted island? Using Mathematica or MATLAB? Or some strange Sage-Py-PARI combination? $\endgroup$ – Anton Antonov Jul 20 at 11:50
  • $\begingroup$ @ciao many excellent codes have been written in Matlab/Octave (like "GeoPdes"), how can we use these codes in Mathematica easily? $\endgroup$ – ABCDEMMM Jul 20 at 18:35
  • $\begingroup$ @ABCDEMMM MATlink exists, and you can use python externally evaluate octave script in Mathematica. $\endgroup$ – CA Trevillian Jul 21 at 17:10
  • $\begingroup$ @CATrevillian first thanks, sure we can use MATlink, but if the basic codes are written in Python, e.g. TensorFlow, then must we turn to use Mathematica with TensorFlow? It sounds complex, or? $\endgroup$ – ABCDEMMM Jul 21 at 17:37
15
$\begingroup$

I have just purchased both for personal use and am getting used to both. Before that I had various experience in other paradigms, including Lisp, Prolog, Algol-like languages, a bit of Fortran, C, etc. I like the two M's for their built-in graphics.

MATLAB

For me, I would say that, once you get used to MATLAB's syntax, everything is pretty straightforward.

Mathematica

Because Mathematica is a pattern-substitution language (and therefore unusual), it is very easy to lose track of what is happening behind the scenes. The order of evaluation is critical and can trip you up. I haven't yet discovered a definitive list of operators and their precedence - yet knowing the precedence is vital. There are lots of operators that can be written in different forms (prefix, postfix, and infix) with different symbols and they aren't well-documented unless you already know what to look for.

Because of the way Mathematica works, local variables have to be thought about very carefully and there are special structures for the purpose. By default all variables are global.

If you are someone who wants to know the nuts and bolts of a language, there is a sea-bed below which you can't penetrate in the documentation unless you know the right people.

You can use Mathematica to simulate pretty much any other paradigm without a great deal of work but then, why not use a purpose-built language?

For example, it is possible to program it in a procedural way, but watch out for scope of variables (and whether or not they remain as symbols for much of the process or are evaluated early). Sometimes you just can't stop early evaluation despite functions that supposedly do so.


Conclusion

Despite all this (and more) I like Mathematica (and its absolutely amazing knowledge base) and it is consistent most of the time. However if you just have a programming job to do and MATLAB fits, then I would get MATLAB and get to work.

There is also a matter of speed of execution. I haven't done any measurements because {reasons}, but Mathematica can be pretty slow (and inconsistently so) unless the functions you are using are built-in and have been optimised.

I could go on, but I've only had them a short while so I'm in no way an expert.

| improve this answer | |
$\endgroup$
  • 3
    $\begingroup$ It's always interesting to hear an experienced newcomer's perspective. Thanks for sharing! Personally, too many operators and the need to remember their precedence never bothered me, but I agree that one must have discipline and exercise self-restraint when using operator forms. I think I use them less, and them more and more restrictively, as time passes, not more. $\endgroup$ – Szabolcs Jul 19 at 14:53
  • 5
    $\begingroup$ "Mathematica is a pattern-substitution language Stack Overflow it is very easy to lose track of what is happening behind the scenes." I disagree strongly. I think Mathematica has one of the simplest execution models of any language. Every expression is uniformly a Head wrapped around a collection of subexpressions. Whenever an expression matches an entry i DownValues, the result is substituted for that expression. You can control this substitution by Holding the expression or keeping it Unevaluated. I find that very easy to visualise. Try explaining MATLAB's execution model in such terms. $\endgroup$ – Shredderroy Jul 19 at 18:39
  • 3
    $\begingroup$ “Mathematica can be pretty slow” – yeah and Matlab is always blazingly fast, especially when using hand-written nested loops. Wait... $\endgroup$ – leftaroundabout Jul 20 at 16:34
  • 2
    $\begingroup$ @Shredderroy One of the simplest execution models, are you kidding? I absolutely love the "everything is an expression" foundation as it makes so many things possible more easily, but having read once upon a time ago the 13 or so steps of evaluation, I can think of very few languages that are so complicated. Something like C++ may come close simply because it's so easy to hide unexpectedly complex behaviors behind an operator. $\endgroup$ – Michael Jul 20 at 21:34
  • 2
    $\begingroup$ @Shredderroy Agreed about the evaluation model. Mathematica definitely has some peculiarities that destroy the overall simple idea, but for the most part you don't need to worry too much about those. MATLAB, on the other hand, never seems to do what I expect it to do the moment I do anything other than absolute boilerplate code and I can never figure out why. In MATLAB I always just flail about till it magically works. Mathematica's drawback is mostly that it's kind-of like Lisp, which is a language hardly anyone knows. $\endgroup$ – Sjoerd Smit Jul 21 at 12:39
14
$\begingroup$

I believe the main difference between Mathematica and MATLAB is that

  • Mathematica is a (mostly rule-based) term rewriting language born for symbolic analysis that has developed a very extensive set of specific procedures, even in its core functionalities.

  • MATLAB is a procedural language with a very limited (this is an advantage) set of core commands and was born for numerical analysis.

You can have one do what the other does, but you might have to jump through hoops to do it as efficiently as the competitor when it comes to their relative strengths. So, symbolic manipulation can become cumbersome in MATLAB, while numerical resolution of PDEs might be slower and much more memory consuming in Mathematica.

EDIT to elaborate on the difference:
Mathematica's term rewriting is extremely powerful but it's more recursive than procedural and as such tends to use up a lot of memory to be carried out. MATLAB's procedural style is more straightforward and works by updating preinitialized array structures.
In a way it's like Mathematica does all its calculations in its head and spits out the result in the end, while MATLAB does its calculations step by step with pencil and eraser on a piece of paper, updating partial results on the go.

Moreover, the limited core set of MATLAB's commands allows (the procedural) programs to be scrutinized with only a basic knowledge of a handful of statements and also makes them easily translatable in other procedural languages.
Mathematica, on the other hand, tends to hide the implementation details under the hood, in a flurry of specific procedures and methods (selectable by options) that can change from one version to the other. The magic Mathematica performs is not so easily translatable in other languages. This is both an advantage (you can do stuff in five minutes that other languages would require days of coding) and a disadvantage (if you are reading or peer-reviewing a paper with procedures written in Mathematica - even more so if you have an older version or no version at all).

[Unsolicited opinion] I believe both programs have evolved so much that they are now the scientific equivalent of an Hollywoodian reboot where special effects are free.

| improve this answer | |
$\endgroup$
9
$\begingroup$

I'm an experimental physicist. I use Mathematica occasionally and used to use MATLAB. I've since mostly replaced MATLAB by Python but can still speak to Mathematica and MATLAB.

I use Mathematica for symbolic analytic calculations. If I know the equations that setup my problem and I want to come up with an analytical answer (so that I can immediately see the affect of various input parameter values on the output) but I either can't do it myself by hand, it would be cumbersome to do it by hand, or I just want the process streamlined and I want to visualize the results then Mathematica is great for this. Mathematica also has some really great built in visualization. Of any software I've used I've found Mathematica to be the easiest for making 3D plots and easily manipulating those 3D plots. Finally, the manipulate functionality in Mathematica is awesome and really smooth so if I want to play around with a range of parameters I will always turn to Mathematica manipulate. Admittedly I've never spent a lot of time exploring this functionality in other languages so I can't make a complete comparison, but my guess is that it's easier in Mathematica.

MATLAB. First off, I would say I do think of MATLAB as being more of a "real scripting/coding language" as compared to Mathematica. It has familiar control structures and program flow. It has predictable and understandable program flow and variable scope. It's straightforward to define complex functions with conditional flow structure etc. You can also use MATLAB for instrument control, for example. However, restricting to using Mathematica vs. MATLAB for purely mathematical tasks. If I have a task which I consider to be a numerical calculation I will spring for MATLAB right away. My usual flow for such a problem is: create a big old list of input values to some simulation block. Run that simulation block on all of those input values. Visualize the results. MATLAB does this really nicely with matrices etc. It also does it very quickly and is designed exactly for this type of calculation. Mathematica's lists while brutally "formal/rule following" are just pretty ugly to look at and manipulate (even at a notational level). Yes, you can make lists and pass them through functions appropriately but it just feels like that isn't what Mathematica was designed for. On top of that, I've found Mathematica to be slower when I operate it in this mode.

So in short: Mathematica is good for getting analytic results and certain visualization tasks. MATLAB is better for `general (not necessarily mathematical) purpose programming' and numerical calculations.

All of that said, in recent years I've tried to move away from MATLAB towards Python. In the context of this discussion Python fills the same roles as MATLAB but feels even more developed/targeted to be what I'm calling a `general purpose programming language' while still having the ease of use for numerical simulation as MATLAB. I've heard that MATLAB may outperform Python in terms of speed on some tasks but fortunately I'm not typically working on the types of computational tasks where that would matter so I haven't run up against this yet.

| improve this answer | |
$\endgroup$
4
$\begingroup$

To add to this discussion, I picked up Python in Visual Studio/Jupyter Lab for the note book feature a few years back. I have never used Matlab but my students have. I personally Mathematica to be absolutely unequaled for prototyping mathematical models. It provides so much to work out why things work and don't. For any kind of serious application work, I go to Python with its massive libraries. My only complaint about Mathematica is that its debugging is rather limited and often inscrutable. I often work with tensors and Mathematica's treatment of these is phenomenal.

| improve this answer | |
$\endgroup$

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