# Trapezoidal Rule for Numerical Integration

If the trapezoidal rule approximates an integral with trapezoids, then I thought (and was tought in high school) that the formula is:

$\frac{h}{2}(f(x) + f(x + h))$ Where $h$ is the distance between two points that are close together.

However, when I look up the Trapezoidal Rule online, I get a modified formual: (seethe links below)

http://mathworld.wolfram.com/TrapezoidalRule.html

http://mathworld.wolfram.com/Newton-CotesFormulas.html

Why is the additional term required? How does it change the approximation?

The application is that I am integrating an estimated probability density function. The PDF is estimated from empirical data with Kernel Density Estimation. I am using a Gaussian Kernel. Further, the data must be positive, so I used an approach that is described by Silverman 1998, "Density Estimation for Statistics and Data Analysis".

For each point x, in the dataset, I made another point -1*x. I then estimated the density on the that. I then discarded all of the negative points and multiplied the remaining points by two.

-
The "additional term" you speak of is the error incurred when you approximate the integral with the trapezoidal rule. In theory, adding that to your trapezoidal rule evaluation will give the exact answer; in practice, you almost never have something like that, so you just hope that that error term is reasonably tiny... – J. M. Nov 8 '12 at 11:11
So if I have a lot of data points, is it reasonal to just omit that correction term? – power Nov 8 '12 at 11:13
You won't even be able to compute that "correction term" to begin with; for the most part, it's really only useful for theoretical considerations. That's why I said "hope that that error term is reasonably tiny"... – J. M. Nov 8 '12 at 11:15
You're computing a CDF, I see. Could you maybe mention what probability distribution you're dealing with? The trapezoidal rule may or may not be the best way to go about computing the CDF... – J. M. Nov 8 '12 at 11:20
As others have said, that extra term just tells you what the error is in your approximation. You don't actually use that extra term when you are using the trapezoidal rule to approximate an integral. (Knowing that expression for the error allows you to sometimes compute a theoretical upper bound for the error in your approximation.) – littleO Nov 8 '12 at 12:06