Mathematica 7 compares to other languages

J

John B. Matthews

[...]
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/

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?

[...]

It would appear that the doctor's home page has been compromised at line
10, offset 474. A one-pixel iframe linked to onlinestat.cn may be the
fault:

<http://google.com/safebrowsing/diagnostic?tpl=safari&site=onlinestat.cn&
hl=en-us>
 
G

George Sakkis

There is no reason for you to engage in an /ad hominem/ attack.  It
does not speak well of you to resort to deflection when someone
expresses a contrary opinion, as you did with both Jon Harrop and with
me.  I suggest that your ideas will be taken more seriously if you
engage in more responsible behavior.

As a Slashdotter would put it... you must be new here ;-)
 
X

Xah Lee

XahLeewrote:



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.

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.
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.
HTTP request sent, awaiting response... 403 Forbidden

It seems to work for me?
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.

Xah
∑ http://xahlee.org/

☄
 
L

Lew

George said:
As a Slashdotter would put it... you must be new here ;-)

For certain values of "here". I've seen Xah before, and I'm happy to engage
if he behaves himself. Some of his initial ideas I actually find engaging.
His followups leave a lot to be desired.

f/u set to comp.lang.functional. It looks like he's got nothing to offer us
Java weenies this time around.
 
J

jason-sage

So when you need an algorithm, you can often find it already inside,
for example in the large Combinatorics package. So it has WAY more
batteries included, compared to Python. I'd like to see something as
complete as that Combinatorics package in Python.


