In working with interpolating functions and integration, I noticed a lot of differences between NIntegrate and Integrate in the case of a function applied to an interpolating function.
In order to provide a simple example, look at this output:
ifun = Interpolation[ {{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}]
NIntegrate[x*ifun[x], {x, 0, 5}]
32.5694
xifun = FunctionInterpolation[x*ifun[x], {x, 0, 5}]
FunctionInterpolation::precbd: Requested precision [Infinity] is not a machine-sized real number between \$MinPrecision and \$MaxPrecision. >>
out = Integrate[xifun[x], {x, 0, 5}];
N[out]
32.591
The difference is at the second decimal place, or of the order of 0.06%. For more complicated functions (lots of data values and Bessel functions, I get errors of more than 100%).
I would like to know the reason of the error. In my real-life example I only get correct answers using the NIntegrate method.
I know there is this other question: How to integrate functions of linearly interpolated data?
But they don't use FunctionInterpolation and I think that there should be a simple explanation for this difference. My data is also not linearly-interpolated.
FunctionInterpolation. Go with what works. – m_goldberg Mar 04 '14 at 13:43xifun["Grid"] // Differencesreveals that the third argument is just the sampling step. – Alexey Popkov Mar 04 '14 at 16:34FunctionInterpolation::precbderror will be surpressed if one changes the range to be machine precision number i.e.{x,0,5}to be{x,0.,5}(@Santi). Very odd. – luyuwuli Mar 22 '16 at 11:58