MathGroup Archive 2007

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

Search the Archive

Evaluation in Mathematica: Until no rules apply? Or until the expression

The documentation says:

"As discussed in "Principles of Evaluation", Mathematica follows the 
principle that each expression is evaluated until no further definitions 
apply. This means that Mathematica must continue re-evaluating results 
until it gets an expression which remains unchanged through the 
evaluation procedure. "

This is not very clear.  Does Mathematica evaluate the expression until 
no rules apply?  Or does it stop when application of a rule does not 
change the expression any more?

A few examples:

a := a
a // Trace

Out[2]= {}

b[x] := b[x]
b[x] // Trace

Out[4]= {b[x], b[x]}

c[p_] := c[p]
c[x] // Trace

During evaluation of In[5]:= $IterationLimit::itlim: Iteration limit of 
4096 exceeded. >>

Out[6]= {c[x],c[x],c[x],c[x],c[x], ... (and so forth)

d[x /; True] := d[x]
d[x] // Trace

Out[8]= {d[x], d[x]}

e[p_ /; p===x] := e[x]
e[x] // Trace

Out[10]= {e[x], {x===x, True}, e[x], {x===x, True}, e[x]}

Could someone explain how Mathematica decides when to finish the 
evaluation of an expression?


  • Prev by Date: Re: rule based program for "Deleting repeated members of a list."
  • Next by Date: Re: HELP: How to do count to the SUB-LIST
  • Previous by thread: Background Color for a Panel
  • Next by thread: Implicit plotting issues