Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2010

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

Search the Archive

Re: How to Enable Automatic Recalculation

  • To: mathgroup at
  • Subject: [mg109876] Re: How to Enable Automatic Recalculation
  • From: Victor Roberts <xxx at>
  • Date: Thu, 20 May 2010 07:29:30 -0400 (EDT)
  • References: <ht33if$hfb$>

On Thu, 20 May 2010 10:40:15 +0000 (UTC), Bill Rowe
<readnews at> wrote:

>On 5/19/10 at 7:01 AM, xxx at (Victor Roberts)
>>I'm new to Mathematica, so perhaps there is a simple answer to this
>>How to I set Mathematica so that when I change the value assigned to
>>a variable it will automatically change all later calculations that
>>use that variable.
>>For example, if I set
>>a = 5
>>b = 3 + a
>>I would like the value of b updated each time I change the value of
>>Right how, I need to recalculate each and every expression that uses
>>the variable a if I change its value.  There must be a better way.
>It is a little unclear as to exactly what you want when you say
>you want "the value of to be updated each time I change the
>value of a". One way to interpret this would be that you want
>computations made before a was changed to update when a is
>changed. If so, you will need to have a, b and the other
>expressions that depend on a in a dynamic module.
>Another way to interpret what you want is as saying you want
>computations made after a is changed to reflect the new value.
>This is much simpler to implement. All you need do is define
>those operations using SetDelayed rather than Set. For example:
>In[1]:= a = 5;
>b := a + 3
>{a, b}
>Out[3]= {5,8}
>In[4]:= {a = 4, b}
>Out[4]= {4,7}
>SetDelayed causes the evaluation of b to be delayed until it is
>used. So, any use of b when defined with set delayed will
>reflect the value of a at the time b is used. Contrast that with
>c defined below with Set
>In[5]:= c = a + 5;
>{a, c}
>Out[6]= {4,9}
>In[7]:= {a = 5, c}
>Out[7]= {5,9}
>Here, c is unchanged even though a is changed.
 I want to thank everyone for their help.

I just "discovered" that the Evaluation tab has a number of
options, including Evaluate Notebook, which does exactly
what I was asking about, although by the wrong name for
Mathematica.  However, I am also learning that I probably do
not want to reevaluate the whole notebook very often, which
is why there does not seem to be any way to have automatic
reevaluation of the whole notebook each time I change

I've also learned that differences between the user
interface of Mathematica and the user interface of the math
program I had been using for years mean that I do not need
an "automatic recalculation" or, more properly in
Mathematica, an "automatic reevaluation" option as often.
The other program used the values of variables based on
their position on the worksheet.  To change the value of a
variable used in some function, I needed to go back and edit
the value where it appeared on the worksheet before the
function was called.  

Mathematica, on the other hand, uses the value of a variable
that was entered last.  So, I can just move ahead with a new
value for some variable, and then reevaluate the function
that uses that variable, and that leaves me with both the
old and new answers in the notebook, which is great. 

Thanks again.

Vic Roberts
Replace xxx with vdr in e-mail address.

  • Prev by Date: Re: an attempt at solid modeling with Mathematica
  • Next by Date: Re: Read/Write streams in parallel
  • Previous by thread: Re: How to Enable Automatic Recalculation
  • Next by thread: Re: How to Enable Automatic Recalculation