(I am teaching a course on Measure and Probability and was quite happy to find the following computational exercise to give to the students.)
The following computational exercise may help clarify the different methods of integrating functions and their relative utility.
Take an any "algebraic function" f (like a polynomial or rational function or something like f(x) = √(()1 − x2) ) which is continuous on [0, 1] .
- Integrate it using High-School methods and calculate the value. (You may need to use a power series method to integrate term-by-term.)
- Integrate it numerically by Simpson's rule (or trapezoidal rule) by choosing a sufficiently fine partition of [0, 1] into small intervals.
- Integrate it by Monte-Carlo. Choose a uniformly random large finite sequence xn in [0, 1] (by using a Pseudo-random generator) and calculating the average value of f(xn) .
After writing the program you should test which method is faster.
Note that if you know the function only approximately, then (1) is not available but (2) may still give a reasonable answer.
If you know only a large number of (x, f(x)) values (experimental data) then (2) is also not available and you can only use (3).
Method (1) is Newton/Liebnitz integration, (2) is Riemann integration and (3) is Lebesgue integration.