MathGroup Archive 1999

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

Search the Archive

FW: Plotting multiple outputs from cpu intensive functi

  • To: mathgroup at
  • Subject: [mg16933] FW: [mg16745] Plotting multiple outputs from cpu intensive functi
  • From: "Ersek, Ted R" <ErsekTR at>
  • Date: Thu, 8 Apr 1999 02:32:38 -0400
  • Sender: owner-wri-mathgroup at

Recall the recent discussion where Joel asked:

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

We can have some savings if we use a function (foo) that remembers it's
function values and we make sure we sample the second part of (foo) at the
points where it was already computed.  The lines of code below will do this.
As before Sin, Cos are not CPU intensive, but the method will apply to
functions that are.


     {x,0,\[Pi]/2}, PlotDivision->3, MaxBend->25];
  pnts={#,Part[foo[#],2]}&  /@lst;

(* Graphics not shown *)

The only problem with the approach above is that the adaptive sampling
algorithm isn't used for the second function.  I still haven't found a way
to use the samples already computed, and use the plot function to perform
adaptive sampling on the second function where needed.

Joel indicated he would like Wolfram to make the source code available.  I
was thinking something along the same lines.  Actually I don't think anyone
has a legitimate need for the source code to compute things like
LerchPhi[2.3, 1.2, 1/2].  Besides WRI probably keep those algorithms closely
guarded.  But what about functions like Plot, FindRoot, NIntegrate?  Are
they implemented with nothing but Mathematica code?  I don't see why WRI
should not let us have the source code for functions like that.

Ted Ersek

  • Prev by Date: Re: Help needed with List!
  • Next by Date: PoissonDistribution
  • Previous by thread: Re: Plotting multiple outputs from cpu intensive functi
  • Next by thread: ListPlot3D