MathGroup Archive 2010

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

Search the Archive

Re: How to Enable Automatic Recalculation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109866] Re: How to Enable Automatic Recalculation
  • From: Victor Roberts <xxx at lighting-research.com>
  • Date: Thu, 20 May 2010 06:39:14 -0400 (EDT)
  • References: <ht1uua$3cf$1@smc.vnet.net>

Thanks Murray.  Dynamic is very close to what I was looking
for.  

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


On Thu, 20 May 2010 00:15:06 +0000 (UTC), Murray Eisenberg
<murray at math.umass.edu> wrote:

>There IS a "simple" answer. Actually, two answers. it used to be that 
>the only way to do this was to use SetDelayed ( := ) for the symbol you 
>wanted to be recalculated whenever you changed another variable whose 
>values was specified by Set ( = ).  Since Mathematica 6, you also have 
>the more sophisticated method of using Dynamic quantities.
>
>    (* method 1: use SetDelayed instead of Set for b *)
>    a = 5;
>    b := 3 + a
>    b
>8
>    a = Pi;
>    b
>3 + Pi
>
>
>   (* method 2: use Dynamic *)
>   Clear[a,b]
>   Dynamic[a]
>a
>   a = 3;  (* preceding output changes to 3 *)
>   b = 3 + a
>6
>   a = Pi;
>   b
>3 + Pi
>
>   (* method 3: another way to use Dynamic *)
>   Clear[a,b]
>   a = 3;
>   Dynamic[b = 3 + a]
>6
>   a = Pi;  (* preceding ouptput changes to 3 + Pi *)
>   b
>3 + Pi
>
>
>
>On 5/19/2010 7:01 AM, Victor Roberts wrote:
>> I'm new to Mathematica, so perhaps there is a simple answer
>> to this question.
>>
>> 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
>>
>> and
>>
>> b = 3 + a
>>
>> I would like the value of b updated each time I change the
>> value of a.
>>
>> 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.
>>
>>
>> --
>> Vic Roberts
>> Replace xxx with vdr in e-mail address.
>>


  • Prev by Date: Re: How to Enable Automatic Recalculation
  • Next by Date: Re: How to Enable Automatic Recalculation
  • Previous by thread: Re: How to Enable Automatic Recalculation
  • Next by thread: Re: How to Enable Automatic Recalculation