When dealing with a slow function (e.g., a numerical integration) it is sometimes useful to tabulate it and create an interpolation function to work with instead. I found that one can deal with a possible extrapolation issues with "ExtrapolationHandler"
, e.g.,
FInterpolation[f_] :=
Interpolation[{#, f[#]} & /@ Range[0., 10., 0.1],
"ExtrapolationHandler" -> {f[#] &, "WarningMessage" -> False}]
will return an InterpolationFunction
object that will use function f
outside of the interpolation domain. But as far as I can see there is no similar functionality when using FunctionInterpolation
instead. Naively I'd expect that as the latter returns an InterpolationFunction
object as well, it should be possible to use
ifunc = FunctionInterpolation[f[x], {x, 0., 10.}]
and then modify the "ExtrapolationHandler"
inside ifunc
. Can one do that somehow?
My workaround was to use
FInterpolationExt[func_, domain_] := Module[{ifunc},
ifunc = FunctionInterpolation[func[x], {x, domain[[1]], domain[[2]]}];
If[domain[[1]] <= # <= domain[[2]], ifunc[#], func[#] ] & ]
which however does not return a simple InterpolationFunction
(and perhaps is not optimal?).
ifunc
is stored inifunc[[1,1]]
. To change it, you, could say:ifunc[[1,1]]= {new-start,new-end}
$\endgroup$ifunc[[2, 10]] = f[#] &
-- is there a way of adding"WarningMessage" -> False
as well? It does not work this way:ifunc[[2, 10]] = {f[#] &, "WarningMessage" -> False}
$\endgroup$