Question: Your task is to write a function that compute a definite integral, namely, integral _a^b f(x) dx where f is an arbitrary continuous unary function.

Your task is to write a function that compute a definite integral, namely, integral _a^b f(x) dx where f is an arbitrary continuous unary function. Naturally, you should provide a numerical solution using a simple method such as the trapezoidal method over a collection of boxes that sub-divide the integration interval [a, b]. Formally, given f, a, b and n, subdivide the range [a, b] into n sub-intervals (of width b-a) and compute the integral as the sum of the surfaces of the trapezoid embedded in each sub-interval. fun integrate f a b n =
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
