This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Lecture 21 Integration: Left, Right and Trapezoid Rules The Left and Right endpoint rules In this section, we wish to approximate a definite integral: integraldisplay b a f ( x ) dx where f ( x ) is a continuous function. In calculus we learned that integrals are (signed) areas and can be approximated by sums of smaller areas, such as the areas of rectangles. We begin by choosing points { x i } that subdivide [ a,b ]: a = x < x 1 < ... < x n 1 < x n = b. The subintervals [ x i 1 ,x i ] determine the width Δ x i of each of the approximating rectangles. For the height, we learned that we can choose any height of the function f ( x * i ) where x * i ∈ [ x i 1 ,x i ]. The resulting approximation is: integraldisplay b a f ( x ) dx ≈ n summationdisplay i =1 f ( x * i )Δ x i . To use this to approximate integrals with actual numbers, we need to have a specific x * i in each interval. The two simplest (and worst) ways to choose x * i are as the lefthand point or the righthand point of each interval. This gives concrete approximations which we denote by L n and R n given by L n = n summationdisplay i =1 f ( x i 1 )Δ x i and R n = n summationdisplay i =1 f ( x i )Δ x i . function L = myleftsum(x,y) % produces the left sum from data input. % Inputs: x  vector of the x coordinates of the partition % y  vector of the corresponding y coordinates % Output: returns the approximate integral n = max(size(x)); % safe for column or row vectors L = 0; for i = 1:n1 L = L + y(i)*(x(i+1)  x(i)); end 75 76...
View
Full Document
 Fall '08
 Young,T
 Integrals, Tn, trapezoid rule

Click to edit the document details