MathGroup Archive 2006

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

Search the Archive

Re: Recalculating values in tables?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63905] Re: Recalculating values in tables?
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sat, 21 Jan 2006 01:50:55 -0500 (EST)
  • References: <dqqbtt$lu1$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

AES schrieb:
> If I'm evaluating a table with something like
> 
>  Table[ {initialExpressions; f1, f2, Sqrt[(f1-f2)/(f1*f2)}, {iterator} ]
> 
> where  f1, f2, f3  are slow-to-evaluate functions (possibly with 
> explicit variables, which will be the same for all three calls to the 
> f's), I'm tempted to assume that Mathematica will be smart enough to 
> evaluate  f1, f2 and f3 just once, not three times, for each line in the 
> Table.  Is this low risk?
> 
> Or should I always take the messier of route of coding these functions 
> explicitly in my initialExpressions using something like
> 
>  Table[ { initialExpressions;
>             g1=f1;
>             g2=f2;
>             g3=f3;
>             g1, g2, Sqrt[(g1-g2)/(g1*g2)}, {iterator} ]
> 
> Just wondering how far to trust Mathematica in situations like this?
> 

Hi AES,

  if I understand you correctly, you want

Table[
   Module[{g1,g2,g3},
     initialExpressions;
     {g1,g2,g3}={f1,f2,f3};
     {g1, g2, Sqrt[(g1-g2)/(g1*g2)]}],
  {iterator}]
?

Peter


  • Prev by Date: Re: Getting the value of the independent var from the dep.var using NDSolve
  • Next by Date: Re: Recalculating values in tables?
  • Previous by thread: Re: Question about Reduce
  • Next by thread: Re: Recalculating values in tables?