Discovering Yourself on the Web
This is an old Usenet news message from February 1995, which I didn't first recognise as my own message. Did I at some point write this kind of things to the newgroups? It appears so.> Here is a further selection of comparisons of Mathematica and > Maple's numeric performance, again performed on a SPARC 1. > 1) Creating a table of Sin[i] for the first 10,000 integers (fp evaluation > throughout) > Maple Mathematica > ----- ----------- > for i from 1 to 10000 Timing[x = Sin[Range[10000.]] > do x[i]:= evalhf(sin(i)) od: > 8.100s 3.333sThe comparison is a bit unfair, because of using array constructs in Mathematica and a loop in Maple. Here are the results for using "for" and "seq" constructs in Maple (on a SGI system, CPU times are in seconds):---------------------------------------------------------------------- > st := time(): for i from 1 to 10000 do x[i]:= evalhf(sin(i)) od: time() - st;2.434> st := time(): x2 := [seq(evalhf(sin(`i`)), `i`=1..10000)]: time() - st;1.250 ----------------------------------------------------------------------Thus the "seq" version is almost twice as fast as the loop version. There might be even a faster way to do the calculation (left as an exercise for Maple experts). How fast would a loop version be on Mathematica?> 2) Creating a table of consisting of 10,000 repeats of the symbol 'a'. > for i from 1 to 10000 > do x[i]:= a od: Timing[x = Table[ a, {10000} ];] > 3.017s .23sThe same when using "seq" on Maple:---------------------------------------------------------------------- > st := time(): for i from 1 to 10000 do x[i]:= a od: time() - st;1.033> st := time(): x2 := [seq(a, `i`=1..10000)]: time() - st;.067 ----------------------------------------------------------------------The latter version is about 10 times faster than the loop version.> 3) Assigning a to the value 1. > for i from 1 to 10000 do Timing[y = x /. a -> 1;] > y[i]:=subs(a=1,x[i]) od: > 5.533 .35sAnd again:---------------------------------------------------------------------- > st := time(): for i from 1 to 10000 do y[i]:=subs(a=1,x[i]) od: time() - st;1.717> st := time(): y2 := subs(a=1,op(x)): time() - st;.083 ----------------------------------------------------------------------Thus the "seq" version of Maple is about 20 times faster than the loop version.All these times are approximate, of course - they just give some idea of the performance.As demonstrated, giving test results for just a few specific constructs is not very useful and it can be very misleading. Also, one should think about the fairness of the comparisons - one should not compare an efficient construct on one system with an inefficient construct on another system.Best regards,- Juha Haataja