MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Why so slow and not getting faster

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113238] Why so slow and not getting faster
  • From: Sam Takoy <sam.takoy at yahoo.com>
  • Date: Wed, 20 Oct 2010 04:07:21 -0400 (EDT)

Hi,

I ran the following code on two machines (linux and windows) under 
identical versions - 7.0.1.0.

On the windows machine, the code takes 10-15 seconds on each run.

On the linux maxhine, the first run took 6 seconds and all subsequent 
runs are nearly instantaneous (< 1/10 sec).

1. I accept that my windows machine is slower, but why doesn't it show 
similar acceleration in subsequent runs?

2. Even 6 seconds I think is too high. Are these very simple 
integrations for Mathematica?

Many thanks in advance,

Sam


FourierCoefficients[f_, order_] := Module[{first, reim},
   first = 1/(2 \[Pi]) Integrate[f[a], {a, -\[Pi], \[Pi]}];
   Print[first];
   reim = Table[(Print[n];
      1/\[Pi] Integrate[f[a]*E^(I*n*a), {a, -\[Pi], \[Pi]}]), {n, 1,
      order}];
   Join[{first},  Map[ComplexExpand[{Re[#], Im[#]}] &, reim]]]

g[a_] := 1/32 (7 - 11 Cos[2 a] - 8 Cos[4 a] - 3 Cos[6 a])
FourierCoefficients[g, 5]


  • Prev by Date: Re: Correct answer for all n
  • Next by Date: Re: Tree with repeated labels
  • Previous by thread: Re: := vs = in some function definitions
  • Next by thread: Re: Why so slow and not getting faster