Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mathematica 7 compares to other languages

1,168 views
Skip to first unread message

Xah Lee

unread,
Nov 30, 2008, 10:30:48 PM11/30/08
to

Wolfram Research's Mathematica Version 7 has just been released.

See:
http://www.wolfram.com/products/mathematica/index.html

Among it's marketing material, it has a section on how mathematica
compares to competitors.
http://www.wolfram.com/products/mathematica/analysis/

And on this page, there are sections where Mathematica is compared to
programing langs, such as C, C++, Java, and research langs Lisp,
ML, ..., and scripting langs Python, Perl, Ruby...

See:
http://www.wolfram.com/products/mathematica/analysis/content/ProgrammingLanguages.html
http://www.wolfram.com/products/mathematica/analysis/content/ResearchLanguages.html
http://www.wolfram.com/products/mathematica/analysis/content/ScriptingLanguages.html

Note: I'm not affliated with Wolfram Research Inc.

Xah
http://xahlee.org/


Xah Lee

unread,
Dec 1, 2008, 2:23:43 AM12/1/08
to
On Nov 30, 7:30 pm, Xah Lee <xah...@gmail.com> wrote:
> Wolfram Research's Mathematica Version 7 has just been released.
>
> See: http://www.wolfram.com/products/mathematica/index.html
>
> Among it's marketing material, it has a section on how mathematica
> compares to competitors. http://www.wolfram.com/products/mathematica/analysis/

Stephen Wolfram has a blog entry about Mathematica 7. Quite amazing:

http://blog.wolfram.com/2008/11/18/surprise-mathematica-70-released-today/

Mathematica today in comparsion to all other existing langs, can be
perhaps compared to how lisp was to other langs in the say 1980s:
Quite far beyond all.

Seeing how lispers today still talking about how to do basic list
processing with its unusable cons, and how they get giddy with 1980's
macros (as opposed to full term rewriting), and still lack pattern
matching, one feels kinda sad.

see also:

• Fundamental Problems of Lisp
http://xahlee.org/UnixResource_dir/writ/lisp_problems.html

Xah
http://xahlee.org/


Lars Rune Nøstdal

unread,
Dec 1, 2008, 3:19:03 AM12/1/08
to
On Sun, 2008-11-30 at 23:23 -0800, Xah Lee wrote:


For many people, an excuse is better than an achievement because
an achievement, no matter how great, leaves you having to prove
yourself again in the future; but an excuse can last for life.
-- Eric Hoffer


..better keep posting instead.. *holds hands over ears: lalalala*

budden

unread,
Dec 1, 2008, 5:24:09 AM12/1/08
to
Mathematica is a great language, but:
1. it is too slow
2. It is often hard to read
3. It gives sence to every keystroke. You press escape by occasion and
it goes in a code as a new
symbol, w/o error. Nasty.
3. I know 5-th version. It does not allow to track the source as SLIME
does. This feature as absolutely
necessary for serious development

So, in fact, Mathematica do not scale well IMO.

Don Geddis

unread,
Dec 1, 2008, 11:23:57 AM12/1/08
to
Xah Lee <xah...@gmail.com> wrote on Sun, 30 Nov 2008:
> Mathematica today in comparsion to all other existing langs, can be
> perhaps compared to how lisp was to other langs in the say 1980s:
> Quite far beyond all.

You seem to have drunk the kool-aid. Do you not realize that every
programming language design is a series of compromises? It always
makes some things easier, at the expense of making other things harder.

Can you think of no programming task for which the Mathematica approach
is more difficult?

> Seeing how lispers today still talking about how to do basic list
> processing with its unusable cons

You bring this up every time, and are just as wrong this time as each time
previous.

> and how they get giddy with 1980's macros (as opposed to full term
> rewriting), and still lack pattern matching, one feels kinda sad.

If you think that "full term rewriting" is a superset of the functionality of
Common Lisp macros, then you've clearly missed the whole point of macros.

Term rewriting may be a good idea. But macros are a different, good idea.

-- Don
_______________________________________________________________________________
Don Geddis http://don.geddis.org/ d...@geddis.org
Sign for a combined Veterinarian and Taxidermist business:
"Either Way You Get Your Dog Back"

anonymous...@gmail.com

unread,
Dec 1, 2008, 5:48:21 PM12/1/08
to
On Dec 1, 2:23 am, Xah Lee <xah...@gmail.com> wrote:
> On Nov 30, 7:30 pm, Xah Lee <xah...@gmail.com> wrote:
>
>>some stuff

