Re: Howto vonvert a list of functions in a list valued function
- To: mathgroup at smc.vnet.net
- Subject: [mg28300] Re: [mg28253] Howto vonvert a list of functions in a list valued function
- From: "Mark Harder" <harderm at ucs.orst.edu>
- Date: Sat, 7 Apr 2001 03:45:01 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
I just realized that there is a simpler method (letting funlist[x] [[i]]=Sin[x/(2*i) ], for example): nFunc=10; Clear[x, f]; f := Table[Sin[#/(2 i) ], {i, nFunc} ] &; In[620]:=f[x] f[Pi] Out[620]= {Sin[x/2], Sin[x/4], Sin[x/6], Sin[x/8], Sin[x/10], Sin[x/12], Sin[x/14], Sin[x/16], Sin[x/18], Sin[x/20]} Out[621]= {1, 1/Sqrt[2], 1/2, Sin[Pi/8], 1/4*(-1 + Sqrt[5]), (-1 + Sqrt[3])/(2*Sqrt[2]), Sin[Pi/14], Sin[Pi/16], Sin[Pi/18], Sin[Pi/20]} -mark harder -----Original Message----- From: Mark Harder <harderm at ucs.orst.edu> To: mathgroup at smc.vnet.net <mathgroup at smc.vnet.net> Subject: [mg28300] Re: [mg28253] Howto vonvert a list of functions in a list valued function >Thomas, > As you have defined it, funlist is only a list of undefined expressions >f1,f2, etc., i.e. they are *not* functions. To define a mapping as a list >of functions numbered as you wish, I would do this with one function >definition: > >In[426]:= Clear[x]; > nFunc = 10; > f[x_] = Table[ToExpression["f" <> ToString[i] <> "[x]" ], {i, >nFunc} ] > >Out[428]= {f1[x], f2[x], f3[x], f4[x], f5[x], f6[x], f7[x], f8[x], f9[x], >f10[x]} > >or, for example, >In[430]:= f[x_] = Table[ToExpression["Exp[" <> ToString[i] <> " x]" ], {i, >nFunc} ] > f[a] > >Out[430]= >{E^x, E^(2*x), E^(3*x), E^(4*x), E^(5*x), E^(6*x), E^(7*x), E^(8*x), >E^(9*x), E^(10*x)} >Out[431]= >{E^a, E^(2*a), E^(3*a), E^(4*a), E^(5*a), E^(6*a), E^(7*a), E^(8*a), >E^(9*a), E^(10*a)} > >mark harder >harderm at ucs.orst.edu > > >-----Original Message----- >From: Thomas Neff <t.neff at gsi.de> To: mathgroup at smc.vnet.net >To: mathgroup at smc.vnet.net <mathgroup at smc.vnet.net> >Date: Thursday, April 05, 2001 11:11 PM >Subject: [mg28300] [mg28253] Howto vonvert a list of functions in a list valued >function > > >>I have a list of functions, say >> >>funlist = {f1, f2, f3, ..., fn} >> >>I want to construct a function f, so that >> >>f[x] gives the list {f1[x], f2[x], f3[x], ... fn[x]} >> >>f[x_] = funlist[x] doesn't work ;-( >> >>Is there an elegant way to do this in Mathematica ? >> >> >>Thanks >> >>Thomas >> >>-- >>Thomas Neff >>Gesellschaft fuer Schwerionenforschung (GSI) >>Email: t.neff at gsi.de - PGP key available >>WWW: http://theory.gsi.de/~tneff/tneff.html >> >