Sage (http://www.sagemath.org/, based on Python) already has some pretty
powerful and comprehensive combinatorics functionality (including lots
of things that Mma doesn't have). What's more, one of the most
comprehensive combinatorics libraries out there, MuPAD combinat, is
currently in the process of switching to Sage (and becoming the
Sage-combinat project). See http://wiki.sagemath.org/combinat/.

If you are interested in graph theory, then you might be interested in
the comparison to the Combinatorica package at
http://wiki.sagemath.org/CombinatoricaCompare . This page is a little
old, but it gives you an idea of how things compare.

Jason
 
H

Hendrik van Rooyen

Xah Lee said:
Chances are, $10 is not enough for me to take the
trouble of disappearing from the face of this earth.

What a pity.
It would be cheap at the price.

- Hendrik
 
X

Xah Lee

My example demonstrates several of Mathematica's fundamental limitations.

enough babble Jon.

Come flying $5 to my paypal account, and i'll give you real code,
amongest the programing tech geekers here for all to see.

I'll show, what kinda garbage you cooked up in your Mathematica code
for “comparisonâ€.

You can actually just post your “comparisons†to “comp.soft-
sys.math.mathematicaâ€, and you'll be ridiculed to death for any
reasonable judgement of claim on fairness.
Consequently, there is great value in combining Mathematica with performant
high-level languages like OCaml and F#. This is what the vast majority of
Mathematica users do: they use it as a glorified graph plotter.

glorified your ass.

Yeah, NASA, Intel, NSA, ... all use Mathematica to glorify their
pictures. LOL.
What exactly do you believe is wrong with my code?

come flies $5 to my paypal, and i'll explain further.
I am not trying to make Mathematica look bad. It is simply not suitable when
hierarchical solutions are preferable...

Certainly there are areas other langs are more suitable and better
than Mathematica (for example: assembly langs). But not in the ways
you painted it to peddle your F# and OCaml books.

You see Jon, you are this defensive, trollish guy, who takes every
opportunity to slight other langs that's not one of your F#, OCml that
you make a living of. In every opportunity, you injest your gribes
about static typing and other things, and thru ensuring chaos paves
the way for you to post urls to your website.

With your math and functional programing expertise and Doctor label,
it can be quite intimidating to many geekers. But when you bump into
me, i don't think you have a chance.

As a scientist, i think perhaps you should check your newsgroup
demeanor a bit? I mean, you already have a reputation of being biased.
Too much bias and peddling can be detrimental to your career, y'known?

to be sure, i still respect your expertise and in general think that a
significant percentage of tech geeker's posts in debate with you are
moronic, especially the Common Moron Lispers, and undoubtably the Java
and imperative lang slaving morons who can't grope the simplest
mathematical concepts. Throwing your Mathematica bad mouthing at me
would be a mistake.

Come, fly $5 to my paypal account. Let the challenge begin.

Xah
∑ http://xahlee.org/

☄
 
T

Thomas M. Hermann

enough babble Jon.

Come flying $5 to my paypal account, and i'll give you real code,
amongest the programing tech geekers here for all to see.

I'll show, what kinda garbage you cooked up in your Mathematica code
for “comparisonâ€.

You can actually just post your “comparisons†to “comp.soft-
sys.math.mathematicaâ€, and you'll be ridiculed to death for any
reasonable judgement of claim on fairness.


glorified your ass.

Yeah, NASA, Intel, NSA, ... all use Mathematica to glorify their
pictures. LOL.


come flies $5 to my paypal, and i'll explain further.


Certainly there are areas other langs are more suitable and better
than Mathematica (for example: assembly langs). But not in the ways
you painted it to peddle your F# and OCaml books.

You see Jon, you are this defensive, trollish guy, who takes every
opportunity to slight other langs that's not one of your F#, OCml that
you make a living of. In every opportunity, you injest your gribes
about static typing and other things, and thru ensuring chaos paves
the way for you to post urls to your website.

With your math and functional programing expertise and Doctor label,
it can be quite intimidating to many geekers. But when you bump into
me, i don't think you have a chance.

As a scientist, i think perhaps you should check your newsgroup
demeanor a bit? I mean, you already have a reputation of being biased.
Too much bias and peddling can be detrimental to your career, y'known?

to be sure, i still respect your expertise and in general think that a
significant percentage of tech geeker's posts in debate with you are
moronic, especially the Common Moron Lispers, and undoubtably the Java
and imperative lang slaving morons who can't grope the simplest
mathematical concepts. Throwing your Mathematica bad mouthing at me
would be a mistake.

Come, fly $5 to my paypal account. Let the challenge begin.

  Xah
∑http://xahlee.org/

☄

Xah,

I'll pay $20 to see your improved version of the code. The only
references to PayPal I saw on your website were instructions to direct
the payment to (e-mail address removed), please let me know if that is correct.

What I want in return is you to execute and time Dr. Harrop's original
code, posting the results to this thread. Then, I would like you to
post your code with the timing results to this thread as well.

By Dr. Harrop's original code, I specifically mean the code he posted
to this thread. I've pasted it below for clarity.

Jon Harrop coded a ray tracer in Mathematica:
delta = Sqrt[$MachineEpsilon];

RaySphere[o_, d_, c_, r_] :=
Block[{v, b, disc, t1, t2},
v = c - o;
b = v.d;
disc = Sqrt[b^2 - v.v + r^2];
t2 = b + disc;
If[Im[disc] != 0 || t2 <= 0, \[Infinity],
t1 = b - disc;
If[t1 > 0, t1, t2]]
]

Intersect[o_, d_][{lambda_, n_}, Sphere[c_, r_]] :=
Block[{lambda2 = RaySphere[o, d, c, r]},
If[lambda2 >= lambda, {lambda, n}, {lambda2,
Normalize[o + lambda2 d - c]}]
]
Intersect[o_, d_][{lambda_, n_}, Bound[c_, r_, s_]] :=
Block[{lambda2 = RaySphere[o, d, c, r]},
If[lambda2 >= lambda, {lambda, n},
Fold[Intersect[o, d], {lambda, n}, s]]
]

neglight = N@Normalize[{1, 3, -2}];

nohit = {\[Infinity], {0, 0, 0}};

RayTrace[o_, d_, scene_] :=
Block[{lambda, n, g, p},
{lambda, n} = Intersect[o, d][nohit, scene];
If[lambda == \[Infinity], 0,
g = n.neglight;
If[g <= 0, 0,
{lambda, n} =
Intersect[o + lambda d + delta n, neglight][nohit, scene];
If[lambda < \[Infinity], 0, g]]]
]

Create[level_, c_, r_] :=
Block[{obj = Sphere[c, r]},
If[level == 1, obj,
Block[{a = 3*r/Sqrt[12], Aux},
Aux[x1_, z1_] := Create[level - 1, c + {x1, a, z1}, 0.5 r];
Bound[c,
3 r, {obj, Aux[-a, -a], Aux[a, -a], Aux[-a, a], Aux[a, a]}]]]]

scene = Create[1, {0, -1, 4}, 1];

Main[level_, n_, ss_] :=
Block[{scene = Create[level, {0, -1, 4}, 1]},
Table[
Sum[
RayTrace[{0, 0, 0},
N@Normalize[{(x + s/ss/ss)/n - 1/2, (y + Mod[s, ss]/ss)/n - 1/2,
1}], scene], {s, 0, ss^2 - 1}]/ss^2, {y, 0, n - 1},
{x, 0, n - 1}]]

AbsoluteTiming[Export["image.pgm", Graphics@Raster@Main[9, 512, 4]]]
 
C

Chris Rathman

Xah said:
Come flying $5 to my paypal account, and i'll give you real code,
amongest the programing tech geekers here for all to see.

That's the problem with Mathematica - it's so expensive that you even
have to pay for simple benchmark programs.
 
X

Xah Lee

I'll pay $20 to see your improved version of the code. The only
references to PayPal I saw on your website were instructions to direct
the payment to (e-mail address removed), please let me know if that is correct.

What I want in return is you to execute and time Dr. Harrop's original
code, posting the results to this thread. Then, I would like you to
post your code with the timing results to this thread as well.

By Dr. Harrop's original code, I specifically mean the code he posted
to this thread. I've pasted it below for clarity.

Agreed. My paypal address is “xah @@@ xahlee.orgâ€. (replace the triple
@ to single one.) Once you paid thru paypal, you can post receit here
if you want to, or i'll surely acknowledge it here.

Here's what i will do:

I will give a version of Mathematica code that has the same behavior
as his. And i will give timing result. The code will run in
Mathematica version 4. (sorry, but that's what i have) As i
understand, Jon is running Mathematica 6. However, i don't see
anything that'd require Mathematica 6. If my code is not faster or in
other ways not satisfactory (by your judgement), or it turns out
Mathematica 6 is necessary, or any problem that might occure, i offer
money back guarantee.

Xah
∑ http://xahlee.org/

☄

enough babble Jon.
Come flying $5 to my paypal account, and i'll give you real code,
amongest the programing tech geekers here for all to see.
I'll show, what kinda garbage you cooked up in your Mathematica code
for “comparisonâ€.
You can actually just post your “comparisons†to “comp.soft-
sys.math.mathematicaâ€, and you'll be ridiculed to death for any
reasonable judgement of claim on fairness.
glorified your ass.
Yeah, NASA, Intel, NSA, ... all use Mathematica to glorify their
pictures. LOL.
come flies $5 to my paypal, and i'll explain further.
Certainly there are areas other langs are more suitable and better
than Mathematica (for example: assembly langs). But not in the ways
you painted it to peddle your F# and OCaml books.
You see Jon, you are this defensive, trollish guy, who takes every
opportunity to slight other langs that's not one of your F#, OCml that
you make a living of. In every opportunity, you injest your gribes
about static typing and other things, and thru ensuring chaos paves
the way for you to post urls to your website.
With your math and functional programing expertise and Doctor label,
it can be quite intimidating to many geekers. But when you bump into
me, i don't think you have a chance.
As a scientist, i think perhaps you should check your newsgroup
demeanor a bit? I mean, you already have a reputation of being biased.
Too much bias and peddling can be detrimental to your career, y'known?
to be sure, i still respect your expertise and in general think that a
significant percentage of tech geeker's posts in debate with you are
moronic, especially the Common Moron Lispers, and undoubtably the Java
and imperative lang slaving morons who can't grope the simplest
mathematical concepts. Throwing your Mathematica bad mouthing at me
would be a mistake.
Come, fly $5 to my paypal account. Let the challenge begin.

☄

Xah,

I'll pay $20 to see your improved version of the code. The only
references to PayPal I saw on your website were instructions to direct
the payment to (e-mail address removed), please let me know if that is correct.

What I want in return is you to execute and time Dr. Harrop's original
code, posting the results to this thread. Then, I would like you to
post your code with the timing results to this thread as well.

By Dr. Harrop's original code, I specifically mean the code he posted
to this thread. I've pasted it below for clarity.

Jon Harrop coded a ray tracer in Mathematica:
delta = Sqrt[$MachineEpsilon];
RaySphere[o_, d_, c_, r_] :=
Block[{v, b, disc, t1, t2},
v = c - o;
b = v.d;
disc = Sqrt[b^2 - v.v + r^2];
t2 = b + disc;
If[Im[disc] != 0 || t2 <= 0, \[Infinity],
t1 = b - disc;
If[t1 > 0, t1, t2]]
]
Intersect[o_, d_][{lambda_, n_}, Sphere[c_, r_]] :=
Block[{lambda2 = RaySphere[o, d, c, r]},
If[lambda2 >= lambda, {lambda, n}, {lambda2,
Normalize[o + lambda2 d - c]}]
]
Intersect[o_, d_][{lambda_, n_}, Bound[c_, r_, s_]] :=
Block[{lambda2 = RaySphere[o, d, c, r]},
If[lambda2 >= lambda, {lambda, n},
Fold[Intersect[o, d], {lambda, n}, s]]
]
neglight = N@Normalize[{1, 3, -2}];
nohit = {\[Infinity], {0, 0, 0}};
RayTrace[o_, d_, scene_] :=
Block[{lambda, n, g, p},
{lambda, n} = Intersect[o, d][nohit, scene];
If[lambda == \[Infinity], 0,
g = n.neglight;
If[g <= 0, 0,
{lambda, n} =
Intersect[o + lambda d + delta n, neglight][nohit, scene];
If[lambda < \[Infinity], 0, g]]]
]
Create[level_, c_, r_] :=
Block[{obj = Sphere[c, r]},
If[level == 1, obj,
Block[{a = 3*r/Sqrt[12], Aux},
Aux[x1_, z1_] := Create[level - 1, c + {x1, a, z1}, 0.5 r];
Bound[c,
3 r, {obj, Aux[-a, -a], Aux[a, -a], Aux[-a, a], Aux[a, a]}]]]]
scene = Create[1, {0, -1, 4}, 1];
Main[level_, n_, ss_] :=
Block[{scene = Create[level, {0, -1, 4}, 1]},
Table[
Sum[
RayTrace[{0, 0, 0},
N@Normalize[{(x + s/ss/ss)/n - 1/2, (y + Mod[s, ss]/ss)/n - 1/2,
1}], scene], {s, 0, ss^2 - 1}]/ss^2, {y, 0, n - 1},
{x, 0, n - 1}]]
AbsoluteTiming[Export["image.pgm", Graphics@Raster@Main[9, 512, 4]]]
 
T

Thomas M. Hermann

Agreed. My paypal address is “xah @@@ xahlee.orgâ€. (replace the triple
@ to single one.) Once you paid thru paypal, you can post receit here
if you want to, or i'll surely acknowledge it here.

Here's what i will do:

I will give a version of Mathematica code that has the same behavior
as his. And i will give timing result. The code will run in
Mathematica version 4. (sorry, but that's what i have) As i
understand, Jon is running Mathematica 6. However, i don't see
anything that'd require Mathematica 6. If my code is not faster or in
other ways not satisfactory (by your judgement), or it turns out
Mathematica 6 is necessary, or any problem that might occure, i offer
money back guarantee.

  Xah
∑http://xahlee.org/

☄

Alright, I've sent $20. The only reason I would request a refund is if
you don't do anything. As long as you improve the code as you've
described and post the results, I'll be satisfied. If the improvements
you've described don't result in better performance, that's OK.

Good luck,

Tom
 
X

Xah Lee

Alright, I've sent $20. The only reason I would request a refund is if
you don't do anything. As long as you improve the code as you've
described and post the results, I'll be satisfied. If the improvements
you've described don't result in better performance, that's OK.

Good luck,

Tom

Got the payment. Thanks.

I'll reply back with code tonight or tomorrow. Wee!

Xah
∑ http://xahlee.org/

☄
 
T

toby

Xah said:
If [yo]u would like to learn [the] [E]nglish lang[uage] and writing
insights from me, peruse:
/Au contraire/, I was suggesting a higher standard for your posts.

Hi Lew,

It is no use. Xah has been posting irrelevant rants in broken English
here for ages. No one knows why, but mental institutions must be really
classy these days if the inmates have internet access. Just filter him
out with your newsreader.

You think the posts are bad... check out his web site...
--T
 
K

Kaz Kylheku

if you add "and never come back" then count me in, too.

Really? I will trade you one Xah Lee for three Jon Harrops and I will even
throw in a free William James.
 
J

Jürgen Exner

Kaz Kylheku said:
Really? I will trade you one Xah Lee for three Jon Harrops and I will even
throw in a free William James.

Well, I've never seen those names on CL.perl.M, so I don't know them.

jue
 
A

Andreas Waldenburger

Good point. Plonk. Guun dun!

I vaguely remember you plonking the guy before. Did you unplonk him in
the meantime? Or was that just a figure of speech?


teasingly yours,
/W
 
L

Lew

Andreas said:
I vaguely remember you plonking the guy before. Did you unplonk him in
the meantime? Or was that just a figure of speech?

I have had some hard drive and system changes that wiped out my old killfiles.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top