MathGroup Archive 2001

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

Search the Archive

RE: Howto vonvert a list of functions in a list valued function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28290] RE: [mg28253] Howto vonvert a list of functions in a list valued function
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 7 Apr 2001 03:44:49 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Thomas,

You want to use the Through command.

funlist = {f1, f2, f3, f4};

funlist[x]
% // Through
{f1, f2, f3, f4}[x]
{f1[x], f2[x], f3[x], f4[x]}

You could make your functions pure functions.

{#1^2 & , 1 + #1 + 2*#1^2 & , 1/(Cos[#1] + 1) & }[x]//Through
{x^2, 1 + x + 2*x^2, 1/(1 + Cos[x])}

However, Through doesn't work well when it is used with a combination of
undefined function names and constants. Through pushes the x only one level
at a time, and onto everything.

{f1, f1 + f2, 1 + a + f1*f2, a*f1*f2^2}[x]
%//Through
Through /@ %

{f1, f1 + f2, 1 + a + f1*f2, a*f1*f2^2}[x]
{f1[x], (f1 + f2)[x], (1 + a + f1*f2)[x],
  (a*f1*f2^2)[x]}
{Through[f1[x]], f1[x] + f2[x], 1[x] + a[x] +
   (f1*f2)[x], a[x]*f1[x]*(f2^2)[x]}

There is a Mathematica package at my web site called Algebra`PushThrough`
which makes it easier to tailor the use of Through.

Needs["Algebra`PushThrough`"]

With PushOnto you can tell Mathematica precisely which names the argument(s)
are to be pushed onto.

{f1, f1 + f2, 1 + a + f1*f2, a*f1*f2^2}[x]
% // PushOnto[{x}, {f1, f2}]

{f1, f1 + f2, 1 + a + f1*f2, a*f1*f2^2}[x]
{f1[x], f1[x] + f2[x], 1 + a + f1[x]*f2[x],
  a*f1[x]*f2[x]^2}

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


> -----Original Message-----
> From: Thomas Neff [mailto:t.neff at gsi.de]
To: mathgroup at smc.vnet.net
> Sent: Friday, April 06, 2001 1:53 AM
> To: mathgroup at smc.vnet.net
> Subject: [mg28290] [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
>



  • Prev by Date: Re: Manipulating Strings
  • Next by Date: Re: C, MathLink or Java, J/Link
  • Previous by thread: Re: Howto vonvert a list of functions in a list valued function
  • Next by thread: Re: Howto vonvert a list of functions in a list valued function