Are you a bot?

I think you failed the Turing test after the 8th time you posted the
exact same thing...

I'm completely serious.

anonymous...@gmail.com

unread,
Dec 1, 2008, 5:53:50 PM12/1/08
to
On Nov 30, 10:30 pm, Xah Lee <xah...@gmail.com> wrote:
> some stuff

You are a bot?

I think you failed the Turing test when you posted the same thing 20
times.

A rational human would realize that not too many people peruse this
newsgroup,
and that most of them have already seen the wall of text post that you
generate every time.

Just a thought, but whoever owns this thing might want to rework the
AI.

awhite

unread,
Dec 1, 2008, 6:41:13 PM12/1/08
to
On Mon, 01 Dec 2008 14:53:50 -0800, anonymous.c.lisper wrote:

> On Nov 30, 10:30 pm, Xah Lee <xah...@gmail.com> wrote:
>> some stuff
>
> You are a bot?
>
> I think you failed the Turing test when you posted the same thing 20
> times.

I have wondered the same thing. Perhaps Xah is an ELIZA simulation without
the profanity filter.

A

Jon Harrop

unread,
Dec 1, 2008, 7:06:22 PM12/1/08
to
Xah Lee wrote:
> And on this page, there are sections where Mathematica is compared to
> programing langs, such as C, C++, Java, and research langs Lisp,
> ML, ..., and scripting langs Python, Perl, Ruby...

Have they implemented any of the following features in the latest version:

1. Redistributable standalone executables.

2. Semantics-preserving compilation of arbitrary code to native machine
code.

3. A concurrent run-time to make efficient parallelism easy.

4. Static type checking.

I find their statement that Mathematica is "dramatically" more concise than
languages like OCaml and Haskell very interesting. I ported my ray tracer
language comparison to Mathematica:

http://www.ffconsultancy.com/languages/ray_tracer/

My Mathematica code weighs in at 50 LOC compared to 43 LOC for OCaml and 44
LOC for Haskell. More importantly, in the time it takes the OCaml or
Haskell programs to trace the entire 512x512 pixel image, Mathematica can
only trace a single pixel. Overall, Mathematica is a whopping 700,000 times
slower!

Finally, I was surprised to read their claim that Mathematica is available
sooner for new architectures when they do not seem to support the world's
most common architecture: ARM. Also, 64-bit Mathematica came 12 years after
the first 64-bit ML...

Here's my Mathematica code for the ray tracer benchmark:

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]]]

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?u

bearoph...@lycos.com

unread,
Dec 1, 2008, 8:02:17 PM12/1/08
to
Mathematica has some powerful symbolic processing capabilities, for
example the integrals, etc. It also contains many powerful algorithms,
often written in few lines of code. And its graphic capabilities are
good. It also shows some surprising ways to integrate and manipulate
data, for example here you can see how you can even put images into
formulas, to manipulate them:
http://reference.wolfram.com/mathematica/ref/ImageApply.html

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.

But while the editor of (oldish) Mathematica is good to quickly input
formulas (but even for this I have found way better things, for
example the editor of GraphEQ www.peda.com/grafeq/ that is kilometers
ahead), it's awful for writing *programs* even small 10-line ones.
Even notepad seems better for this.

For normal programming Python is light years more handy and better
(and more readable too), there's no contest here. Python is also
probably faster for normal programs (when built-in functions aren't
used). Python is much simpler to learn, to read, to use (but it also
does less things).

A big problem is of course that Mathematica costs a LOT, and is closed
source, so a mathematician has to trust the program, and can't inspect
the code that gives the result. This also means that any research
article that uses Mathematica relies on a tool that costs a lot (so
not everyone can buy it to confirm the research results) and it
contains some "black boxes" that correspond to the parts of the
research that have used the closed source parts of Mathematica, that
produce their results by "magic". As you can guess, in science it's
bad to have black boxes, it goes against the very scientific method.

Bye,
bearophile

Lew

unread,
Dec 1, 2008, 8:29:44 PM12/1/08
to
anonymous...@gmail.com wrote:
> A rational human would realize that not too many people peruse this
> newsgroup,
> and that most of them have already seen the wall of text post that you
> generate every time.

Just out of curiosity, what do you consider "this" newsgroup, given its wide
crossposting?

--
Lew

Lew

unread,
Dec 1, 2008, 8:31:17 PM12/1/08
to
Jon Harrop wrote:
> Xah Lee wrote:
(nothing Java-related)

