*To*: mathgroup@smc.vnet.net*Subject*: [mg10525] Re: [mg10456] Plotting vector-valued functions*From*: Lou Talman <me@talmanl.mscd.edu>*Date*: Tue, 20 Jan 1998 02:23:12 -0500

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