Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2586
| From | Joseph Gwinn <joegwinn@comcast.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: The same function the second time evaluated is faster. Why? |
| Date | 2011-05-22 10:53 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <irapvg$lku$1@smc.vnet.net> (permalink) |
| References | <ir857q$beh$1@smc.vnet.net> |
In article <ir857q$beh$1@smc.vnet.net>,
Guillermo Sanchez <guillermo.sanchez@hotmail.com> wrote:
> 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
Because Mathematica caches intermediate results.
Joe Gwinn
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
The same function the second time evaluated is faster. Why? Guillermo Sanchez <guillermo.sanchez@hotmail.com> - 2011-05-21 10:47 +0000 Re: The same function the second time evaluated is faster. Why? Joseph Gwinn <joegwinn@comcast.net> - 2011-05-22 10:53 +0000
csiph-web