MathGroup Archive 2009

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

Search the Archive

SetDelayed and Evaluate

  • To: mathgroup at
  • Subject: [mg104477] SetDelayed and Evaluate
  • From: Peter < at>
  • Date: Sun, 1 Nov 2009 04:02:47 -0500 (EST)

Hi group,

after years of experience with Mathematica I've got a simple (?)

When answering to a question on the student support forum (http:// I tried fo myself
the folowing variants:
and got the following results:
In[6]:= Timing[Do[NMaximize[f[x],x],{1000}]]
Out[6]= {35.871,Null}
In[7]:= Timing[Do[NMaximize[g[x],x],{1000}]]
Out[7]= {35.962,Null}

~1 ms per NMaximize is OK, because there are background-processes

But I expect f to compile x-x^2 at every call to f and g to compile
once on time of definition. Therefore I expected g to be significantly
faster than f.

Where am I wrong?

Peter Pein

  • Prev by Date: Re: Answer for Simplify[Cos[x]^4-Sin[x]^4]?
  • Next by Date: Re: How to calculate a union
  • Previous by thread: Re: Answer for Simplify[Cos[x]^4-Sin[x]^4]?
  • Next by thread: Re: SetDelayed and Evaluate