Written sometime in 2005? I should really record the time when I write something.
I just run these now, August 2014, and now Maple 18 as very fast. So this all below is no longer valid. I will leave it here for now for reference until I update it all later
I have written a few lines of code, which counts how many times each digit occurs after the decimal points of \(\pi \)
Written this in maple first. Then did similar thin in mma 5.0. Both are run on the same PC. No other applications are running at the time when I run the code.
The basic idea of the algorithm is to use evalf(Pi,digits) in maple to find \(\pi \) for any
number of decimal digits, and to use N[Pi,digits] in mma for doing the same. (Where
the variable digits above is the number of digits)
Then in maple convert the above \(\pi \) to a string, and generate a sequence of the characters
to right of decimal point, then use stats[transform,tally] to do the actual
counting.
In mma, I use RealDigits[] to get a list of the digits, and then use Count[] to do the
counting.
This is result of some of the runs to find Pi to some digits, and the total time (to find Pi and do the counting)
All times are in cpu seconds, machine is P4, 2.8 Ghz, 500 MB of RAM, single CPU, hyperthreading enabled, running XP home edition. Maple 9.03 student version, and mma 5.0 student version.
Below is the result, and below that I show the maple code and the mma code.
Because of this, before each run in mma, I exited the application and started it fresh. In maple, it does not matter for the above reason.
Mma is 60 times faster in finding pi and about 56 times faster overall
Mma is 300 times faster in finding Pi, and 130 times faster overall.
Maple code
> restart; startingTime :=time(); L:=evalf(Pi,100000): timeToFindPiInSecs:=time()-startingTime; S:=convert(L,string): the_list:=[seq(parse(S[i]),i=3..length(S))]: stats[transform,tally](the_list); endingTime :=time(): cpuTimeInSecs := endingTime - startingTime;
mma code
Clear[] startingTime=TimeUsed[] t1=N[Pi,100000]; timeToFindPiInSecs=TimeUsed[]-startingTime {c,d}=RealDigits[t1]; theList=c[[Range[2,Length[c]]]]; f[digit_]:=Count[theList,digit]; r=Range[0,9]; Map[f,r] cpuTimeInSecs=TimeUsed[]-startingTime
update 12/25/03 Changed maple code on how to do the counting : To use
Now the counting in maple is much faster. It is always hard to know which is the best function to use.