MathGroup Archive 2011

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

Search the Archive

Re: The same function the second time evaluated is faster. Why?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119126] Re: The same function the second time evaluated is faster. Why?
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Sun, 22 May 2011 06:56:57 -0400 (EDT)

----- Original Message -----
> From: "Guillermo Sanchez" <guillermo.sanchez at hotmail.com>
> To: mathgroup at smc.vnet.net
> Sent: Saturday, May 21, 2011 5:47:34 AM
> Subject: [mg119076] The same function the second time evaluated is faster. Why?
> Dear gurus?
> 
> I evaluate the below function ,
> 
> Int[1]:=1+1
> 
> Int[2]:=Timing[(f2[x1_] := Integrate[Sin[x^3], {x, 0, x1}];
> f2[Range[10]]);]
> Out[2]:= {12.261, Null}
> 
> I repeat the evaluation is faster
> 
> Out[2]:={1.389, Null}
> 
> and the third faster
> 
> Out[3]:= {0.281, Null}
> 
> Even writting f3 instead f2
> 
> Timing[(f3[x1_] := Integrate[Sin[x^3], {x, 0, x1}]; f3[Range[10]]);]
> {0.281, Null}
> 
> Why the second and third evaluation are faster?
> 
> Guillermo

Cache effects. See

http://forums.wolfram.com/mathgroup/archive/2010/Jan/msg00253.html

Daniel Lichtblau
Wolfram Research




  • Prev by Date: Re: how do I plot many points?
  • Next by Date: Re: Overloading functions
  • Previous by thread: Re: The same function the second time evaluated is faster. Why?
  • Next by thread: how do I plot many points?