Re: Yet more Timing[10000!] ...
- To: mathgroup at yoda.physics.unc.edu
- Subject: Re: Yet more Timing[10000!] ...
- From: Jerry Keiper <keiper>
- Date: Sat, 2 Jul 1994 17:13:07 -0500
> When I do the same test on $Version "DEC OSF/1 Alpha 2.2 > (March 17, 1994)" running on a DEC 3000 Model 400 the > results are even more bizarre. The first time I enter > Timing[10000!] > I get the result > {3.55 Second, 2846...0000} > about 15-20 seconds later, and then if I enter the command > again, I get > {0. Second, 2486...0000} > about 15-20 seconds later. > What is this Timing command playing at? It appears more > like a random number generator, or is it just because I'm > asking it to do this on a Friday afternoon? Timing[ ] measures how long it took to calculate the answer. It does not include the time it takes to format the result. If you want to avoid the formatting you can do In[1]:= Timing[10000!;] Out[1]= {32.3333 Second, Null} Moreover, there are many things that are cached the first time they are calculated and then the cached value is used subsequently. For example, a sparse table of factorials is cached: In[2]:= Timing[10000!;] Out[2]= {0. Second, Null} Bernoulli and Euler numbers are also cached. Numerical approximations to mathematical constants such as Pi, E, EulerGamma, etc. are cached. In[7]:= Timing[N[Pi, 5000];] Out[7]= {8.03333 Second, Null} In[8]:= Timing[N[Pi, 5000];] Out[8]= {0. Second, Null} (Of course if the cached approximation is of lower precision than the new requested value then the cache cannot be used and the new higher-precision value gets cached in place of the old value.) In[9]:= Timing[N[Pi, 5020];] Out[9]= {8.1 Second, Null} Finally, there are some things, like the weights and abscissae for Gaussian quadrature that are cached, but may be overwritten with other values if the number of abscissae gets changed. Jerry B. Keiper keiper at wri.com Wolfram Research, Inc.