MathGroup Archive 2000

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

Search the Archive

Re: Hold, HoldForm, ReleaseHold when Plotting multiple functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25501] Re: [mg25481] Hold, HoldForm, ReleaseHold when Plotting multiple functions
  • From: Matt.Johnson at autolivasp.com
  • Date: Thu, 5 Oct 2000 23:50:20 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Sean-

No Holds etc are necessary.  When you Map the function over the values, a
list of equations in y alone are returned.  You must simply evaluate these
inside Plot to get the graphics.

In[15]:=
\!\(\(f[x_, y_] := x\^2 + x\ y + y\^2;\)\n
  funs = Map[f[#, y] &, {2, 3, 4, 5}]\)
Out[16]=
\!\({4 + 2\ y + y\^2, 9 + 3\ y + y\^2, 16 + 4\ y + y\^2, 25 + 5\ y + y\^2}\)

Plot[Evaluate[funs], {y, -10, 10}];

produces the desired type of plot.

-matt





Ross Sean Civ AFRL/DELO <Sean.Ross at kirtland.af.mil> on 10/02/2000 08:26:59
PM

cc:

Subject: [mg25501]  [mg25481] Hold, HoldForm, ReleaseHold when Plotting multiple
      functions


I wrote a function called bandwidth and want to print out a number of these
functions on the same graph.  Here is an example:
In[1]:=

Plot[{bandwidth[28.5,x],
  bandwidth[28.7,x],
  bandwidth[28.9,x],
  bandwidth[29.1,x],
  bandwidth[29.3,x],
  bandwidth[29.5,x],
  bandwidth[29.7,x],
  bandwidth[29.9,x]},{x,140,200},
  PlotRange->{-5,5},PlotStyle->Array[Hue[#/9.]&,9]]

Now, I personally think that listing out all those functions is a little
clumsy.  I would rather put some kind of a Map statement as the argument to
Plot.  Here is one that does the trick:
In[2]:=
Map[HoldForm[bandwidth[#,x]]&,{28.5,28.7,28.9,29.1,29.3,29.5,29.7,29.9}]

However, using this code as the argument to Plot generates a lot of error
messages and, ultimately, doesn't work.  I know that the solution has
something to do with Hold, HoldForm, ReleaseHold, Evaluate etc., but I have
never been able to figure out what these things do or figure out which
combination will work.

Here are some combinations I have tried that kind of work:
In[3]:=
Plot[Evaluate[ReleaseHold[Map[HoldForm[bandwidth[#,x]]
&,{28.5,28.7,28.9,29.1
,29.3,29.5,29.7,29.9}]]],{x,140,200},
  PlotRange->{-5,5},PlotStyle->Array[Hue[#/9.]&,9]]
In[4]:=
Plot[Evaluate[ReleaseHold[Map[Hold[bandwidth[#,x]]
&,{28.5,28.7,28.9,29.1,29.
3,29.5,29.7,29.9}]]],{x,140,200},
  PlotRange->{-5,5},PlotStyle->Array[Hue[#/9.]&,9]]

In[3] and In[4] generate lots of error messages and take a long time, but
print out the multiple graph.  I have tried other combinations that don't
work at all.

I would greatly appreciate it if someone could tell me

1) what magic combination of Holds and Releases etc. would generate a
multiple plot in the same time as the explicit version of In[1] and without
generating error messages.  (Please don't refer me to other packages or
other kinds of solutions or approaches like MultipleListPlot or Show.  I
want to understand Holds and this is a good case in point.)
2) how I could have figured out what that magic combination was before hand
by reading the Mathematica Book or something on the Wolfram web site.

Please respond directly to Sean.Ross at kirtland.af.mil as I no longer
subscribe to the mathgroup.


Dr. Sean Ross

AFRL/DELO
3550 Aberdeen Ave. Building 761
Kirtland AFB, NM 87117

Office:    (505) 846-9148
Labs:      (505) 853-6440/846-9289
Fax:        (505) 853-0485
Email:     sean.ross at kirtland.af.mil









  • Prev by Date: Re: Run[] in background (NT)?
  • Next by Date: Re:Mapping down two lists
  • Previous by thread: Hold, HoldForm, ReleaseHold when Plotting multiple functions
  • Next by thread: RE: Hold, HoldForm, ReleaseHold when Plotting multiple functions