I successfully imported some optical data to Mathematica, which I need to interpolate to use it as a proper function. The command data=Interpolation[] was quite helpful, but know I'm in doubt whether it is the best way to define a function f[x_]:=data[x] when the function will later be called upon in a numerical integration with NIntegrate[].
What is the best way to store the interpolated data in terms of computational time when using it later in NIntegrate[]? Any advice is highly appreciated.
Thank you!
NIntegrate[]anInterpolationFunction– Feyre Aug 09 '16 at 15:12NIntegrate[]– Feyre Aug 09 '16 at 15:18FindFit[]instead? – Feyre Aug 09 '16 at 15:23IntegrateanInterpolatingFunction, since it is a piecewise-polynomial function and therefore easy to piecewise-integrate. (I learned that here somewhere.) – march Aug 09 '16 at 15:36Integrate[func[x], {x, ...}], wherefuncis theInterpolatingFunction. As soon as you do e.g.Integrate[x^2 func[x], {x, ...}], it fails to integrate, even though one would hope that Mathematica would recognize thatx^2*func[x]is still piecewise-polynomial. – march Aug 09 '16 at 15:45