Please take this crud out of the Java newsgroup.

--
Lew

anonymous...@gmail.com

unread,
Dec 1, 2008, 8:46:10 PM12/1/08
to
On Dec 1, 8:29 pm, Lew <no...@lewscanon.com> wrote:

Ah, didn't realize the cross-posted nature.

comp.lang.lisp

Hadn't realized he had branched out to cross-posting across five
comp.langs

Apologies for the double post,
thought the internet had wigged out when i sent it first time.

toby

unread,
Dec 1, 2008, 10:47:47 PM12/1/08
to
On Dec 1, 5:24 am, budden <budde...@gmail.com> wrote:
> Mathematica is a great language, but:
> 1. it is too slow
> 2. It is often hard to read
> 3. It gives sence to every keystroke. You press escape by occasion and
> it goes in a code as a new
> symbol, w/o error. Nasty.
> 3. I know 5-th version. It does not allow to track the source as SLIME
> does. This feature as absolutely
> necessary for serious development

Worst of all, it's proprietary, which makes it next to useless. Money
corrupts.

Xah Lee

unread,
Dec 2, 2008, 2:36:11 PM12/2/08
to
2008-12-01

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.

few tips:

• Always use Module[] unless you really have a reason to use Block[].

• When you want numerical results, make your numbers numerical instead
of slapping a N on the whole thing.

• Avoid Table[] when you really want go for speed. Try Map and Range.

• I see nowhere using Compile. Huh?

Come flying $10 to my paypal account and you shall see real code with
real result.

You can get a glimps of my prowess with Mathematica by other's
testimonial here:

• Russell Towle Died
http://xahlee.org/Periodic_dosage_dir/t2/russel_tower.html

• 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

> Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u

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?

Xah
http://xahlee.org/

Lew

unread,
Dec 2, 2008, 3:21:14 PM12/2/08
to
Xah Lee wrote:
> LOL Jon. r u trying to get me to do otimization for you free?

These are professional software development forums, not some script-
kiddie cellphone-based chat room. "r" is spelled "are" and "u" should
be "you".

> how about pay me $5 thru paypal? I'm pretty sure i [sic] can speed it up.


> Say, maybe 10%, and even 50% is possible.

The first word in a sentence should be capitalized. "PayPal" is a
trademark and should be capitalized accordingly. The word "I" in
English should be capitalized.

Proper discipline in these matters helps the habit of mind for
languages like Java, where case counts.

Jon Harrop has a reputation as an extremely accomplished software
maven and columnist. I find his claims of relative speed and
compactness credible. He was not asking you to speed up his code, but
claiming that yours was not going to be as effective. The rhetorical
device of asking him for money does nothing to counter his points,
indeed it reads like an attempt to deflect the point.

--
Lew

Xah Lee

unread,
Dec 2, 2008, 3:50:44 PM12/2/08
to

Dear tech geeker Lew,

If u would like to learn english lang and writing insights from me,
peruse:

• Language and English
http://xahlee.org/Periodic_dosage_dir/bangu/bangu.html

In particular, i recommend these to start with:

• To An Or Not To An
http://xahlee.org/Periodic_dosage_dir/bangu/an.html

• I versus i
http://xahlee.org/Periodic_dosage_dir/bangu/i_vs_I.html

• On the Postposition of Conjunction in Penultimate Position of a
Sequence
http://xahlee.org/Periodic_dosage_dir/t2/1_2_and_3.html

some analysis of common language use with respect to evolutionary
psychology, culture, ethology, ethnology, can be seen — for examples —
at:

• Hip-Hop Rap and the Quagmire of (American) Blacks
http://xahlee.org/Periodic_dosage_dir/sanga_pemci/hiphop.html

• Take A Chance On Me
http://xahlee.org/Periodic_dosage_dir/sanga_pemci/take_a_chance_on_me.html

• 花样的年华 (Age of Blossom)
http://xahlee.org/Periodic_dosage_dir/sanga_pemci/hua3yang4nian2hua2.html

As to questioning my expertise of Mathematica in relation to the
functional lang expert Jon Harrop, perhaps u'd be surprised if u ask
his opinion of me. My own opinion, is that my Mathematica expertise
surpasses his. My opinion of his opinion of me is that, my opinion on
Mathematica is not to be trifled with.

Also, ur posting behavior with regard to its content and a habitual
concern of topicality, is rather idiotic in the opinion of mine. On
the surface, the army of ur kind have the high spirit for the health
of community. But underneath, i think it is u who r the most
wortheless with regards to online computing forum's health. I have
published a lot essays regarding this issue. See:

