I need to evaluate an expression, sum in this case, involving an arbitrary function. Below is a simplified version of what I wanted to do:
points = {1.3, 2.4};
f1[g_] = g^2 + 1;
f2[g_] = Sum[f1[g[points[[i]]]], {i, 2}];
I want to be general so g is an arbitrary function. It works for simple functions, for example, if I want g[x]=Sin[x], then
f2[Sin]
gives the correct answer 3.38469. My problem is, in the actual code, g is much more complicated. A simpler example will suffice. If I want g[x]=Sin[x]+Cos[x], then the following does not work:
f2[Sin +Cos]
Will be glad if someone can help or give a useful hint. Thank you in advance!
g
, usingFunction
or&
. For instance, tryf2[Sin[#] + Cos[#]&]
. $\endgroup$