Composite Trapezoid Rule: Difference between revisions
Content added Content deleted
(Created page with "In mathematics, and more specifically in numerical analysis, the trapezoidal rule (also known as the trapezoid rule or trapezium rule) is a technique for approximating the In...") |
(No difference)
|
Revision as of 13:52, 8 April 2018
In mathematics, and more specifically in numerical analysis, the trapezoidal rule (also known as the trapezoid rule or trapezium rule) is a technique for approximating the In numerical analysis, the trapezoidal rule is used for approximation of a definite integral. The code here is a general purpose code for any equation.
MATLAB
function integral = trapezoidal(f, a, b, n)
h = (b-a)/n; result = 0.5*f(a) + 0.5*f(b); for i = 1:(n-1) result = result + f(a + i*h); end integral = h*result;
end