Re: surprising comparison of Mathematica 5.2 and 7.0

*To*: mathgroup at smc.vnet.net*Subject*: [mg111238] Re: surprising comparison of Mathematica 5.2 and 7.0*From*: David Skulsky <edskulsky at gmail.com>*Date*: Sat, 24 Jul 2010 05:09:21 -0400 (EDT)*References*: <i293uc$mck$1@smc.vnet.net>

On Jul 22, 2:44 am, mathfanda <KKra... at seznam.cz> wrote: > Dear Mathematica friends, > > the following program runs 4.7 times faster and uses 22.7 times less > memory > in Mathematica 5.2 than in Mathematica 7.0. > Fortunately, it gives the same result. > > ClearAll["Global`*"]; > c[1] = 2; > Table[ > a = Sum[c[i] r^i,{i,1,n}] + O[r]^(n+1); > s = 4(1-1/(1+1/3+r-a*Cos[2t]))//Normal//TrigReduce; > Table [ b[2i]= Coefficient[s,Cos[2i*t]]/2,{i,n}]; > b[0] = s-2*Sum[b[2i]*Cos[2i*t],{i,n}]//Simplify; > b[x_?OddQ]=0; > m=Table[If[i==j,b[0]-(n+1-i)^2,b[Abs[i-j]]],{i,2n+1},{j,2n+1}]; > m=Simplify[m]; > d=Det[m]+O[r]^(n+1)//Simplify//Normal; > c[n-1]=c[n-1]/.First[Solve[d==0,c[n-1]]]; > ,{n,3,5}]; > Print[$Version]; > Print["c[4]=",c[4]]; > Print["time=",TimeUsed[]]; > Print["memory=",MaxMemoryUsed[]/2^20.," MB"]; > > Here are the results: > > 5.2 for Linux x86 (64 bit) (June 20, 2005) > 38475 > c[4]=-(-----) > 16384 > time=0.98 > memory=6.07137 MB > > 7.0 for Linux x86 (64-bit) (February 18, 2009) > 38475 > c[4]=-(-----) > 16384 > time=4.61 > memory=136.313 MB > > The conclusion might be: do not uninstall Mathematica 5.2 yet :-) > Or am I wrong? > > Pavel TimeUsed[] doesn't seem like the right choice to evaluate speed (it's the total number of seconds of CPU time used in the current session). On my machine, the timing result increases every time I run your example. Why not use AbsoluteTiming instead? There may be a similar issue with how you're evaluating memory usage, but I'm not sure. David