MathGroup Archive 1998

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

Search the Archive

Re: Plotting vector-valued functions



hi,
In[16]:=f[z_] := Eigenvalues[{{z, 1, 4}, {7, z - 1, -1}, {3, 0, 2 - z}}]
In[17]:=Table[f[z],{z,0.,3.,.1}]

this works :


In[18]:=Plot[Evaluate@f[x],{x,-14,14}]

have you checked if your data are reals and not complex numbers? Even if
they turn out real, you might need Chop to get rid of small imaginary
parts.

wouter.
 



At 04:34 16-01-98 -0500, Malcolm Boshier wrote:
>    I have a problem which is related to the recent thread about
>plotting lists of functions.  In the case when a vector-valued function
>is expensive or impossible to Evaluate before plotting, Plot apparently
>forces you to evaluate the function repeatedly at each value of the
>independent parameter.  This can be very inefficient.
>    As an example, 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.
>    It seems that unless the head of the first argument to Plot is List,
>Plot assumes that it will evaluate to a real number and returns with an
>error if it later finds that it doesn't.  Why can't Plot trust the user
>long enough to discover that the function will evaluate to a list?
>Thanks for any solutions or explanations, Malcolm
>
>
>
>
Dr. Wouter L. J. MEEUSSEN
w.meeussen.vdmcc@vandemoortele.be
eu000949@pophost.eunet.be




  • Prev by Date: MathLive Professional and Mathematica 3.01
  • Next by Date: Re: lists
  • Prev by thread: Re: Plotting vector-valued functions
  • Next by thread: Re: Plotting vector-valued functions