Mathematica vs. Matlab

Can someone summarize the differences and similarities between Mathematica and Matlab?

Mathematica is a general-purpose symbolic/numeric mathematics package based on a mixed-paradigm language (e.g. procedural/functional/etc).

Matlab is more like a program development environment - using a BASIC-like procedural language - rooted in numerical data processing (though an add-on for symbolics is available) with many more add-ons for industry-specific work.

The simplest way to explain it is that Mathematica is good for analytic calculations, while Matlab is better for numerical calculations. Internally, Mathematica stores the information you give it as a symbolic expression, while Matlab stores it as a number. For example, in Mathematica, saying that y = Cos without declaring what x is first is OK, since Mathematica will just think of Cos as a function of the variable x. Matlab, on the other hand, will rear up & spit at you if you tried to say that y = Cos(x) without declaring what x is first. If you said that x = pi (say) before that statement, then Matlab would immediately assign the value y = 0.

In general, I find that Mathematica is useful for simplifying horrendously complicated algebraic expressions. However, if I don’t need an analytic expression, or my problem has to be solved numerically, Matlab is much faster (since it doesn’t have the “overhead” of remembering exactly what Cos(x) is and how to manipulate it.)

MikeS has hit the nail on the head.

Mathematica (similar to Maple) is a program for symbolic mathematics. You can enter mathematical statements and Mathematica understands (to a certain extent) what they mean and how to manipulate them (e.g. that cos(x)^2 + sin(x)^2 = 1 ). If you want to calculate the integral of say x^2 , the program actually calculates it as x^3/3.

Matlab on the other hand is purely numeric. If you calculate the above integral with Matlab, it doesn’t actually calculate the function, but it uses a numerical approximation to calculate the answer.

Additionally, Matlab is a powerful probramming language. It is not especially fast, but there is an abundance of preprogrammed functions which makes developing, for example of algorithm prototypes, very easy.

<hijack> Is there a Mathematica type programme (symbolic logic based) that can run well on a PDA? Would this be the ultimate pocket calculator?

In that particular example, Matlab probably doesn’t use an approximation. Or rather, it uses an approximation which happens to be exact. Most of the common numerical methods for integrals are exact for polynomials of low order, and I suspect that Matlab has some means of choosing a method which is best suited for the function it’s integrating.

As missing_link alluded to, if you’re looking for another program which fills the same purpose as Mathematica, Maple would be a much closer analogue than Matlab. I think that the two programs actually use the same underlying engine, differing primarily just in the interface. It’s worth noting, by the way, that both Mathematica and Maple can be used for numerical calculations; it’s just not the default behaviour, and must be asked for specifically.

Yep, Chronos is right, my example wasn’t the best choice. But the general idea holds.

As far as I know, there is an add-on for Matlab with which you can do symbolic calculations, the symbolics toolbox , but I have never used it, so I can’t tell if it is any good.

But even if you can do both (symbolic/numeric) with both programs, I definitely would stick to Matlab-numeric and Maple/Mathematica-symbolic as this is what they were primarily designed for.

With Matlab it is also possible to build GUIs and to translate Matlab code into C++. There are also a lot of other toolboxes for different applications (e.g. SIMULINK to model control systems and the neural networks toolbox to model neural networks)

Thanks to everyone for your insights. Just what I was after.