# Numerica integration with unequal intervals

1. Nov 1, 2014

### cris

Hello,

I have to compute the numerical integral of a function which is expressed at unequal (but almost) intervals. I tried the trapezoidal method, but the error is too large for my application. Is it possible to generalize the Boole's rule to or something on the same order of precision?

2. Nov 1, 2014

### mathman

You could try to generalize Simpson's rule. You need to fit quadratics to sequences of three points, with the third point of a sequence being the first point of the next. For each set of three calculate the integral of the quadratic as an estimate of the contribution to the integral.

3. Nov 1, 2014

### cris

Thanks for your reply. The generalized Simpson rule gives great improvement over the trapezoidal.
Though it appears I need something more ...

4. Nov 2, 2014

### mathman

What are you looking for?

5. Nov 2, 2014

### Dr.D

How do you know this is not good enough? What are you measuring against?

6. Nov 3, 2014

### ellipsis

If it's possible, use MATLAB's numerical integration solver ode45 (or its brothers). It allows you to integrate arbitrary functions (the programmatic sense) very accurately, including exotic ones such as discontinuous or chaotic functions.

I don't get what you mean by 'only expressed at certain unequal intervals'. Does this mean you only know a few data points? Or that the value of the expression only changes every interval? Is it smooth? The best method of numerical integration greatly depends on the properties of the function itself.