• Netiquette Anthropology
http://xahlee.org/Netiquette_dir/troll.html

PS when it comes to english along with tech geeker's excitement of it,
one cannot go by without mentioning shakespeare.

• The Tragedy Of Titus Andronicus, annotated by Xah Lee
http://xahlee.org/p/titus/titus.html

Please u peruse of it.

Xah
http://xahlee.org/


Lew

unread,
Dec 2, 2008, 4:57:35 PM12/2/08
to
Xah Lee wrote:
> 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.


> As to questioning my expertise of Mathematica in relation to the

> functional lang[uage] expert Jon Harrop, perhaps [yo]u'd be surprised if [yo]u ask


> his opinion of me. My own opinion, is that my Mathematica expertise
> surpasses his. My opinion of his opinion of me is that, my opinion on
> Mathematica is not to be trifled with.

I have no assertion or curiosity about Jon Harrop's expertise compared
to yours. I was expressing my opinion of his expertise, which is
high.

> Also, [yo]ur posting behavior with regard to its content and a habitual


> concern of topicality, is rather idiotic in the opinion of mine. On

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.

> the surface, the army of [yo]ur kind have the high spirit for the health
> of community. But underneath, i [sic] think it is [yo]u who [a]r[e] the most


> wortheless with regards to online computing forum's health.

You are entitled to your opinion. I take no offense at your attempts
to insult me.

How does your obfuscatory behavior in any way support your technical
points?

--
Lew

Tamas K Papp

unread,
Dec 2, 2008, 5:04:44 PM12/2/08
to
On Tue, 02 Dec 2008 13:57:35 -0800, Lew wrote:

> Xah Lee wrote:
>> 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.

Best,

Tamas

Thomas A. Russ

unread,
Dec 2, 2008, 5:30:12 PM12/2/08
to

bearoph...@lycos.com writes:

> A big problem is of course that Mathematica costs a LOT, and is closed
> source, so a mathematician has to trust the program, and can't inspect
> the code that gives the result. This also means that any research
> article that uses Mathematica relies on a tool that costs a lot (so
> not everyone can buy it to confirm the research results) and it
> contains some "black boxes" that correspond to the parts of the
> research that have used the closed source parts of Mathematica, that
> produce their results by "magic". As you can guess, in science it's
> bad to have black boxes, it goes against the very scientific method.

Well, that hardly seems to be the case for most science that relies on
standard, physical instruments. Certainly mass spectrograph analyzers
are not free. Some of them are quite expensive. But that doesn't stop
them from being useful tools in biology and chemistry. And it doesn't
deter other scientists from being able to check the work just because
they may need an expensive piece of apparatus to do it.

In any case, for results that are produced by Mathematica, shouldn't it
be possible to just check them by hand? After all, it isn't as if there
is some proprietary principles of mathematics that are involved, are
there?

And should be conclude that any research done by the Large Hadron
Collider goes against the scientific method just because there's only
one, tremendously expensive machine that allows you to verify the
experimental results?

--
Thomas A. Russ, USC/Information Sciences Institute

John B. Matthews

unread,
Dec 2, 2008, 6:36:03 PM12/2/08
to
In article
<fedfc0ce-7909-42c2...@v5g2000prm.googlegroups.com>,
Xah Lee <xah...@gmail.com> wrote:

[...]


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

> [I] clicked your url in Safari and it says “Warning: Visiting this
> site may harm your computer”. Apparantly, your site set[s] 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>

--
John B. Matthews
trashgod at gmail dot com
http://home.roadrunner.com/~jbmatthews/

Jon Harrop

unread,
Dec 2, 2008, 8:13:39 PM12/2/08
to
Xah Lee wrote:
> On Dec 1, 4:06 pm, Jon Harrop <j...@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?

> few tips:
>
> • Always use Module[] unless you really have a reason to use Block[].

Actually Module is slow because 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.

In this case, Module is 30% slower.

> • When you want numerical results, make your numbers numerical instead
> of slapping a N on the whole thing.

Why?

> • Avoid Table[] when you really want go for speed. Try Map and Range.

The time spent in Table is insignificant.

> • I see nowhere using Compile. Huh?

Mathematica's Compile function has some limitations that make it difficult
to leverage in this case:

. Compile cannot handle recursive functions, e.g. the Intersect function.

. Compile cannot handle curried functions, e.g. the Intersect function.

