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 edit summary
Line 1: Line 1:
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.
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
== MATLAB ==


function integral = trapezoidal(f, a, b, n)
function integral = trapezoidal(f, a, b, n)
Line 12: Line 12:
integral = h*result;
integral = h*result;
end
end

f is the equation, a is the lower limit, b is the upper limit, and n is the number of trapezoids or number of integration points.