Implementing trapezoidal rule using def. The components are the target function, f, lower bound, a, upper bound, b, and the number of spaces, n.The logic of the function starts with opening the parenthesis of the original formula. Ignoring the n firstm the first term is f(x0)/2, and the last term is f(xn)/2. For the remaining terms, the coeffieintcy of 2 and 1/2 cancelled. 'S' is defined as the value of growth within the interval by (b-a)/n. Finally, all terms are added and multiplied by s.

Import integration method and calculate the precise answer for our example 2*x+3 from 1 to 9.

Performing trapezoidal rule fives times with different n each time. All of them result in the ideal answer. The reason for that is 2*x+3 is linear function, and the area of that from 1-9 is trapezoid.

As a function that cannot be integrated mannually, normal distribution is a perfect example to apply trapezoidal rule to find the integration of it. The fucntion of normal distribution is used with parameter mean = 0 and standard deviation = 1. A common knowledge for it is that if a random variable follows normal distribution, the max value of its CDF should be 1, which is also the max value of probability. The outcome of trapeziodal rule is very much the same.