MathGroup Archive 2006

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

Search the Archive

Re: $RecursionLimit Bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63939] Re: [mg63932] $RecursionLimit Bug?
  • From: Pratik Desai <pdesai1 at umbc.edu>
  • Date: Tue, 24 Jan 2006 01:30:24 -0500 (EST)
  • References: <200601230911.EAA04880@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

W. Craig Carter wrote:

>Hello,
>I am using Mathematica 5.2 on MacOS 10.4.4
>
>I was trying to construct a cannonical timing example by writing
>a memoryless factorial function.
>
>If I do this (fresh kernel):
>
>$RecursionLimit = $IterationLimit = 10^6
>fact[0] = 1;
>fact[n_] := n fact[n - 1]
>Timing[fact[10^6]]
>?fact
>This generates no output, and the ?fact input line becomes In[1], as 
>if the kernel died after Timing[fact[10^5]], but no messages are 
>generated.
>
>If I bury the recursion limit inside a Block, then I get
>fact[0] = 1;
>fact[n_] := n fact[n - 1]
>Timing[Block[{$RecursionLimit = Infinity}, Return[fact[10^5]]]]
>-----> $RecursionLimit::reclim : Recursion depth of 256 exceeded
>?fact (* now is In[1] *)
>-----? Symbol fact not found.
>
>
>Is this a bug?  I couldn't find a list of known bugs on the 
>mathematica site....
>
>
>Thanks, WCC
>
>
>
>W. Craig Carter
>Lord Foundation Professor of Materials Science and Engineering
>MIT, Dept. of Materials Science and Engineering 13-5018  77 Massachusetts Ave, Cambridge, MA 02139-4307 USA
>617-253-6048  ccarter at mit.edu http://pruffle.mit.edu/~ccarter http://pruffle.mit.edu/~ccarter/FAQS/ http://pruffle.mit.edu/~ccarter/I_do_not_use_microsoft.html
>
>  
>
There is an example similar to this in the Mathematic Book in section 2.5.9
2.5.9 Functions That Remember Values They Have Found
Here is one that I modified a bit with RecursionLimit set to infinity

In[27]:=
Clear[f,x]
$RecursionLimit=Infinity
f[x_]:= f[x]=x*f[x- 1]
f[0]=f[1]=1
Timing[f[10^4]]//Short

Out[28]=
â??

Out[30]=
1

Out[31]//Short=
{0.23 Second,2846259\[LeftSkeleton]35645\[RightSkeleton]00000000}

Hope this helps

Pratik


  • Prev by Date: Re: correlated random vector
  • Next by Date: Re: show workings
  • Previous by thread: $RecursionLimit Bug?
  • Next by thread: Re: Re: $RecursionLimit Bug?