2. Numerical Integration

MATLAB Trapezoidal Rule

Consider the function y=f(x) for the interval a≤x≤b, shown in figure:

MATLAB Trapezoidal Rule

To evaluate the definite integral, MATLAB Trapezoidal Ruledx, we divide the interval a≤x≤b into subintervals each of lengthMATLAB Trapezoidal Rule. Then, the number of points between x0=a,and xn=b is x1=a+∆x,x2=a+2∆x,…xn-1=a+(n-1)∆x. Therefore, the integral from a to b is the sum of the integrals from a to x1, from x1 to x2 and so on, and finally from xn-1 to b.

The total area is:

MATLAB Trapezoidal Rule

 0 P1 x1that is equal toMATLAB Trapezoidal Rule plus the area of the trapezoid x1 P1 P2 x2 that is equal to MATLAB Trapezoidal Rule, and so on. Then, the trapezoidal approximation becomesMATLAB Trapezoidal Rule


Using the trapezoidal rule with n=4, estimate the cost of the definite integralMATLAB Trapezoidal Rule

Compare with the exact value and evaluate the percent error.


The exact value of this integral isMATLAB Trapezoidal Rule

For the trapezoidal rule approximation, we haveMATLAB Trapezoidal Rule

and by substitution into an equationMATLAB Trapezoidal Rule

From equation 3 and equation 4, we find that the percent error isMATLAB Trapezoidal Rule

Leave a Reply

Your email address will not be published. Required fields are marked *