MathGroup Archive 1998

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

Search the Archive

Re: Plotting vector-valued functions

Malcolm Boshier wrote:

> suppose that f[z] returns the eigenvalues of a 5 x 5
> matrix which is a function of z.  In general this function cannot be
> evaluated without a value for z, so
> Plot[ Evaluate[f[z]], {z, zmin, zmax}] doesn't work.
>     The only way around this that I have found is something like:

> Plot[{f[z][[1]],  f[z][[2]], f[z][[3]], f[z][[4]], f[z][[5]]}, 

>     {z, zmin, zmax}]

> which of course requires 5 evaluations of f[z] for each value of z.

This is inevitable if you simply use Set or SetDelayed in your
definition   of the function f:

     f[z_] = <stuff>


     f[z_] := <stuff>

Try instead

     f[z_] := f[z] = <stuff>

This syntax causes Mathematica to remember each value it computes for f.
See Section 2.4.9 or The Book.

--Lou Talman

  • Prev by Date: Re: ReplacePart?
  • Next by Date: Drawing multiple curves with ParametricPlot3D
  • Prev by thread: Re: Plotting vector-valued functions
  • Next by thread: Re: Plotting vector-valued functions