Re: hung for good?

• To: mathgroup at smc.vnet.net
• Subject: [mg23602] Re: [mg23592] hung for good?
• From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
• Date: Wed, 24 May 2000 02:16:04 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

on 5/22/00 7:12 AM, Matt Enlow at matt at enlow.net wrote:

>
> Is it possible to give Mathematica (4.0) an expression to evaluate that will
> send it into an infinite loop? (The evaluation itself does not contain any
> loops.) Or does it have some way of knowing when it's "stuck"? I realize
> some evaluations may take a very long time... but is there some way of
> knowing whether any progress is being made while I'm waiting?
>
>
> Matt Enlow
> Bridgeport, CT
>
>
It is difficult to enter an infinite loop in in the ordinary sense in
Mathematica because of the \$IterationLimit global variable, which is by
default set to the value

In[14]:=
\$IterationLimit

Out[14]=
4096

This stops you from getting into infinite loops like this one:

In[15]:=
x := y; y := x;

In[16]:=
x

\$IterationLimit::"itlim" : "Iteration limit of 4096 exceeded."

Out[16]=
Hold[x]

(Of course you can set \$IterationLimit to Infinity and then this
protection will be gone).

However there is nothing to prevent you from starting computations that run
for ever and which are not strictly infinite loops, for example, the
following trivial one:

In[17]:=
FixedPoint[(x = # + 1) &, 1]

Once this starts running you can inspect the current value of x by choosing
Kernel>Evaluation>Enter Subsession and evaluating x:

(Dialog) In[18]:=
x

(Dialog) Out[18]=
520018

You can continue the computation by choosing Kernel>Evaluation>Exit
Subsession and (usually) abort it by choosing next Kernel>Abort Evaluation.

--
Andrzej Kozlowski
Toyama International University, JAPAN

For Mathematica related links and resources try:
<http://www.sstreams.com/Mathematica/>

• Prev by Date: AW: Reverse Axis
• Next by Date: Re: BarChart Bug?
• Previous by thread: hung for good?
• Next by thread: long-time calculation