Implicitly, this works best if you express $h$ as a pure function, but it's relatively straightforwards. If you are interested in evaluating the integral from $a$ to $b$ precisely once, then this should work:
f[h_] := f[h] = Function[{a,b},Evaluate[Integrate[h[x],{x,a,b}]]];
This defines f
as a function which takes a parameter h
(which will need to be a function itself to work properly), and then memoizes its result. Its result is a function representing the evaluated integral of h[x]
, to within Mathematica's abilities.
For example, f[Sin]
(note that this is not f[Sin[x]]
) will return:
Function[{a$,b$}, Cos[a$] - Cos[b$]]
This represents a function of a$
and b$
and contains the evaluated integral of Sin
. From here f[Sin][1,3]
will equal Cos[1]-Cos[3]
, which is equal to Integrate[Sin[x],{x,1,3}]
.
To evaluate a more arbitrary function, using pure functions is prudent. For example, to find the integral of $x^2$ once, write it as a pure function:
f[#^2 &]
(* Function[{a$,b$},-a$^3/3+b$^3/3] *)
f[#^2 &][1,2]
(* 7/3 *)