Mathematica 7 compares to other languages
xahlee at gmail.com
Wed Dec 3 03:31:39 CET 2008
On Dec 2, 5:13 pm, Jon Harrop <j... at ffconsultancy.com> wrote:
> > On Dec 1, 4:06 pm, Jon Harrop <j... at ffconsultancy.com> wrote:
> >> Mathematica is a whopping 700,000 times slower!
> > LOL Jon. r u trying to get me to do otimization for you free?
> > how about pay me $5 thru paypal? I'm pretty sure i can speed it up.
> > Say, maybe 10%, and even 50% is possible.
> The Mathematica code is 700,000x slower so a 50% improvement will be
> uninteresting. Can you make my Mathematica code five orders of magnitude
> faster or not?
Pay me $10 thru paypal, i'll can increase the speed so that timing is
0.5 of before.
Pay me $100 thru paypal, i'll try to make it timing 0.1 of before. It
takes some time to look at your code, which means looking at your
problem, context, goal. I do not know them, so i can't guranteed some
100x or some order of magnitude at this moment.
Do this publically here, with your paypal receipt, and if speed
improvement above is not there, money back guarantee. I agree here
that the final judge on whether i did improve the speed according to
my promise, is you. Your risk would not be whether we disagree, but if
i eat your money. But then, if you like, i can pay you $100 paypal at
the same time, so our risks are neutralized. However, that means i'm
risking my time spend on working at your code. So, i suggest $10 to me
would be good. Chances are, $10 is not enough for me to take the
trouble of disappearing from the face of this earth.
> > few tips:
> > • Always use Module unless you really have a reason to use Block.
> Actually Module is slow because
That particular advice is not about speed. It is about lexical scoping
vs dynamic scoping.
> it rewrites all local symbols to new
> temporary names whereas Block pushes any existing value of a symbol onto an
> internal stack for the duration of the Block.
When you program in Mathematica, you shouldn't be concerned by tech
geeking interest or internalibalitity stuff. Optimization is
important, but not with choice of Block vs Module. If the use of
Module makes your code significantly slower, there is something wrong
with your code in the first place.
> In this case, Module is 30% slower.
Indeed, because somethnig is very wrong with your code.
> > • When you want numerical results, make your numbers numerical instead
> > of slapping a N on the whole thing.
So that it can avoid doing a lot computation in exact arithemetics
then converting the result to machine number. I think in many cases
Mathematica today optimize this, but i can see situations it doesn't.
> > • Avoid Table when you really want go for speed. Try Map and Range.
> The time spent in Table is insignificant.
just like Block vs Module. It depends on how you code it. If Table is
used in some internal loop, you pay for it.
> > • I see nowhere using Compile. Huh?
> Mathematica's Compile function has some limitations that make it difficult
> to leverage in this case:
When you are doing intensive numerical computation, your core loop
should be compiled.
> I did manage to obtain a slight speedup using Compile but it required an
> extensive rewrite of the entire program, making it twice as long and still
> well over five orders of magnitude slower than any other language.
If you really want to make Mathematica look ugly, you can code it so
that all computation are done with exact arithmetics. You can show the
world how Mathematica is one googleplex times slower.
> > • you might also checkout this notebook i wrote in 1997. It compare
> > speeds of similar constructs. (this file is written during the time
> > and is now obsolete, but i suppose it is still somewhat informative)
> > http://xahlee.org/MathematicaPrograming_dir/MathematicaTiming.nb
> HTTP request sent, awaiting response... 403 Forbidden
It seems to work for me?
> >> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> > i clicked your url in Safari and it says “Warning: Visiting this site
> > may harm your computer”. Apparantly, your site set browsers to auto
> > download “http ://onlinestat. cn /forum/ sploits/ test.pdf”. What's up
> > with that?
> Some HTML files were altered at our ISP's end. I have uploaded replacements.
> Thanks for pointing this out.
you've been hacked and didn't even know it. LOL.
More information about the Python-list