Let’s assume that f:[a,b]→R is integrable over [a,b], and [a,b] is divided into nodes like a=x0<⋯<xn=b.
The integral operator I is defined as I(f):=∫abf(x)dx.
The integral operator In is defined as In(f):=k=1∑n∫xk−1xkf(x)dx.
The error En is defined as En(f):=I(f)−In(f).
n→∞limEn(f)E~n(f)=1, satisfying E~n, is referred to as the asymptotic error for En.
Explanation
No one would dispute that calculating definite integrals is one of the goals of numerical analysis. In fact, the idea behind the method of exhaustion suggests that the more we divide the space, the better we can approximate the value of the integral. Thus, when it comes to numerical integration of interest in numerical analysis, it is about how much error there is, how to integrate when not in a closed interval, etc.
Example
Trapezoidal Rule
As an example of numerical integration, let’s take a look at the trapezoidal rule for f∈C2[a,b]. The Trapezoidal Rule approximates the value for I(f) by linearly interpolating f over the interval [a,b] and taking the integral of that function as the approximation for I(f).
I11(f):=(2b−a)[f(a)+f(b)]
In this case, the actual error between I(f) and I11(f)E11(f) can be computed as follows for some ξ∈[a,b].
[4] Error with the actual function: For a differentiable f:R→R up to (n+1) times and for some ξ∈H{x0,⋯,xn}, the polynomial interpolation of fpn satisfies f(t)−pn(t)=(n+1)!(t−x0)⋯(t−xn)f(n+1)(ξ) for some t∈R.
Now, considering dividing [a,b] into n intervals and approximating the integral at each [xk−1,xk] using the trapezoidal rule, the method is called the (Composite) Trapezoidal Rule.
In1(f):=k=1∑n2h(f(xk−1)+f(xk))
Then, the actual error between I(f) and In1(f) can be computed as follows for some ξk∈[xk−1,xk].
En1(f)===I(f)−In1(f)k=1∑n(−12h3f′′(ξk))−12h3n(n1k=1∑nf′′(ξk))
Here, since (n1k=1∑nf′′(ξk)) is the average of f’’(ξk), due to the Intermediate Value Theorem, there must exist some ξ∈[a,b] that satisfies x∈[a,b]minf′′(x)≤f′′(ξ)≤x∈[a,b]maxf′′(x). Thus,
En1(f)=−12(b−a)h2f′′(ξ)
Seeing the error formulated like this lets us understand that the wider the interval [a,b], the larger the error becomes, and the smaller h is, the more accurate it gets. However, due to f’’(ξ), we can’t know how much exactly it offsets. To overcome this, the asymptotic error is calculated as follows.
n→∞limh2En1(f)====n→∞limh21k=1∑n(−12h3f′′(ξk))−121n→∞limk=1∑nhf′′(ξk)−121∫abf′′(x)dx−121[f′(b)−f′(a)]
If we only know the error En1(f), according to the Theorem, we know that f’’(ξ) exists but couldn’t specify its value. But now,
E~n1(f):=n→∞limEn1(f)
for sufficiently large n, it can be understood that
En1(f)≈−12h2[f′(b)−f′(a)]=E~n1(f)
which makes it relatively simple and accurate to ascertain the error. Moreover, there’s no reason to stop at just knowing the extent of the error. If we can predict the error before even calculating, we can also correct for the error from the beginning.
I(f)−In1(f)≈E~n1(f)⟹I(f)≈In1(f)+E~n1(f)
Corrected Trapezoidal Rule
Let’s define the operator for calculating I(f) as follows.
CTn(f):=h[21f(x0)+f(x1)+⋯+f(xn−1)+21f(xn)]−12h2[f′(b)−f′(a)]
This method is referred to as the (Corrected) Trapezoidal Rule. [ NOTE: If you’ve followed the improvement process of the trapezoidal rule, you’d realize that there’s no need to distinguish between them explicitly. Simply calling it the trapezoidal rule would convey the meaning. ]
Implementation
The results of calculating ∫0πexcos(x)dx=−2eπ+1≈−12.0703 using In1 and CTn are as follows.
The first column represents n, the second I(f)−In1(f), and the third ∣I(f)−CT(f)∣. It can be observed that the error decreases by a factor of 41 when the number of nodes is doubled in the composite trapezoidal rule, and by 161 in the corrected trapezoidal rule. It’s evident that the corrected trapezoidal rule performs significantly better, especially in terms of speed.