Prev: Need to align data from sublists to Union of dates from all sublists
Next: Inverse of a six-parameter asymmetric sigmoidal curve
From: mathfanda on 22 Jul 2010 05:44 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
From: Bruno Campanini on 23 Jul 2010 07:11 "mathfanda" <KKratky(a)seznam.cz> wrote in message news:i293uc$mck$1(a)smc.vnet.net... > 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. [...] My results: 7.0 for Microsoft Windows (64-bit) (November 11, 2008) c[4]=-(38475/16384) time=24.217 memory=142.09 MB Winserver 2008 R2 64-bit, 4Gb RAM Very bad indeed! Bruno
From: juan flores on 24 Jul 2010 05:05 On a Mac, -------- 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) c[4]=-(38475/16384) time=6.2792 memory=140.069 MB -------- Results depend on how busy your computer is. The above results were gotten on a fresh kernel running nothing else, but Mathematica. Also, TimeUsed[] gives the total number of seconds of CPU time used so far in the current Mathematica session. So, results will vary if you run it twice or later on a non-fresh kernel session. Just some thoughts. Juan On Jul 23, 6:11 am, "Bruno Campanini" <bruno...(a)libero.it> wrote: > "mathfanda" <KKra...(a)seznam.cz> wrote in message > > news:i293uc$mck$1(a)smc.vnet.net... > > > 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. > > [...] > > My results: > > 7.0 for Microsoft Windows (64-bit) (November 11, 2008) > c[4]=-(38475/16384) > time=24.217 > memory=142.09 MB > > Winserver 2008 R2 64-bit, 4Gb RAM > > Very bad indeed! > > Bruno
From: David Skulsky on 24 Jul 2010 05:09 On Jul 22, 2:44 am, mathfanda <KKra...(a)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
From: Pavel Pokorny on 25 Jul 2010 01:57
A big surprise is that Mathematica 5.2 performs much better than Mathematica 7.0. The difference becomes more important if you want to compute more coefficients. Pavel |