MathGroup Archive 2006

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

Search the Archive

Re: Making plots using transformation rules

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71950] Re: Making plots using transformation rules
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 5 Dec 2006 06:04:54 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <el128e$5h8$1@smc.vnet.net>

amannuc at yahoo.com wrote:
> I've read about making plots of functions, for example:
> 
> Plot[Evaluate[f[x]], {x, 0, 10}]
> 
> I don't have this sort of function to plot. Because it involves
> derivatives, I only get numerical output after defining a
> transformation rule. A simple example (not the real one) is the
> following:
> 
> g[t_] := D[t^2, t]
> g[t] /. t -> 1
> 
> I cannot evaluate g[1], because then Mathematica thinks I am trying to
> take a derivative with respect to the number 1, and flags that as
> error. So I need the transformation rule to get function values.
> 
> What is the best way to plot g[t]? I am looking to create multiple
> transformation rules that replace the argument t with a reasonable
> range of values. Then I can plot g[t] versus t. Plot will not do this
> directly because it takes variable values as input. However, as I've
> said, the construction g[x] (x = some number) flags an error.
> 
> Thanks for your help.
> 

If the argument is always a number, you could define g[t] with a Set 
rather than a SetDelayed, or evaluate the derivative directly within the 
plot command.

In[1]:=
g[(t_)?NumberQ] = D[t^2, t];
g[1]
Plot[g[x], {x, 0, 10}]

Out[2]=
2

Out[3]=
Graphics

In[4]:=
Plot[Evaluate[D[t^2, t]], {t, 0, 10}]

Out[4]=
Graphics

Regards,
Jean-Marc


  • Prev by Date: Re: Area of ellipse between major axis and ray through focus, given angle
  • Next by Date: Re: Re: Pythonika: Python in Mathematica
  • Previous by thread: Re: Making plots using transformation rules
  • Next by thread: RE: Making plots using transformation rules