6
$\begingroup$

I have a logarithmic grid, upon which i have two functions that are similar to this one (this is only the last 100 points):

enter image description here

These are essentially very similar to a Sin function at this point. I need to take the integral of two of these functions multiplied together, along with the position:

$$ \int_0^R f_1(r)\; r\; f_2(r)\; dr $$

Unfortunately, this gives me functions similar to the following:

enter image description here

I need to integrate these with high accuracy, but I'm not sure how to do it. There are a few options that I know of, but I expect there are more that I'm not sure of:

  • I can interpolate the original functions (is cubic interpolation a good interpolation strategy for sinusoids and products of sinusoids?), then multiply the interpolated functions together at specific points and use something from this scicomp post

  • I can switch the order of the interpolation and multiplication, multiplying the values I have, then taking the interpolation.

  • I can do a simpler Simpsons rule approximation, though I'm not sure how to do such a thing on a non-uniform grid.

$\endgroup$
12
  • $\begingroup$ Can you write out the form of the function, or is it a black box? $\endgroup$
    – Bill Barth
    Commented Feb 7, 2014 at 23:01
  • $\begingroup$ @BillBarth: Unfortunately, it is a black box. $\endgroup$ Commented Feb 7, 2014 at 23:11
  • $\begingroup$ Are the functions periodic, or you understand how they are not periodic if so? If they're periodic, taking the Fourier transform and analytically integrating the trigonometric polynomial will give very high accuracy (exponential convergence for analytic functions). $\endgroup$ Commented Feb 8, 2014 at 1:39
  • $\begingroup$ They are periodic within a certain range. Is taking the Fourier transform and then integrating the trigonometric polynomial really that efficient? I have to do this much more than 100,000 times, so efficiency matters at least a little bit. $\endgroup$ Commented Feb 8, 2014 at 2:01
  • $\begingroup$ @GeoffreyIrving: Sorry, they are on a non-uniform grid, which makes taking the fourier transform difficult. $\endgroup$ Commented Feb 10, 2014 at 22:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.