Re: Mathematica Vs. Matlab
From: Leo Harten (leoharten_at_rcn.com)
Date: 08/19/04
- Previous message: Paul Abbott: "Re: Mathematica Vs. Matlab"
- In reply to: Bill Rowe: "Re: Mathematica Vs. Matlab"
- Next in thread: Richard Fateman: "Re: Mathematica Vs. Matlab"
- Reply: Richard Fateman: "Re: Mathematica Vs. Matlab"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 19 Aug 2004 03:23:45 -0400
The general DO loop in Macsyma is designed to handle cases where the loop
may
be exited on the basis of any type of comparison, integer or not, and hence
is
very slow since it must call an extremely general comparison routine. To
improve the
efficiency, one can declare the type of the variables in the scope of the
DO, and
then translate-to-lisp/compile the loop. If the tests are all made on
integer values,
then the loop is executed vastly more efficiently in the compiled version.
This notion
applies to numerical integration, plotting, and similar uses, where a
function returns
a numerical value.Being able to compile a function, and save that in a file,
made an
excellent utility for symbolic-numeric interface. I spent a lot of time in
DOE-Macsyma
and ParaMacs converting the share library functions to this higher standard
of
programming to enable the translation/compilation. Do either Matlab or
Mathematica
support true compilation, and saving the compiled function objects? If you
are
comparing "interpreted" expressions, does the interpreter byte-compile or
type-check
to improve performance?
"Bill Rowe" <readnewscix@earthlink.net.invalid> wrote in message
news:readnewscix-8069B2.22202818082004@news.west.earthlink.net...
> 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
- Previous message: Paul Abbott: "Re: Mathematica Vs. Matlab"
- In reply to: Bill Rowe: "Re: Mathematica Vs. Matlab"
- Next in thread: Richard Fateman: "Re: Mathematica Vs. Matlab"
- Reply: Richard Fateman: "Re: Mathematica Vs. Matlab"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|