MathGroup Archive 2007

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

Search the Archive

Evaluate, Replace, and Hold

This is a newbie question. I have a parametric form of a model and I
would like to evaluate it with different parameters on a list of

model = a x + b;

Different sets of parameters:

p1 = {a->1, b->0};
p2 = {a->1, b->1};

x for which I'd like to evaluate the model:

pts = Range[10];

I would like to define a function to evaluate the model at pts using
any of the sets of paramters:

f[pts, p1]
f[pts, p2]

I would also like it to work for single points:

f[1, p1]
f[2, p1]

I've tried various forms for a function definition that dont work. I
can do the following for a particular set of parameters:

Function[{x}, Evaluate[model /. p1]] /@ pts

but how can I turn it into a function of also the parameters. The
below doesn't work, for example:

f[pts_, p_]:=Function[{x}, Evaluate[model /. p] ] /@ pts

What I know is from descending the documentation tree (v6.0) starting
from the examples in FindFit. I have a fundamental misunderstanding of
replacement rules and delayed evaluation.


  • Prev by Date: Unable to copy graphics from Mathematica 6 to Publicon
  • Next by Date: Fun with zero sums
  • Previous by thread: Re: Unable to copy graphics from Mathematica 6 to Publicon
  • Next by thread: Re: Evaluate, Replace, and Hold