MathGroup Archive 2000

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

Search the Archive

Re: best solution?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22907] Re: [mg22899] best solution?
  • From: Hartmut Wolf <hwolf at debis.com>
  • Date: Thu, 6 Apr 2000 02:04:27 -0400 (EDT)
  • Organization: debis Systemhaus
  • References: <200004050241.WAA01036@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Peter Weijnitz schrieb:
> 
> I have a function e.g F[a,b,c,x] =a Sin[b x +c]  and a number of parameter
> triplets
> k={{a1,b1,c1},{a2,b2,c2},{a3,b3,c3},....}.
> I would like to feed my function the parameter values in an good and simple
> way, how?
> 
> (Picking out the elements like k[[3,2]]=b3 e.t.c is not what I want.)


Dear Peter,

if you have your function defined as 

F[a_, b_, c_, x_] := a Sin[b x + c]

k = {{a1, b1, c1}, {a2, b2, c2}, {a3, b3, c3}}

then ...

In[2]:= F[##, x] & @@@ k
Out[2]= {F[a1, b1, c1, x], F[a2, b2, c2, x], F[a3, b3, c3, x]}

... is a way to do it. If you define F as

F[a_, b_, c_][x_] := a Sin[b x + c]

In[3]:= Through[(F @@@ k)[x]]
Out[3]= {F[a1, b1, c1][x], F[a2, b2, c2][x], F[a3, b3, c3][x]}

... or  as

F[x][a, b, c] := a Sin[b x + c]

In[4]:= F[x] @@@ k
Out[4]= {F[x][a1, b1, c1], F[x][a2, b2, c2], F[x][a3, b3, c3]}

(If you don't have version 4, then replace @@@ by the alternative
input form:

In[5]:= Hold[F[x] @@@ k] // InputForm
Out[5]//InputForm=
Hold[Apply[F[x], k, {1}]]
)

If you define your F as 

F[{a_, b_, c_}, x_] := a Sin[b x + c]

then

In[7]:= F[#, x] & /@ k
Out[7]= {F[{a1, b1, c1}, x], F[{a2, b2, c2}, x], F[{a3, b3, c3}, x]}

etc, etc. So far there is no "best" (would depend one finer details 
not specified here).

Hartmut


  • References:
  • Prev by Date: Parallel programming.
  • Next by Date: Re: Edit Mathematica graphics in Adobe
  • Previous by thread: best solution?
  • Next by thread: Re: best solution?