Mathematica vs Matlab vs Maple, discuss (Wilmott Forums)

In terms of capabilities, it seems Mathematica is the winner. But Matlab can be so more productive especially in numeric calculations, as it is build-in matrix. Mathematica can do numerical stuff too, just not as convenient to do so, as it's based on the concept of List. But theoretically, List is more general than Matrix.

Marry Mathematica, and keep Matlab as mistress.

http://www.wilmott.com/messageview.cfm?catid=19&threadid=41499&FTVAR_MSGDBTABLE=&STARTPAGE=1

Interesting post, information summarized:

1. Speed test between Mathematica and Matlab:

Alan
Senior Member

Posts: 4009
Joined: Dec 2001
Sun Aug 26, 07 04:38 PM


Can anyone match or beat either of these running times?
If so what's your setup? (Matlab/Mathematica Version #, CPU, Brand, Model, Op. Sys., Memory)


Matlab
---------------------------
M = rand(300,300);
t=0.25; T=2;
tic; inv(M) * (expm(-t*M) - expm(-T*M)); toc;
Elapsed time is 0.288171 seconds


Mathematica
---------------------------
M = Table[Random[], {i, 1, 300}, {j, 1, 300}];
t = 0.25; T= 2;
Timing[Inverse[M].(MatrixExp[-M t] - MatrixExp[-M T]);]
{0.375 Second, Null}




Edited: Sun Aug 26, 07 at 10:57 PM by Alan

-------------------------------------------------------
-------------------------------------------------------
2. An in-depth case for Mathematica's superior symbolic calculation over Matlab

haZim
Member

Posts: 61
Joined: Jan 2007
Fri Jun 22, 07 10:15 AM


I've been using MatLab in trying to compute a definite integral where the inegrand contained a gamma function of complex argument and a modified bessel function of the second kind where both the argument and the order are complex and where the integration is carried out with respect to the order of the bessel, the argument of the gamma function and some other weights. After running into problems due to the fact that MatLab did not handle the complex orders for the modified bessel I tried looking through Matlab exchange to see if anyone had implemented the code. Indeed, one guy claimed that he had done so. I downloaded the code which included calls to a C++ written .dll file. Again the function could deal with the complex order but now was not able to deal with a vector when calculating the integral (Matlab apparently calculates integrals by constructing vectors that it dots with a grid). I had to write a new piece of code using the Matlab exchange code. After leaving the damn thing run for the entire night I got a plot of my integral which contained patches as the code could not generate many pieces of the graphs (i.e. the way it calculated things was so imprecise that many zeros became NaNs). In any case....the graph was still ok as the integral I was computing had some symmetries which I could use to fill the missing patches and realize that some singularities I was afraid of did not exist. Finally i had to prove that the integral along with a sum added to one for some values of the parameters....the imprecision of the code was so much that I kept getting completely different and quite divergent numbers in place of 1!....finally I managed to get some help in Mathematica...the patches have disappeared, the integral sums to 1 and the plots take about 1 hour instead of 11 not to mention that a code which required a few hundred lines was all already implemented very well in Mathematica......I am not sure that MatLab is so bad when it comes to data otherwise people wouldnt be using it as much....but as far as numerical stuff and Maths...my experience was quite concluding.


Edited: Sun Jun 24, 07 at 11:41 AM by haZim
------------------------------------------------
------------------------------------------------
3. Big deal in Parallel computing: Mathematica wins again.

eredhuin
Senior Member

Posts: 260
Joined: Jul 2002
Tue Nov 20, 07 01:22 PM


With regard to Matlab's parallel toolkit; I've been using it in some form or another for over a decade. First at Cornell's Theory Center, where parallel matlab was first created as a neat hack on its SP2. Definitely interesting but not ready for prime time.

Much later, I started using the parallel matlab. Hey, parfor is a great idea. Think OpenMP and matlab parallelizing your loops. Easy. But not terribly stable. My impression on it is that it's not ready for prime time. Or Windows or Java or (...) isn't.

Parallelizing is a big deal. It's THE big deal going forward in a world of diminishing CPU speed gains.

Did you know that recent versions of Matlab 2007 support multithreaded computation. Look under general preferences. That's where you see the ominous warning under the [ ] Enable multithread
"Note: Upon encountering a fatal condition when multithread is enabled, MATLAB cannot attempt to return control to the Command Window and exits instead."

I'm not sure who's winning the parallel race but perhaps it's time I looked at Mathematica again.