. Compile cannot handle complex arithmetic, e.g. inside RaySphere.

. Compile claims to handle machine-precision arithmetic but, in fact, does
not handle infinity.

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.

> • 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

>> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
>> http://www.ffconsultancy.com/?u
>
> 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.

--

George Sakkis

unread,
Dec 2, 2008, 9:25:08 PM12/2/08
to
On Dec 2, 4:57 pm, Lew <l...@lewscanon.com> wrote:

> 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 ;-)

Xah Lee

unread,
Dec 2, 2008, 9:31:39 PM12/2/08
to
On Dec 2, 5:13 pm, Jon Harrop <j...@ffconsultancy.com> wrote:
> XahLeewrote:

> > On Dec 1, 4:06 pm, Jon Harrop <j...@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.
>
> Why?

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.
> >>http://www.ffconsultancy.com/?u
>
> > 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.

Xah
http://xahlee.org/


George Neuner

unread,
Dec 2, 2008, 9:46:22 PM12/2/08
to
On 02 Dec 2008 14:30:12 -0800, t...@sevak.isi.edu (Thomas A. Russ)
wrote:

No, but the results must be held suspect until independently verified.
Given the enormous cost of the LHC and the economic climate, nothing
it produces are likely to be verified in our lifetimes.

George

Lew

unread,
Dec 2, 2008, 10:28:23 PM12/2/08
to
George Sakkis wrote:
> 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.

--
Lew

Pascal J. Bourguignon

unread,
Dec 3, 2008, 7:45:48 AM12/3/08
to
George Neuner <gneu...@comcast.net> writes:

Right for the collider. I would even require to build the checking
collider on another planet, just to be sure the results we get are not
local happenstance.


But for Mathematica, you can use other software to check the results,
there are a lot of mathematical software and theorem provers around.

--
__Pascal Bourguignon__

Jon Harrop

unread,
Dec 3, 2008, 11:24:36 AM12/3/08
to
Xah Lee wrote:
> On Dec 2, 5:13 pm, Jon Harrop <j...@ffconsultancy.com> wrote:
>> 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.

My example demonstrates several of Mathematica's fundamental limitations.
They cannot be avoided without improving or replacing Mathematica itself.
These issues are never likely to be addressed in Mathematica because its
users value features and not general performance.

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.

>> > 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.

What exactly do you believe is wrong with my code?

>> In this case, Module is 30% slower.
>
> Indeed, because somethnig is very wrong with your code.

No, that is a well-known characteristic of Mathematica's Module and it has
nothing to do with my code.

>> > • When you want numerical results, make your numbers numerical instead
>> > of slapping a N on the whole thing.
>>
>> Why?
>
> 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.

That is a premature optimization that has no significant effect in this case
because all applications of N have already been hoisted.

>> > • 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.

It is insignificant in this case.

>> > • 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.

No, such computations must be off-loaded to a more performant high-level
language implementation like OCaml or F#. With up to five orders of
magnitude performance difference, that means almost all computations.

>> 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.

I am not trying to make Mathematica look bad. It is simply not suitable when
hierarchical solutions are preferable, e.g. FMM, BSPs, adaptive subdivision
for cosmology, hydrodynamics, geophysics, finite element materials...

The Mathematica language is perhaps the best example of what a Lisp-like
language can be good for in the real world but you cannot compare it to
modern FPLs like OCaml, Haskell, F# and Scala because it doesn't even have
a type system, let alone a state-of-the-art static type system.

Mathematica is suitable for graph plotting and for solving problems where it
provides a prepackaged solution that is a perfect fit. Even then, you can
have unexpected problems. Compute the FFT of 2^20 random machine-precision
floats and it works fine. Raise them to the power of 100 and it becomes
100x slower, at which point you might as well be writing your numerical
code in PHP.

--

Jon Harrop

unread,
Dec 3, 2008, 11:33:03 AM12/3/08
to
Thomas A. Russ wrote:
> In any case, for results that are produced by Mathematica, shouldn't it
> be possible to just check them by hand?

Only in some cases. For example, most numerical computations cannot be
checked by hand and any large symbolic calculations quickly become
intractable.

Xah Lee

unread,
Dec 3, 2008, 4:15:11 PM12/3/08
to
On Dec 3, 8:24 am, Jon Harrop <j...@ffconsultancy.com> wrote:
> 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/

Thomas M. Hermann

unread,
Dec 3, 2008, 5:12:51 PM12/3/08
to

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 x...@xahlee.org, 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:

