# Map array of functions

What is the most elegant way of mapping an array of functions to an array of arguments of the same length? In practice I want to map {f1,f2,f3} and {x1,x2,x3} to {f[x1],f[x2],f[x3]}. Thanks!

EDIT

I should have mentioned that {f1,f2,f3} are the solutions of a differential equation:

fsol[t_] = Table[First[f[t] /. NDSolve[{f''[t] + m^2 f[t] == 0,
f[0] == c[[i]], f'[0] == cp[[i]]}, f[t], {t,0,1}]], {i,1,3}]


Then the output is something like

{InterpolatingFunction[t],InterpolatingFunction[t],InterpolatingFunction[t]}


When I evaluate fsol[t] for some numerical t I get a numerical array as a result. With the proposed solutions the argument gets appended at the end, but the InterpolatingFunctions are not evaluated at that point.

EDIT 2:

Here is a minimal working example:

c = {1, 2, 3};
fsol = Table[NDSolveValue[{f''[t] + f[t] == 0, f[0] == c[[i]], f'[0] == 0}, f, {t, 0, 5}], {i, 1, 3}]
xtest = {1, 2, 3};


Then MapThread[#1[#2] &, {fsol, xtest}] indeed gives the desired result. The remaining question is, can the same be done with the derivative of fsol? MapThread[#1[#2] &, {fsol', xtest}] doesn't seem to work, since Mathematica doesn't interpret that as the derivative of the components of the array.

• MapThread[#1[#2] &, {{f1, f2, f3}, {x1, x2, x3}}] Mar 14 at 23:06
• Very helpful, but see comment below. Mar 14 at 23:39
• @gabo_18 You mention that {f1,f2,f3} are InterpolatingFunctions returned by NDSolve. In that case you should probably have a look at the alternative NDSolveValue. Mar 15 at 0:12
• A minimal working example would be helpful Mar 15 at 9:29
• …As to EDIT 2: why not MapThread[#1'[#2] &, {fsol, xtest}]? Mar 16 at 2:20

MapThread[Construct, {{f1, f2, f3}, {x1, x2, x3}}]