MathGroup Archive 2010

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

Search the Archive

manipulate plot

  • To: mathgroup at
  • Subject: [mg107378] manipulate plot
  • From: you can call me al <misterraum at>
  • Date: Thu, 11 Feb 2010 05:18:27 -0500 (EST)

Hi all,
   Often after arriving at the result of some calculation in
Mathematica I have an expression in many variables and would like to
plot the function inside of a manipulate box so that I can observe the
effect of changing the parameters.  To make the discussion here more
concrete let's say I have

y = f(x,a,b)

A natural thing to try to do is something like:


This of course fails to produce output seemingly because Mathematica
can't understand that f is actually an expression in the variables
x,a, and b.  It seems that the only way to get what I'm after is to go
through a lot of syntactic acrobatics geared at turning the results of
my calculations (which are usually just algebraic expressions) into
some sort of function definition.  This is generally a huge pain in
the ass and also tends to clutter and obfuscate the notebook that I'm
working in.  So....

When I'D LIKE to do this:

y = m x;

I MUST INSTEAD do either:

Manipulate[Plot[m x,{x,0,1},PlotRange->{0,2}],{{m,1},0,2}]


y = Function[{m,x},m x];


y[m_,x_] := m x;

or god knows what else...

In the example above the problem doesn't seem so bad but when the
expressions become larger functions of more variables and/or I'm
plotting more than one function then the constructs above start to get
unweildly and I start really wondering why there is no support for me
to type something like:





f1 = Function[{a,b,x},Exp[-(a-b)*x]];
f2 = Function[{a,b,x},Exp[-a*x]Cos[2*Pi*b*x]];
f3 = Function[{a,b,x},Exp[-a*x]Cos[2*Pi*b*x]];


f1[a_,b_,x_] = Exp[-(a-b)*x];
f2[a_,b_,x_] = Exp[-a*x]Cos[2*Pi*b*x];
f3[a_,b_,x_] = Exp[-a*x]Cos[2*Pi*b*x];

I've often wondered if there is something I don't know about this.  If
there are any tricks out there to simplify the use of the
construct i'd really love to hear them.  I think the Manipulate
functionality is VERY attractive but i'm always VERY frustrated that I
usually have to bend over backwards to operate it in anything but the
simplest context.

Thanks in advance,


  • Prev by Date: Re: Question about subscripts and polynomial
  • Next by Date: Re: Weird vanishing syntax coloring
  • Previous by thread: Re: Translating this algorithm into mathematica code
  • Next by thread: Re: manipulate plot