Compute I = ∫[0 to 1] 1/(x^3 + 10) dx using Trapezoidal rule with the number of points 3, 5 and 9. Improve the results using Romberg integration.
Hint: For 3, 5 and 9 points, we have h = 1/2, 1/4 and 1/8 respectively.
Trapezoidal Rule Algorithm. Suppose the function f, the interval [a, b], the length n of the initial partition, a positive tolerance ε < 1, and the maximum number of iterations M are given. The following algorithm will compute a sequence of approximations to ∫[0 to 1] f(x)dx by the Trapezoidal rule, until the estimated relative error is smaller than ε, or the maximum number of computed approximations reach M. The final approximation is stored in I.
n := 1; I := 0; it := 0;
do {
it := it + 1; n := n * 2; I_old := I;
h := (b - a) / n; I := 0;
for i := 1, 2, ..., n - 1;
I := I + f(a + ih);
I := h/2 [f(a) + 2 * I + f(b)]
} while (it < M and |I - I_old| > ε * |I|);
Output: it, I.