MathGroup Archive 1996

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

Search the Archive

Re: Re-evaluation of Conditional expressions, wrong explanation

  • To: mathgroup at
  • Subject: [mg3482] Re: Re-evaluation of Conditional expressions, wrong explanation
  • From: fateman at (Richard J. Fateman)
  • Date: Sat, 16 Mar 1996 22:39:07 -0500
  • Organization: University of California, Berkeley
  • Sender: owner-wri-mathgroup at

In article <4i5q7t$rtt at>,
David Withoff <withoff at> wrote:

((example omitted, see below))

Sorry David, it seems to me your explanation below doesn't wash.
>This and similar situations represent the entire purpose of Update.
>Once an expression has evaluated to itself, Mathematica will not
>re-evaluate the expression unless something inside the expression
>changes.  In this example, nothing inside If[x,1,2] changed, so
>the expression is not re-evaluated.  This is an important optimization,
>and is exactly what you want in the vast majority of cases.  The
>Update function is included for those rare situations when you
>want an expression to be re-evaluated even though nothing inside
>the expression has changed.
>Dave Withoff
>Research and Development
>Wolfram Research

Any explanation must, in particular, explain why "If" differs from


In[3]:= y=If[z,1,2]

Out[3]= If[z, 1, 2]

In[4]:= z=True;y

Out[4]= 1   /* thus z is evaluated and inserted into y */

In[5]:= z=ww;y  /* this is EXACTLY the same form with ww <->True */

Out[5]= If[z, 1, 2]  /* thus z is NOT evaluated to ww and inserted into y */

Now, just remove all the capital I's there.  That is, change If to f.

In[15]:= Clear[x,z,y]

In[16]:= y=f[z,1,2]

Out[16]= f[z, 1, 2]

In[17]:= z=True;y

Out[17]= f[True, 1, 2]

In[18]:= z=ww;y

Out[18]= f[ww, 1, 2]  /*  ... compare this to Out[5] */

Evaluation in Mathematica is rather subtle. The vast majority of
people who use Mathematica don't understand it completely.
Fortunately they usually don't need to understand it.

I know of no written complete official public explanation of
Mathematica's evaluation process.  Perhaps it is considered a
trade secret.

Richard J. Fateman
fateman at


  • Prev by Date: Re: Re-evaluation of Conditional expressions
  • Next by Date: Re: Mathematica and Windows 95 in Windows-Network
  • Previous by thread: mathematica vs.mathcad vs. maple
  • Next by thread: Re: Re: Re-evaluation of Conditional expressions, wrong explanation