Re: Calculate the first time, not each time (?)
- To: mathgroup at smc.vnet.net
- Subject: [mg94577] Re: Calculate the first time, not each time (?)
- From: Szabolcs <szhorvat at gmail.com>
- Date: Tue, 16 Dec 2008 06:04:39 -0500 (EST)
- References: <gi7ljg$cui$1@smc.vnet.net>
On Dec 16, 8:33 am, Michael Young <michaelcharlesyo... at earthlink.net> wrote: > Hello, > > I'm doing some engineering which will involve a large number of points = > -- and I anticipate time problems if all steps are repeated for each > one. Here's an outline of the way I'd like to approach it. > > shapeprimativeXvalues := N[Table[functionpX[v], {v, vlimit}]] > shapeprimativeYvalues := N[Table[functionpY[v], {v, vlimit}]] > > Arriving at these will involve some calculation, and once the results > are in, it is unnecessary that the this be repeated when the values > are used. > > adaptshapetoitslocation[v_] := (various operations on or including) > shapeprimativeXvalues[[v]] (and or) shapeprimativeYvalues[[v]] > > Is there a way I can instruct Mathematica to evaluate a table, (value > or function), once, when it is first called; then not to evaluate it > again, but to pass numerical results on request? Use = instead of := in the assignment. Read about the difference between Set (=) and SetDelayed (:=) in the manual. This is an essential distinction in Mathematica.