Comments

  1. eredhuin
    Senior Member

    Posts: 260
    Joined: Jul 2002
    Wed Nov 21, 07 09:08 PM


    The original parallel Matlab was MultiMatlab at Cornell. It used .mexrs6k addins compiled with MPI to do the dirty work IIRC.

    Of course, the syntax for parallel matlab is really a wrapper for distributed (not shared) computing so there is data being flipped around and shared. It's really doing something like MPI, not OpenMP. On today's hardware you have the luxury of multiple cores so something like OpenMP can give you some very easy wins without the burden of nonlocal data.

    Nonlocal data is problem with MPI of course, since there are fewer easy wins. Because of communication requirements, the distributed code can easily be slower than the serial code. Also, once you move away from data locality, things get complicated to debug. I tuned my algorithm in terms of flop counts, O(n^3), and calculated an "Equivalent" flop effort for flipping one number across the network. Depending on if that number's 1000 or 1000000 you will have to tune your algorithm differently for optimal performance. It may even make sense to not communicate, rather, to redundantly compute some things locally.

    And of course, of course, use profiling tools to decide what to parallelize first. A good rule of thumb is the upper bound of your speedup is the reciprocal of the fraction of the algorithm you leave serialized. With MC you can parallelize pretty much 100%; it's "embarassingly" parallel. If you have an 80% parallelizable algorithm, then the best you can ever do is 5x faster on a wallclock. And that's an upper bound.


    Edited: Wed Nov 21, 07 at 09:09 PM by eredhuin

    ReplyDelete
  2. exneratunrisk
    Senior Member

    Posts: 1527
    Joined: Apr 2004
    Thu Feb 28, 08 01:06 PM


    colonel..

    Agree!

    We have now integrated hundred-thousands of lines of Mathematica, C+, Java code, with computational grid support, data base access
    and web front-end. We use the workbench intensively.
    To describe comprehensive tasks, we have created a kind of "uniform risk analytics task model" described in Mathematica.
    Every interaction pattern is transformed into this model.
    But also, when a complete task is performed (say, HTML calls Java calls Mathematica cals C++, or SQL), we create a Mathematica notebook automatically, which describes each single step in the system symbolically.
    This notebooks can be evaluated in Mathematica and tell us everything about the operational semantics of the task in the hybrid environment.
    This shortens development, integration and support cycles significantly.

    We are passionate about hybrid programming (choose languages and tools based on fit for purpose criteria), and Mathematica is our "operating system"
    for this.

    -------------------------
    Our news and views: UnRisk Insight

    Edited: Thu Feb 28, 08 at 01:07 PM by exneratunrisk

    ReplyDelete
  3. http://unriskinsight.blogspot.com/

    ReplyDelete
  4. http://www.china-quants.com/quants/index.asp

    ReplyDelete
  5. MCarreira
    Senior Member

    Posts: 1339
    Joined: Jul 2002
    Fri Jul 11, 08 04:04 AM


    Computational Financial Mathematics using Mathematica is a good reference for SDEs, and has code.

    -------------------------
    "The best lack all conviction, while the worst
    Are full of passionate intensity." - W.B. Yeats

    ReplyDelete
  6. exneratunrisk
    Senior Member

    Posts: 1527
    Joined: Apr 2004
    Mon Apr 20, 09 10:13 AM


    I know, all of the related systems are developing fast.
    I have only deeper experiences with Mathematica.

    We are now intensively using Mathematica 7.
    Its major enhancement is: built-in parallel computing for the multi-core revolution (more local parallelization) and (networked) pools of compute processes (the original "definition" of Grid computing at CERN) where each computer announces its availability and can be accessed in parallel.

    In principle Mathematica seems to go the direction of integration instead of tool boxes.

    (IMO) If, where is Mathematica fundamentally different?
    - automation in computation, development and visualisation
    - integrated symbolic computation
    - unified symbolic representation (everything has a symbolic representation)
    - multi-paradigm programming
    - document centered interface

    ReplyDelete
  7. exneratunrisk
    Senior Member

    Posts: 1527
    Joined: Apr 2004
    Wed Nov 17, 10 02:26 PM


    Mathematica 8 was just released.

    New in Mathematica 8

    Important news for quant developers?

    IMO

    - new interactive charts and visualization
    - it has quadrupled its statistics and probability functionality (Wolfram claims: now the broadest available)
    - and for us hybrid system makers always striving for speed-up without giving away accuracy and robustness:
    Fast and automated-paralleliized C code generation, the direct integration of DLLs and CUDA / OpenCL support

    For huge information system planners, the integration with Wolfram|Alpha
    might be interesting?

    -------------------------
    Our news and views: UnRisk Insight

    Edited: Fri Nov 19, 10 at 10:56 AM by exneratunrisk

    ReplyDelete
  8. Alan
    Senior Member

    Posts: 4009
    Joined: Dec 2001
    Wed Nov 17, 10 03:00 PM


    Interesting -- I see that they have made the GBM option model (multiple assets) a built-in

    http://reference.wolfram.com/mathematica/ref/FinancialDerivative.html

    ReplyDelete
  9. I confused how to use matlab or mathematica. But I want to check mathematica first. Thank you for your information

    ReplyDelete
  10. AbsoluteTiming should be used instead of Timing, then the of time of MMA and Matlab are very close to each other.

    ReplyDelete

Post a Comment