Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2560

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

From Guillermo Sanchez <guillermo.sanchez@hotmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject The same function the second time evaluated is faster. Why?
Date 2011-05-21 10:47 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ir857q$beh$1@smc.vnet.net> (permalink)

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | NextNext in thread | Find similar | Unroll thread


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