Chapter 5: Problem 18
Rearranging Eq. (5.19) into a slightly more conventional form, we have: $$ \int_{a}^{b} f(x) \mathrm{d} x=h\left[\frac{1}{2} f(a)+\frac{1}{2} f(b)+\sum_{k=1}^{N-1} f(a+k h)\right]+\frac{1}{12} h^{2}\left[f^{\prime}(a)-f^{\prime}(b)\right]+\mathrm{O}\left(h^{4}\right) . $$ This result gives a value for the integral on the left which has an error of order \(h^{4}-a\) factor of \(h^{2}\) better than the error on the trapezoidal rule and as good as Simpson's rule. We can use this formula as a new rule for evaluating integrals, distinct from any of the others we have seen in this chapter. We might call it the "Euler-Maclaurin rule." a) Write a program to calculate the value of the integral \(\int_{0}^{2}\left(x^{4}-2 x+1\right) \mathrm{d} x\) using this formula. (This is the same integral that we studied in Example 5.1, whose true value is \(4.4\).) The order- \(h\) term in the formula is just the ordinary trapezoidal rule; the \(h^{2}\) term involves the derivatives \(f^{\prime}(a)\) and \(f^{\prime}(b)\), which you should evaluate using central differences, centered on \(a\) and \(b\) respectively. Note that the size of the interval you use for calculating the central differences does not have to equal the value of \(h\) used in the trapezoidal rule part of the calculation. An interval of about \(10^{-5}\) gives good values for the central differences. Use your program to evaluate the integral with \(N=10\) slices and compare the accuracy of the result with that obtained from the trapezoidal rule alone with the same number of slices. b) Good though it is, this integration method is not much used in practice. Suggest a reason why not.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.