Chris Rathman

unread,
Dec 3, 2008, 6:23:53 PM12/3/08
to
Xah Lee wrote:
> 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.

Xah Lee

unread,
Dec 3, 2008, 6:26:26 PM12/3/08
to
> 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 x...@xahlee.org, 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/

Thomas M. Hermann

unread,
Dec 3, 2008, 7:22:21 PM12/3/08
to
On Dec 3, 5:26 pm, Xah Lee <xah...@gmail.com> wrote:
> 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

Xah Lee

unread,
Dec 3, 2008, 7:32:57 PM12/3/08
to

Got the payment. Thanks.

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

Xah
http://xahlee.org/


Lew

unread,
Dec 3, 2008, 8:38:44 PM12/3/08
to
Xah Lee wrote:
> enough babble ...

Good point. Plonk. Guun dun!

--
Lew

toby

unread,
Dec 3, 2008, 11:15:24 PM12/3/08
to

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

>
> Best,
>
> Tamas

toby

unread,
Dec 3, 2008, 11:19:01 PM12/3/08
to
On Dec 3, 4:15 pm, Xah Lee <xah...@gmail.com> wrote:
> On Dec 3, 8:24 am, Jon Harrop <j...@ffconsultancy.com> wrote:
>
> > 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,

I'll give you $5 to go away

--T

Jürgen Exner

unread,
Dec 3, 2008, 11:45:39 PM12/3/08
to

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

jue

Kaz Kylheku

unread,
Dec 3, 2008, 11:54:31 PM12/3/08
to

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

Jürgen Exner

unread,
Dec 4, 2008, 12:24:13 AM12/4/08
to

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

jue

Andreas Waldenburger

unread,
Dec 4, 2008, 5:11:15 AM12/4/08
to
On Wed, 03 Dec 2008 20:38:44 -0500 Lew <no...@lewscanon.com> wrote:

> Xah Lee wrote:
> > enough babble ...
>
> 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

--
My real email address is constructed by swapping the domain with the
recipient (local part).

Lew

unread,
Dec 4, 2008, 9:19:04 AM12/4/08
to
Andreas Waldenburger wrote:
> On Wed, 03 Dec 2008 20:38:44 -0500 Lew <no...@lewscanon.com> wrote:
>
>> Xah Lee wrote:
>>> enough babble ...
>> 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?

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

--
Lew

Don Geddis

unread,
Dec 4, 2008, 12:56:15 PM12/4/08
to
Xah Lee <xah...@gmail.com> wrote on Wed, 3 Dec 2008 :
> On Dec 3, 8:24 am, Jon Harrop <j...@ffconsultancy.com> wrote:
>> My example demonstrates several of Mathematica's fundamental limitations.
> enough babble Jon.

Wait a minute ... are c.l.l's two trolls having a public argument with
each other?

Suddenly, I feel a deja vu flashback to misconfigured mailer daemons,
that just keep sending bounced email messages back and forth to each other
in an infinite loop...

-- Don
_______________________________________________________________________________
Don Geddis http://don.geddis.org/ d...@geddis.org

Kaz Kylheku

unread,
Dec 4, 2008, 2:20:44 PM12/4/08
to
On 2008-12-04, Don Geddis <d...@geddis.org> wrote:
> Xah Lee <xah...@gmail.com> wrote on Wed, 3 Dec 2008 :
>> On Dec 3, 8:24 am, Jon Harrop <j...@ffconsultancy.com> wrote:
>>> My example demonstrates several of Mathematica's fundamental limitations.
>> enough babble Jon.
>
> Wait a minute ... are c.l.l's two trolls having a public argument with
> each other?

Now if they start trimming the responses in each round, so that the article
size is bounded, we can call it proper tail recursion!

Dimiter "malkia" Stanev

unread,
Dec 4, 2008, 3:08:48 PM12/4/08
to
> You think the posts are bad... check out his web site...

Just don't go to every page on the Xah website - some of his stuff is
NSFW (Not Safe For Work).

s...@netherlands.com

unread,
Dec 4, 2008, 7:09:53 PM12/4/08
to
On Wed, 3 Dec 2008 16:32:57 -0800 (PST), Xah Lee <xah...@gmail.com> wrote:

>On Dec 3, 4:22 pm, "Thomas M. Hermann" <tmh.pub...@gmail.com> wrote:
>> On Dec 3, 5:26 pm, Xah Lee <xah...@gmail.com> wrote:
>>
>>
>>
>> > 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,