Re: Mathematica Vs. Matlab

From: Bill Rowe (readnewscix_at_earthlink.net.invalid)
Date: 08/19/04


Date: Thu, 19 Aug 2004 05:21:01 GMT

In article <cfvmpd$u$1@fred.mathworks.com>,
 "Steven Lord" <slord@mathworks.com> wrote:

> Now rather than having an emotional and subjective discussion about the two
> products (see my previous comment about a religious war) let's take a look
> at a benchmark that I believe is fairly well-known and impartial:

> http://www.scientificweb.com/ncrunch/

> This is Stefan Steinhaus's report comparing Mathematica, MATLAB, and a
> number of other software packages. Now since there have been changes to
> both Mathematica and MATLAB in the two years since the report was last
> compiled, it's probably about time for it to be rerun

Definitely since it appears the last report (vers 4.41) was done for
version 4.2 of Mathematica and the current version is 5.0

> -- but as of the last time it ran MATLAB scored higher than
> Mathematica in every category except platform support, where they
> were tied with 100% each.

While this does appear to be true, it really isn't as significant as it
might seem. For example, consider the loop test benchmark shown in
section 7 of the report. Here Matlab out performs Mathematica with a
score showing Matlab to be ~300 times faster than Mathematica.

Looking at the Mathematica code I see the loop implemented is a Do loop
using an iterator in the form {n,1, nmax,1}

Now consider the following results I just got using Mathematica

n = 1000000;
data = Table[Random[Real], {n}];

a = 0; Timing[Do[a += data[[i]], {i, 1, n, 1}]]
{12.54*Second, Null}

Ia = 0; Timing[Do[a += data[[i]], {i, n}]]
11.967*Second, Null}I

a = 0; Timing[Do[a = a + data[[i]], {i, n}]]
{9.27*Second, Null}I

All three of the above loops are exactly equivalent in terms of what
they do. But by simply specifying the iterator differently or using
different syntax, there is a definite difference in performance but not
enough to show Mathematica does better than Matlab.

But now consider replacing the Do loop with Mathematica's functional
equivalent

Timing[Plus @@ data]
{1.39*Second, 499736.342054831}

An order of magnitude improvement in performance. And using built-in
specialized functions

Timing[Tr[data]]
{0.03*Second, 499736.342054831}I

Timing[Total[data]]
{0.02*Second, 499736.342054831}

Two orders of magnitude improvement over the functional equivalent.

Now, it really isn't fair to compare a specialized function in one
software package for with a general loop in another. So, the fact I can
get such a significant improvement doesn't mean Mathematica is faster
than Matlab.

But it also isn't useful argue Matlab is significantly faster than
Mathematica for Do loops even though true when there are much faster
ways to achieve the same result in Mathematica. In general loops of this
nature are the slowest way to do something in Mathematica.

Note, I am not arguing the comparison done isn't impartial or
construction with an intent to deceive. It is extremely difficult to
develop meaningful benchmarks for significantly different software
packages despite the fact there is overlap in some of the functionality
of the packages.

For a specific application when the benchmark tests that specific
application, then the benchmark *might* serve as a useful criteria to
choose one package over the other. But in general such benchmarks do not
offer a good basis for choosing one package over another.

> Now are there some problems that Mathematica can handle that MATLAB cannot?
> I don't know. I will admit that I haven't used Mathematica that much. It
> may be that you can find a problem that MATLAB can't handle _easily_ (never
> underestimate the coding ingenuity of some of our long-time users :) but
> there are just as many problems that I would bet Mathematica can't handle
> easily that MATLAB breezes through -- signal processing, filter design, and
> control design being some that in my mind are more oriented to numerical
> calculations rather than symbolic.

I've used Mathematica for sometime but have essentially no experience
with Matlab. So while I've no way to check the specific tasks you
mention, I am quite certain there are tasks for which Matlab is more
suitable and there are tasks for which Mathematica is more suitable.

I think Richard Fateman offered some of the best advice in this thread.
It is quite difficult to arrive at a meaningful comparison of
Mathematica and Matlab independent of knowledge of the intended
application. While there is some overlap in functionality, these
packages are not truly equivalent. Probably the most important criteria
for choosing a CAS package is what your instructors, peers etc are
using. For it is these people who you will be seeking help from first.

-- 
To reply via email subtract one hundred nine


Relevant Pages

  • Re: Mathematica Vs. Matlab
    ... The general DO loop in Macsyma is designed to handle cases where the loop ... Do either Matlab or ... >> number of other software packages. ... >> both Mathematica and MATLAB in the two years since the report was last ...
    (sci.math.symbolic)
  • Re: mathematica and matlab
    ... MATLAB is more focused around matrix manipulation in a numeric sense - ... MATHEMATICA is more focused around the symbolic calculations (as is ... packages' web site and see if you like the command syntax, ...
    (sci.math)
  • Re: What is the point of octave? (And its presumed buddy, MatLab)
    ... Mathematica extensively in the past. ... Matlab is solving this in the interpreted language, ... not the fact that those packages are inter- preters. ... being an object-oriented language permits you to define such entities. ...
    (sci.math.symbolic)
  • Generating a huge array.
    ... Then perhaps loop through and remove all instances where w1,w2,w3,w4 don't sum to 1. ... I was considering finding a way to export the array from Mathematica and import it into MatLab, but there must be some way of doing this in MatLab, besides writing heaps of For statements and similar. ... I know I can generate the efficient frontier, and have looked through the portfolio library and can't seem to find anything which will help. ...
    (comp.soft-sys.matlab)
  • Mathematica Symbolic Toolbox for MATLAB--Version 2.0
    ... The Mathematica Symbolic Toolbox for MATLAB ... He is responsible for leading the MathLink ... The Mathematica Symbolic Toolbox for MATLAB is ...
    (sci.math.symbolic)