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

• To: mathgroup at smc.vnet.net
• Subject: [mg82206] Evaluation in Mathematica: Until no rules apply? Or until the expression
• From: Szabolcs Horvát <szhorvat at gmail.com>
• Date: Sun, 14 Oct 2007 06:22:13 -0400 (EDT)

```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:

In:=
a := a
a // Trace

Out= {}

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

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

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

During evaluation of In:= \$IterationLimit::itlim: Iteration limit of
4096 exceeded. >>

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

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

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

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

Out= {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?

--
Szabolcs

```

• 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