So for example:
So to find the area of sin(x) from let's say [x-d... x+d] we can integrate M with respect to x instead:
That simplified nicely!Now to do a whole interval we can just do the sum of this above function over the interval but that will count all but the very left and very right interval twice as [x-d..x+d] and [x-2*d..x] overlap the [x-d..x] region and the same on the right side of x, but either one quadratic function will be an overestimate and the other an underestimate or they're both overestimates or they're both underestimates any of which case the average is better than the worst of the two, so we divide by 2 after all is done and that minimizes the error overall, this is an oversimplification, but correcting for the far left and far right interval only being counted once adds complication for not much gain, and the error when d is small is small.
And that's the given formula... for example [.5..3] for sin(x) and d=.01 :
for d = .001
Other than the fact that the above example is a periodic function which the trapezoidal rule tends to work for really well, for other classes of functions it should be much better than the trapezoidal rule for approximately the same amount of computation because it fits closer to the real curve... It compares to the Simpson's rule that it is quite like doing the Simpson's rule over many small intervals and adding the results together. Since the Simpson's rule uses a quadratic function over the entire interval and this uses many smaller quadratic functions over the interval, so it is more accurate in general, though Simpson's rule is faster to compute.
It would be pretty straight forward to extend this to many small cubic, quartic, etc.. approximations over small intervals.