MathGroup Archive 1999

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

Search the Archive

RE: Plotting multiple outputs from cpu intensive functi

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16816] RE: [mg16745] Plotting multiple outputs from cpu intensive functi
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Tue, 30 Mar 1999 02:35:17 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

After considering comments from Wolf Hartmut and Allan Hayes I see the
solution I had earlier (see the discussion below) does little if any good.
With that in mind I can't find a clever solution, but I do have a small
suggestion.

When plotting CPU intensive function(s) you can save time by using different
settings for some of the plot options.  Consider the settings used below.
They make respectable plots, and take fewer samples than when you use the
default options.


Plot[Tan[x],{x,0,Pi},
 PlotDivision->3, MaxBend->25.];


Plot[Sin[x],{x,0,4Pi},
 PlotDivision->3, MaxBend->25.];


Notes:
The sampling algorithm will take lots of samples where the function
derivative is zero or infinite, or where the function has a discontinuity.
That's provided you don't use options to prevent or minimize this tendency.


MaxBend is the angle (in degrees) formed by three consecutive samples. The
angle is computed by fitting the three points into a rectangle with
AspectRatio=1.


Plot also has a PlotPoints option that might interest you.

----------
Regards,
Ted Ersek

----------------------------------
> 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


  • Prev by Date: Re: curve fiting
  • Next by Date: Re: another set of global variables
  • Previous by thread: RE: Plotting multiple outputs from cpu intensive functi
  • Next by thread: Re: Plotting multiple outputs from cpu intensive functi