Re: local variables - Module, For loop

*To*: mathgroup at smc.vnet.net*Subject*: [mg113092] Re: local variables - Module, For loop*From*: Sebastian Schmitt <sschmitt at physi.uni-heidelberg.de>*Date*: Tue, 12 Oct 2010 13:51:23 -0400 (EDT)

Bill Rowe wrote: > In[5]:= Timing[Sum[k, {k, n}]] > > Out[5]= {0.393106,500000500000} > > In[6]:= Timing[Sum[k, {k, m}] /. m -> n] > > Out[6]= {0.08371,500000500000} > > Each code snippet does exactly the same thing and produces > exactly the same sum. But as you can see, using For is the > slowest method. Dear Bill! Thank you very much for your detailed answer! Interesting that the last version is so much faster. Is it only due to numeric vs. algebraic? Cheers, Sebastian