0
$\begingroup$

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!

$\endgroup$
  • $\begingroup$ There's no reason you can't NIntegrate[] an InterpolationFunction $\endgroup$ – Feyre Aug 9 '16 at 15:12
  • $\begingroup$ Yes, but compared to a non-interpolated function it takes much more computational time. That's the reason why I was wondering whether there is a more efficient way to store the interpolated values. $\endgroup$ – Display Name Aug 9 '16 at 15:15
  • $\begingroup$ I don't think that's true, at least not when you always use NIntegrate[] $\endgroup$ – Feyre Aug 9 '16 at 15:18
  • $\begingroup$ Ok, so if there is no other way that is more efficient I have to stick to this method and see how I can otherwise improve my code. $\endgroup$ – Display Name Aug 9 '16 at 15:19
  • 1
    $\begingroup$ Note that you can Integrate an InterpolatingFunction, since it is a piecewise-polynomial function and therefore easy to piecewise-integrate. (I learned that here somewhere.) $\endgroup$ – march Aug 9 '16 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.