RE: Plotting multiple outputs from cpu intensive functi
- To: mathgroup at smc.vnet.net
- Subject: [mg16791] RE: [mg16745] Plotting multiple outputs from cpu intensive functi
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Wed, 24 Mar 1999 17:07:14 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Joel wrote: --------------------------- Say you are using a module to calculate something that takes quite a LONG while. It has 2 or more outputs in an output list, or whatever is convenient: f[x_]:=Module[{...}, ...long cpu intensive stuff...; {out1,out2}] out1 and out2 are calculated together because they are closely related and share a lot of the needed cputime. How would you go about plotting out1 and out2 together in the same graph without duplicating the cputime? -------------------------- Joel, I think you can solve your problem by defining a function that remembers values it has computed. Here is a simple example that doesn't require this trick, but it gets the point across. In[1]:= foo[x_]:=foo[x]={Sin[x],Cos[x]} In[2]:= Plot[{Part[foo[x],1],Part[foo[x],2]},{x,0,4}]; (* Graphic not shown *) Regards, Ted Ersek ------------ See section 2.4.9 in the big book. Paste the code below into a notebook and you will have a hyperlink the right part of the help browser. (be sure to copy the \!\(\* part) \!\(\* ButtonBox[\(2.4 .9\), ButtonStyle->"MainBookLink"]\)