# How to estimate the error of trapezoidal rule using discrete data?

How can I estimate the error of a result obtained by using the trapezoidal rule if I don't have the function that describes my problem? The only thing I have is discrete points.

• Are your discrete points equispaced in its abscissae, or not? (Both answers below assume the former case, which indeed has a nicer theory.) – J. M. Apr 20 '17 at 23:53
• Actually, I did not assume equal spacing – Philip Roe Apr 21 '17 at 6:33

You may use the ideas of error extrapolation as one uses it to construct high-order Runge Kutta methods.

Depending on the function that you interpolate, the interpolation error $I - I_h$, where $I$ is the actual integral value and $I_h$ the value obtained by the piecewise trapezoidal rule, may have a smooth asymptotic expansion

$$I - I_h = C_p h^p + C_{p+1}h^{p+1} + ...$$

In the ODE context smooth means that the constants $C_p$, $C_{p+1}$, ... are smooth functions of time. I don't know how this translates to integration, but let's assume that they are independent of $h$.

Then, if you have enough samples and they are evenly spaced, you can assume that $h^{p+1}$ and higher order terms are negligible and that you can compute the approximation $I_h$ also for $h\leftarrow h/2$.

Then you set up the system

\begin{align} I - I_h = C_p h^p \\ I - I_{h/2} = C_p \frac{h^p}{2^p}, \end{align}

which you can solve for $C_p$ and $I$ which gives you the error $I-I_{h}$ up to all the assumptions we made before.

EDIT: In a former version, I assumed that the piecewise trapezoidal rule is convergent with order $3$. Actually, it is of order $2$. Anyway, I have put down the formulas for an arbitrary convergence order $p$.

There is a graphical version of this method (Richardson extrapolation) that can be very insightful. Use least three values of $h$, not necessarily different by factors of two or any other simple relationship. Plot $I_h$ versus $h^p$ where $p$ is the assumed order of accuracy. The result will be a straight line if your data is so smooth, and the spacing so small, that the asymptotic error estimate is valid (so that higher-order terms are indeed negligible) The intercept at $h=0$ of the best line through your points will be an improved estimate of the exact result. If you do not get a straight line then are you sure about $p$; should you try a different value?; is your spacing small enough? If the data are experimental, are they accurate enough?

It is not essential that the data be evenly spaced, but the refined data must be in some sense a systematic refinement. If the coarse data points were distributed according to some rule, like geometrical progression, then the finer data points should be distributed according to the same rule.